Skip to content

Commit 86e98ed

Browse files
committed
Merge tag 'cgroup-for-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: - cpuset changes including the fix for an incorrect interaction with CPU hotplug and an optimization - Other doc and cosmetic changes * tag 'cgroup-for-6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: docs: cgroup-v1/cpusets: update libcgroup project link cgroup/cpuset: Minor updates to test_cpuset_prs.sh cgroup/cpuset: Include offline CPUs when tasks' cpumasks in top_cpuset are updated cgroup/cpuset: Skip task update if hotplug doesn't affect current cpuset cpuset: Clean up cpuset_node_allowed cgroup: bpf: use cgroup_lock()/cgroup_unlock() wrappers
2 parents cd546fa + 9403d9c commit 86e98ed

10 files changed

Lines changed: 99 additions & 100 deletions

File tree

Documentation/admin-guide/cgroup-v1/cpusets.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ There are ways to query or modify cpusets:
719719
cat, rmdir commands from the shell, or their equivalent from C.
720720
- via the C library libcpuset.
721721
- via the C library libcgroup.
722-
(http://sourceforge.net/projects/libcg/)
722+
(https://github.com/libcgroup/libcgroup/)
723723
- via the python application cset.
724724
(http://code.google.com/p/cpuset/)
725725

include/linux/cpuset.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,11 @@ extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
8080
void cpuset_init_current_mems_allowed(void);
8181
int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask);
8282

83-
extern bool __cpuset_node_allowed(int node, gfp_t gfp_mask);
84-
85-
static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
86-
{
87-
if (cpusets_enabled())
88-
return __cpuset_node_allowed(node, gfp_mask);
89-
return true;
90-
}
83+
extern bool cpuset_node_allowed(int node, gfp_t gfp_mask);
9184

9285
static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
9386
{
94-
return __cpuset_node_allowed(zone_to_nid(z), gfp_mask);
87+
return cpuset_node_allowed(zone_to_nid(z), gfp_mask);
9588
}
9689

9790
static inline bool cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
@@ -223,11 +216,6 @@ static inline int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask)
223216
return 1;
224217
}
225218

226-
static inline bool cpuset_node_allowed(int node, gfp_t gfp_mask)
227-
{
228-
return true;
229-
}
230-
231219
static inline bool __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
232220
{
233221
return true;

kernel/bpf/cgroup.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ void bpf_cgroup_atype_put(int cgroup_atype)
173173
{
174174
int i = cgroup_atype - CGROUP_LSM_START;
175175

176-
mutex_lock(&cgroup_mutex);
176+
cgroup_lock();
177177
if (--cgroup_lsm_atype[i].refcnt <= 0)
178178
cgroup_lsm_atype[i].attach_btf_id = 0;
179179
WARN_ON_ONCE(cgroup_lsm_atype[i].refcnt < 0);
180-
mutex_unlock(&cgroup_mutex);
180+
cgroup_unlock();
181181
}
182182
#else
183183
static enum cgroup_bpf_attach_type
@@ -282,7 +282,7 @@ static void cgroup_bpf_release(struct work_struct *work)
282282

283283
unsigned int atype;
284284

285-
mutex_lock(&cgroup_mutex);
285+
cgroup_lock();
286286

287287
for (atype = 0; atype < ARRAY_SIZE(cgrp->bpf.progs); atype++) {
288288
struct hlist_head *progs = &cgrp->bpf.progs[atype];
@@ -315,7 +315,7 @@ static void cgroup_bpf_release(struct work_struct *work)
315315
bpf_cgroup_storage_free(storage);
316316
}
317317

318-
mutex_unlock(&cgroup_mutex);
318+
cgroup_unlock();
319319

320320
for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p))
321321
cgroup_bpf_put(p);
@@ -729,9 +729,9 @@ static int cgroup_bpf_attach(struct cgroup *cgrp,
729729
{
730730
int ret;
731731

732-
mutex_lock(&cgroup_mutex);
732+
cgroup_lock();
733733
ret = __cgroup_bpf_attach(cgrp, prog, replace_prog, link, type, flags);
734-
mutex_unlock(&cgroup_mutex);
734+
cgroup_unlock();
735735
return ret;
736736
}
737737

@@ -831,7 +831,7 @@ static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog,
831831

832832
cg_link = container_of(link, struct bpf_cgroup_link, link);
833833

834-
mutex_lock(&cgroup_mutex);
834+
cgroup_lock();
835835
/* link might have been auto-released by dying cgroup, so fail */
836836
if (!cg_link->cgroup) {
837837
ret = -ENOLINK;
@@ -843,7 +843,7 @@ static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog,
843843
}
844844
ret = __cgroup_bpf_replace(cg_link->cgroup, cg_link, new_prog);
845845
out_unlock:
846-
mutex_unlock(&cgroup_mutex);
846+
cgroup_unlock();
847847
return ret;
848848
}
849849

