Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpuset: fix the issue of cannot add task if cpus and mems empty in cp… #11

Open
wants to merge 100 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
9ce206f
probe cgroup v1 mount path
liubin Aug 25, 2020
6b1b26b
copy cpuset after created
liubin Aug 25, 2020
9d70467
add hugetlb functions
liubin Aug 25, 2020
c702852
add disable oom_control function
liubin Aug 25, 2020
9fe6cb5
change *limit* in memory from u64 to i64
liubin Aug 25, 2020
704db32
fix: create all dirs
liubin Aug 31, 2020
c623dc3
add basic v2 cpu/memory functions
liubin Sep 2, 2020
cd2c748
add systemd controller; add more tests; update blkio stat for v2
liubin Sep 4, 2020
86b2450
add SPDX-License-Identifier for all source
liubin Sep 7, 2020
a1bc586
Merge pull request #3 from liubin/fix/2
bergwolf Sep 8, 2020
5d51e50
get relative paths at new/load func default.
liubin Sep 7, 2020
c391222
use let Some() instead of is_some() to make codes clear
liubin Sep 9, 2020
bcbf438
Merge remote-tracking branch 'upstream/master'
liubin Sep 9, 2020
ff6a0ea
add SPDX-License-Identifier for modified files
liubin Sep 9, 2020
250ada1
cargo fmt
liubin Sep 9, 2020
be61719
hugetlb: update test to avoid depending on test env
liubin Sep 9, 2020
d20e6a5
Merge pull request #4 from liubin/master
bergwolf Sep 9, 2020
f8d653e
cpu: change cfs_quota from u64 to i64
liubin Sep 14, 2020
42685bb
errors: add sync marker to error cause
liubin Sep 14, 2020
0aaf7db
Merge pull request #6 from liubin/fix/cfs_quota-to-i64
bergwolf Sep 14, 2020
3852d7c
Merge pull request #8 from liubin/fix/7-add-sync-marker-to-error-cause
bergwolf Sep 14, 2020
cd7e737
lib: fix compiling error for type i8 in aarch64 environment
Kvasscn Sep 21, 2020
8717524
Merge pull request #10 from Kvasscn/fix-type-i8-compile-error-in-aarch64
lifupan Sep 22, 2020
db40fe8
update Travis configs
liubin Sep 22, 2020
f0eac78
Merge pull request #12 from liubin/fix/11-add-trivas
bergwolf Sep 23, 2020
414fa28
add basic github workflow for basic checks
liubin Sep 23, 2020
d18b3ba
Merge pull request #16 from liubin/enhancement/15-add-workflow-checks
liubin Sep 23, 2020
152af17
fix build warnings
liubin Sep 23, 2020
c310b30
Merge pull request #14 from liubin/enhancement/13-fix-warnings
jodh-intel Oct 1, 2020
efb9810
Fix warnings
Tim-Zhang Oct 29, 2020
42eb327
Make methods to_controller and controller_name of Subsystem public
Tim-Zhang Oct 29, 2020
6f9e895
MemController: add method reset_max_usage
Tim-Zhang Oct 29, 2020
af6fc63
Merge pull request #17 from Tim-Zhang/minor-updates
lifupan Oct 30, 2020
ca610bb
add add_task_by_tgid
Jul 24, 2020
0c18b08
Support customized attributes for CpuController and MemController
Tim-Zhang Nov 4, 2020
567cdb4
Use Option as resource fields, remove the update switch: update_values
Tim-Zhang Nov 5, 2020
10650e2
Update tests to adapt new type of fields in resource
Tim-Zhang Nov 9, 2020
0f76570
Avoid exception caused by cgroup writeback feature
Tim-Zhang Nov 5, 2020
121f78d
Expose deletion error
Tim-Zhang Nov 9, 2020
1ac76b6
Make function find_v1_mount pub
Tim-Zhang Nov 9, 2020
cd998f3
Do not place cgroup under relative path read from cgroup by default
Tim-Zhang Nov 11, 2020
f342254
Remove Box wrap of Cgroup.hire
Tim-Zhang Nov 11, 2020
fbd7164
Fix warnings in tests
Tim-Zhang Nov 11, 2020
1f188be
Detect subsystems and get root from /proc/self/mountinfo
Tim-Zhang Nov 12, 2020
abcb5ed
Add more logs for create_dir error in controller.create
Tim-Zhang Nov 12, 2020
d2882b1
Print cause when println!("{}")
Tim-Zhang Nov 13, 2020
b6bb5ae
docs: Hide Re-exports
Tim-Zhang Nov 17, 2020
42ee1ba
Make Cgroup can be stored in struct
Tim-Zhang Dec 3, 2020
438d774
Fix test
Tim-Zhang Dec 3, 2020
c254fff
Update readme
Tim-Zhang Dec 3, 2020
0592045
Ignore kmem in cgroup v2
Tim-Zhang Dec 7, 2020
61a0957
Fix set_swappiness in cgroup v2
Tim-Zhang Dec 7, 2020
a89f4a0
Support set notify_on_release & release_agent
houstar Dec 9, 2020
e1e05d3
Make new_with_relative_paths=new and load_with_relative_paths=new in v2
Tim-Zhang Dec 16, 2020
e160df0
Make read_i64_from private and merge read_str_from to its caller
Tim-Zhang Dec 17, 2020
9baa065
release: v0.2.0
Tim-Zhang Nov 9, 2020
8f6a7e0
Merge pull request #19 from Tim-Zhang/0.2.0
lifupan Dec 21, 2020
eb6577e
Change package name to cgroups-rs
Tim-Zhang Dec 21, 2020
35ecd6f
Update readme
Tim-Zhang Dec 21, 2020
ac4e6ed
Merge pull request #21 from Tim-Zhang/change-name
bergwolf Dec 21, 2020
033fa4b
optimize and refactor: read_to_string and read_i[u]64_from
Apokleos Dec 23, 2020
50d3c39
Merge pull request #22 from Apokleos/master
Tim-Zhang Jan 6, 2021
f0a695c
Add trait bound Sync for Hierarchy
Tim-Zhang Jan 6, 2021
225388f
release: v0.2.1
Tim-Zhang Jan 6, 2021
87f8ac7
Merge pull request #23 from Tim-Zhang/add-trait-bound-for-hierarchy
Tim-Zhang Jan 7, 2021
15b65c5
Apply customized attributes in MemController.apply
Tim-Zhang Jan 25, 2021
853ed46
release: v0.2.2
Tim-Zhang Jan 25, 2021
bbdfa88
Merge pull request #26 from Tim-Zhang/memory-apply-customized-attrs
Tim-Zhang Jan 25, 2021
d50245e
github: add issue templates
bergwolf Jan 25, 2021
8448548
Merge pull request #30 from bergwolf/issue-templates
Tim-Zhang Jan 25, 2021
0c58b5d
Add Makefile
Tim-Zhang Jan 25, 2021
88a45d4
Migrate the CI from travis-ci to Github Actions
Tim-Zhang Jan 25, 2021
a58cd1d
Merge pull request #31 from Tim-Zhang/switch-travis-to-github-action
Tim-Zhang Jan 25, 2021
9ac2f5d
Add field homepage and readme for Cargo.toml
Tim-Zhang Jan 25, 2021
4a20420
Merge pull request #28 from Tim-Zhang/update-cargo-toml
Tim-Zhang Jan 25, 2021
cd5645b
cgroup: fix the issue of remove cgroup
lifupan Jan 25, 2021
5e538ae
Merge pull request #33 from lifupan/master
lifupan Jan 25, 2021
81d286f
cgroup: get the mount info without procinfo
quanweiZhou Jan 30, 2021
d1d78fe
Merge pull request #34 from quanweiZhou/get_mountinfo_without_procinfo
lifupan Feb 1, 2021
79868d6
release: v0.2.3
Tim-Zhang Feb 2, 2021
87f0587
Merge pull request #35 from Tim-Zhang/v0.2.3
lifupan Feb 2, 2021
b9ca0a5
Update nix to 0.20.0
Jakob-Naucke Feb 22, 2021
16d73e1
Merge pull request #38 from Jakob-Naucke/update-nix
lifupan Feb 25, 2021
8720aed
memory: fix panic when no hierarchical numa stat is available
bergwolf Feb 25, 2021
2209189
Merge pull request #39 from bergwolf/fix-panic
lifupan Feb 25, 2021
60820bf
release: v0.2.4
Jakob-Naucke Feb 25, 2021
0a3e4a8
memory: fix parse_oom_control panic on older kernels
bergwolf Feb 25, 2021
6100717
Merge pull request #41 from bergwolf/fix-panic
lifupan Mar 2, 2021
9ec1010
Fix clippy warnings
Tim-Zhang Jan 25, 2021
fdabe52
github action: Add clippy check
Tim-Zhang Mar 3, 2021
fb56c81
Merge pull request #32 from Tim-Zhang/fix-clippy
liubin Mar 3, 2021
af7a75c
Merge pull request #40 from Jakob-Naucke/v0.2.4
liubin Mar 3, 2021
aa207ed
Impl Clone for hierarchies:V1, hierarchies:V2
Tim-Zhang Mar 23, 2021
c4850ef
Merge pull request #44 from Tim-Zhang/impl-clone
liubin Mar 23, 2021
0b2a040
release: v0.2.5
Tim-Zhang Mar 24, 2021
5bb27a2
Merge pull request #45 from Tim-Zhang/release-0.2.5
lifupan Mar 24, 2021
5aa7e6c
Fix clippy for rust 1.52
Tim-Zhang May 20, 2021
0e2430f
clippy: turn on lint upper_case_acronyms
Tim-Zhang May 20, 2021
45b626e
Merge pull request #46 from Tim-Zhang/fix-clippy-for-rust-1.52
lifupan May 21, 2021
4b5a190
freezer: fix the issue of missing trim the str
Jun 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
upper-case-acronyms-aggressive = true
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug, needs-review'
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Enhancement request
about: Suggest an improvement to an existing feature
title: ''
labels: enhancement, needs-review
assignees: ''

