@@ -1880,18 +1880,17 @@ static void drain_local_memcg_stock(struct work_struct *dummy)
1880
1880
static void drain_local_obj_stock (struct work_struct * dummy )
1881
1881
{
1882
1882
struct obj_stock_pcp * stock ;
1883
- unsigned long flags ;
1884
1883
1885
1884
if (WARN_ONCE (!in_task (), "drain in non-task context" ))
1886
1885
return ;
1887
1886
1888
- local_lock_irqsave (& obj_stock .lock , flags );
1887
+ local_lock (& obj_stock .lock );
1889
1888
1890
1889
stock = this_cpu_ptr (& obj_stock );
1891
1890
drain_obj_stock (stock );
1892
1891
clear_bit (FLUSHING_CACHED_CHARGE , & stock -> flags );
1893
1892
1894
- local_unlock_irqrestore (& obj_stock .lock , flags );
1893
+ local_unlock (& obj_stock .lock );
1895
1894
}
1896
1895
1897
1896
static void refill_stock (struct mem_cgroup * memcg , unsigned int nr_pages )
@@ -2874,10 +2873,10 @@ static bool consume_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes,
2874
2873
struct pglist_data * pgdat , enum node_stat_item idx )
2875
2874
{
2876
2875
struct obj_stock_pcp * stock ;
2877
- unsigned long flags ;
2878
2876
bool ret = false;
2879
2877
2880
- local_lock_irqsave (& obj_stock .lock , flags );
2878
+ if (!local_trylock (& obj_stock .lock ))
2879
+ return ret ;
2881
2880
2882
2881
stock = this_cpu_ptr (& obj_stock );
2883
2882
if (objcg == READ_ONCE (stock -> cached_objcg ) && stock -> nr_bytes >= nr_bytes ) {
@@ -2888,7 +2887,7 @@ static bool consume_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes,
2888
2887
__account_obj_stock (objcg , stock , nr_bytes , pgdat , idx );
2889
2888
}
2890
2889
2891
- local_unlock_irqrestore (& obj_stock .lock , flags );
2890
+ local_unlock (& obj_stock .lock );
2892
2891
2893
2892
return ret ;
2894
2893
}
@@ -2977,10 +2976,16 @@ static void refill_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes,
2977
2976
enum node_stat_item idx )
2978
2977
{
2979
2978
struct obj_stock_pcp * stock ;
2980
- unsigned long flags ;
2981
2979
unsigned int nr_pages = 0 ;
2982
2980
2983
- local_lock_irqsave (& obj_stock .lock , flags );
2981
+ if (!local_trylock (& obj_stock .lock )) {
2982
+ if (pgdat )
2983
+ mod_objcg_mlstate (objcg , pgdat , idx , nr_bytes );
2984
+ nr_pages = nr_bytes >> PAGE_SHIFT ;
2985
+ nr_bytes = nr_bytes & (PAGE_SIZE - 1 );
2986
+ atomic_add (nr_bytes , & objcg -> nr_charged_bytes );
2987
+ goto out ;
2988
+ }
2984
2989
2985
2990
stock = this_cpu_ptr (& obj_stock );
2986
2991
if (READ_ONCE (stock -> cached_objcg ) != objcg ) { /* reset if necessary */
@@ -3002,8 +3007,8 @@ static void refill_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes,
3002
3007
stock -> nr_bytes &= (PAGE_SIZE - 1 );
3003
3008
}
3004
3009
3005
- local_unlock_irqrestore (& obj_stock .lock , flags );
3006
-
3010
+ local_unlock (& obj_stock .lock );
3011
+ out :
3007
3012
if (nr_pages )
3008
3013
obj_cgroup_uncharge_pages (objcg , nr_pages );
3009
3014
}
0 commit comments