@@ -1009,9 +1009,9 @@ static int cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,
10091009
{
10101010
int ret;
10111011

1012-
mutex_lock(&cgroup_mutex);
1012+
cgroup_lock();
10131013
ret = __cgroup_bpf_detach(cgrp, prog, NULL, type);
1014-
mutex_unlock(&cgroup_mutex);
1014+
cgroup_unlock();
10151015
return ret;
10161016
}
10171017

@@ -1120,9 +1120,9 @@ static int cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr,
11201120
{
11211121
int ret;
11221122

1123-
mutex_lock(&cgroup_mutex);
1123+
cgroup_lock();
11241124
ret = __cgroup_bpf_query(cgrp, attr, uattr);
1125-
mutex_unlock(&cgroup_mutex);
1125+
cgroup_unlock();
11261126
return ret;
11271127
}
11281128

@@ -1189,11 +1189,11 @@ static void bpf_cgroup_link_release(struct bpf_link *link)
11891189
if (!cg_link->cgroup)
11901190
return;
11911191

1192-
mutex_lock(&cgroup_mutex);
1192+
cgroup_lock();
11931193

11941194
/* re-check cgroup under lock again */
11951195
if (!cg_link->cgroup) {
1196-
mutex_unlock(&cgroup_mutex);
1196+
cgroup_unlock();
11971197
return;
11981198
}
11991199

@@ -1205,7 +1205,7 @@ static void bpf_cgroup_link_release(struct bpf_link *link)
12051205
cg = cg_link->cgroup;
12061206
cg_link->cgroup = NULL;
12071207

1208-
mutex_unlock(&cgroup_mutex);
1208+
cgroup_unlock();
12091209