---

**Which feature do you think can be improved?**

Specify the feature you think could be made better.

**How can it be improved?**

Describe how specifically you think it could be improved.

**Additional Information**

Anything else to add?
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'feature, needs-review'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
21 changes: 21 additions & 0 deletions .github/workflows/PR-wip-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull request WIP checks
on:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
- labeled
- unlabeled

jobs:
pr_wip_check:
runs-on: ubuntu-latest
name: WIP Check
steps:
- name: WIP Check
uses: tim-actions/wip-check@1c2a1ca6c110026b3e2297bb2ef39e1747b5a755
with:
labels: '["do-not-merge", "wip", "rfc"]'
keywords: '["WIP", "wip", "RFC", "rfc", "dnm", "DNM", "do-not-merge"]'
34 changes: 34 additions & 0 deletions .github/workflows/bvt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: BVT
on: [pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: make debug

fmt:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup component add rustfmt
- run: make fmt
clippy:
name: Clippy Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup component add clippy
- run: make clippy
test:
name: Run Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make test


53 changes: 53 additions & 0 deletions .github/workflows/commit-message-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Commit Message Check
on:
pull_request:
types:
- opened
- reopened
- synchronize

env:
error_msg: |+
See the document below for help on formatting commits for the project.

https://github.com/kata-containers/community/blob/master/CONTRIBUTING.md#patch-forma

jobs:
commit-message-check:
runs-on: ubuntu-latest
name: Commit Message Check
steps:
- name: Get PR Commits
id: 'get-pr-commits'
uses: tim-actions/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: DCO Check
uses: tim-actions/dco@2fd0504dc0d27b33f542867c300c60840c6dcb20
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}

