@@ -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
183183static 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 );
845845out_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 ;
0 commit comments