12101210
cgroup_put(cg);
12111211
}
@@ -1232,10 +1232,10 @@ static void bpf_cgroup_link_show_fdinfo(const struct bpf_link *link,
12321232
container_of(link, struct bpf_cgroup_link, link);
12331233
u64 cg_id = 0;
12341234

1235-
mutex_lock(&cgroup_mutex);
1235+
cgroup_lock();
12361236
if (cg_link->cgroup)
12371237
cg_id = cgroup_id(cg_link->cgroup);
1238-
mutex_unlock(&cgroup_mutex);
1238+
cgroup_unlock();
12391239

12401240
seq_printf(seq,
12411241
"cgroup_id:\t%llu\n"
@@ -1251,10 +1251,10 @@ static int bpf_cgroup_link_fill_link_info(const struct bpf_link *link,
12511251
container_of(link, struct bpf_cgroup_link, link);
12521252
u64 cg_id = 0;
12531253

1254-
mutex_lock(&cgroup_mutex);
1254+
cgroup_lock();
12551255
if (cg_link->cgroup)
12561256
cg_id = cgroup_id(cg_link->cgroup);
1257-
mutex_unlock(&cgroup_mutex);
1257+
cgroup_unlock();
12581258

12591259
info->cgroup.cgroup_id = cg_id;
12601260
info->cgroup.attach_type = cg_link->type;

kernel/bpf/cgroup_iter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void *cgroup_iter_seq_start(struct seq_file *seq, loff_t *pos)
5858
{
5959
struct cgroup_iter_priv *p = seq->private;
6060

61-
mutex_lock(&cgroup_mutex);
61+
cgroup_lock();
6262

6363
/* cgroup_iter doesn't support read across multiple sessions. */
6464
if (*pos > 0) {
@@ -89,7 +89,7 @@ static void cgroup_iter_seq_stop(struct seq_file *seq, void *v)
8989
{
9090
struct cgroup_iter_priv *p = seq->private;
9191

92-
mutex_unlock(&cgroup_mutex);
92+
cgroup_unlock();
9393

9494
/* pass NULL to the prog for post-processing */
9595
if (!v) {

kernel/bpf/local_storage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,14 @@ static void cgroup_storage_map_free(struct bpf_map *_map)
333333
struct list_head *storages = &map->list;
334334
struct bpf_cgroup_storage *storage, *stmp;
335335

336-
mutex_lock(&cgroup_mutex);
336+
cgroup_lock();
337337

338338
list_for_each_entry_safe(storage, stmp, storages, list_map) {
339339
bpf_cgroup_storage_unlink(storage);
340340
bpf_cgroup_storage_free(storage);
341341
}
342342

343-
mutex_unlock(&cgroup_mutex);
343+
cgroup_unlock();
344344

345345
WARN_ON(!RB_EMPTY_ROOT(&map->root));
346346
WARN_ON(!list_empty(&map->list));

kernel/cgroup/cgroup-v1.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
5858
struct cgroup_root *root;
5959
int retval = 0;
6060

61-
mutex_lock(&cgroup_mutex);
61+
cgroup_lock();
6262
cgroup_attach_lock(true);
6363
for_each_root(root) {
6464
struct cgroup *from_cgrp;
@@ -72,7 +72,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
7272
break;
7373
}
7474
cgroup_attach_unlock(true);
75-
mutex_unlock(&cgroup_mutex);
75+
cgroup_unlock();
7676

7777
return retval;
7878
}
@@ -106,7 +106,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
106106
if (ret)
107107
return ret;
108108

109-
mutex_lock(&cgroup_mutex);
109+
cgroup_lock();
110110

111111
percpu_down_write(&cgroup_threadgroup_rwsem);
112112

@@ -145,7 +145,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
145145
out_err:
146146
cgroup_migrate_finish(&mgctx);
147147
percpu_up_write(&cgroup_threadgroup_rwsem);
148-
mutex_unlock(&cgroup_mutex);
148+
cgroup_unlock();
149149
return ret;
150150
}
151151

@@ -847,13 +847,13 @@ static int cgroup1_rename(struct kernfs_node *kn, struct kernfs_node *new_parent
847847
kernfs_break_active_protection(new_parent);
848848
kernfs_break_active_protection(kn);
849849

850-
mutex_lock(&cgroup_mutex);
850+
cgroup_lock();
851851

852852
ret = kernfs_rename(kn, new_parent, new_name_str);
853853
if (!ret)
854854
TRACE_CGROUP_PATH(rename, cgrp);
855855

856-
mutex_unlock(&cgroup_mutex);
856+
cgroup_unlock();
857857

858858
kernfs_unbreak_active_protection(kn);
859859
kernfs_unbreak_active_protection(new_parent);
@@ -1119,7 +1119,7 @@ int cgroup1_reconfigure(struct fs_context *fc)
11191119
trace_cgroup_remount(root);
11201120

11211121
out_unlock:
1122-
mutex_unlock(&cgroup_mutex);
1122+
cgroup_unlock();
11231123
return ret;
11241124
}
11251125

@@ -1246,7 +1246,7 @@ int cgroup1_get_tree(struct fs_context *fc)
12461246
if (!ret && !percpu_ref_tryget_live(&ctx->root->cgrp.self.refcnt))
12471247
ret = 1; /* restart */
12481248

1249-
mutex_unlock(&cgroup_mutex);
1249+
cgroup_unlock();
12501250

12511251
if (!ret)
12521252
ret = cgroup_do_get_tree(fc);

0 commit comments

Comments
 (0)