- name: Commit Body Missing Check
if: ${{ success() || failure() }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}

- name: Check Subject Line Length
if: ${{ success() || failure() }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^.{0,75}(\n.*)*$'
error: 'Subject too long (max 75)'
post_error: ${{ env.error_msg }}

- name: Check Body Line Length
if: ${{ success() || failure() }}
uses: tim-actions/[email protected]
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
pattern: '^.+(\n.{0,72})*$|^.+\n\s*[^a-zA-Z\s\n]|^.+\n\S+$'
error: 'Body line too long (max 72)'
post_error: ${{ env.error_msg }}
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

16 changes: 10 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[package]
name = "cgroups"
name = "cgroups-rs"
description = "Native Rust crate for managing control groups on Linux"
repository = "https://github.com/levex/cgroups-rs"
repository = "https://github.com/kata-containers/cgroups-rs"
keywords = ["linux", "cgroup", "containers", "isolation"]
categories = ["os", "api-bindings", "os::unix-apis"]
license = "MIT OR Apache-2.0"
version = "0.1.1-alpha.0"
authors = ["Levente Kurusa <[email protected]>", "Sam Wilson <[email protected]>"]
version = "0.2.5"
authors = ["The Kata Containers community <[email protected]>", "Levente Kurusa <[email protected]>", "Sam Wilson <[email protected]>"]
edition = "2018"
homepage = "https://github.com/kata-containers/cgroups-rs"
readme = "README.md"

[dependencies]
log = "0.4"
regex = "1.1"
nix = "0.20.0"
libc = "0.2"

[dev-dependencies]
nix = "0.11.0"
libc = "0.2.43"
libc = "0.2.76"
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
all: debug fmt test

#
# Build
#

.PHONY: debug
debug:
RUSTFLAGS="--deny warnings" cargo build

.PHONY: release
release:
cargo build --release

.PHONY: build
build: debug

#
# Tests and linters
#

.PHONY: test
test:
cargo test -- --color always --nocapture

.PHONY: check
check: fmt clippy


.PHONY: fmt
fmt:
cargo fmt --all -- --check

.PHONY: clippy
clippy:
cargo clippy --all-targets --all-features -- -D warnings

28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
# cgroups-rs ![Build](https://travis-ci.org/levex/cgroups-rs.svg?branch=master)
# cgroups-rs ![Build](https://travis-ci.org/kata-containers/cgroups-rs.svg?branch=master)
Native Rust library for managing control groups under Linux

Right now the crate only support the original, V1 hierarchy, however support
is planned for the Unified hierarchy.
Both v1 and v2 of cgroups are supported.

# Examples

## Create a control group using the builder pattern

``` rust
// Acquire a handle for the V1 cgroup hierarchy.
let hier = ::hierarchies::V1::new();


use cgroups_rs::*;
use cgroups_rs::cgroup_builder::*;

// Acquire a handle for the cgroup hierarchy.
let hier = cgroups_rs::hierarchies::auto();

// Use the builder pattern (see the documentation to create the control group)
//
// This creates a control group named "example" in the V1 hierarchy.
let cg: Cgroup = CgroupBuilder::new("example", &v1)
.cpu()
.shares(85)
.done()
.build();
let cg: Cgroup = CgroupBuilder::new("example")
.cpu()
.shares(85)
.done()
.build(hier);

// Now `cg` is a control group that gets 85% of the CPU time in relative to
// other control groups.

// Get a handle to the CPU controller.
let cpus: &CpuController = cg.controller_of().unwrap();
cpus.add_task(1234u64);
let cpus: &cgroups_rs::cpu::CpuController = cg.controller_of().unwrap();
cpus.add_task(&CgroupPid::from(1234u64));

// [...]

Expand Down
Loading