lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ha4sqstdknwvvubs2g33r3itrabepz2jwlr3ksrbjdlgjnbuel@appekpf6ffud>
Date: Wed, 23 Apr 2025 15:16:56 -0700
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, 
	Johannes Weiner <hannes@...xchg.org>, Michal Hocko <mhocko@...nel.org>, 
	Roman Gushchin <roman.gushchin@...ux.dev>, Muchun Song <muchun.song@...ux.dev>, 
	Vlastimil Babka <vbabka@...e.cz>, Eric Dumazet <edumazet@...gle.com>, 
	Soheil Hassas Yeganeh <soheil@...gle.com>, linux-mm@...ck.org, cgroups@...r.kernel.org, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Meta kernel team <kernel-team@...a.com>
Subject: Re: [PATCH] memcg: multi-memcg percpu charge cache

Hi Jakub,

On Tue, Apr 22, 2025 at 06:10:22PM -0700, Jakub Kicinski wrote:
> On Wed, 16 Apr 2025 11:02:29 -0700 Shakeel Butt wrote:
> >  static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
> >  {
> >  	struct memcg_stock_pcp *stock;
> > -	unsigned int stock_pages;
> > +	struct mem_cgroup *cached;
> > +	uint8_t stock_pages;
> 
> Is it okay to use uintX_t now?
> 
> >  	unsigned long flags;
> > +	bool evict = true;
> > +	int i;
> >  
> >  	VM_WARN_ON_ONCE(mem_cgroup_is_root(memcg));
> >  
> > -	if (!local_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
> > +	if (nr_pages > MEMCG_CHARGE_BATCH ||
> > +	    !local_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
> >  		/*
> > -		 * In case of unlikely failure to lock percpu stock_lock
> > -		 * uncharge memcg directly.
> > +		 * In case of larger than batch refill or unlikely failure to
> > +		 * lock the percpu stock_lock, uncharge memcg directly.
> >  		 */
> 
> We're bypassing the cache for > CHARGE_BATCH because the u8 math 
> may overflow? Could be useful to refocus the comment on the 'why'
> 

We actually never put more than MEMCG_CHARGE_BATCH in the cache and thus
we can use u8 as type here. Though we may increase the batch size in
future, so I should put a BUILD_BUG_ON somewhere here.

> >  		memcg_uncharge(memcg, nr_pages);
> >  		return;
> >  	}
> 
> nits notwithstanding:
> 
> Acked-by: Jakub Kicinski <kuba@...nel.org>

Thanks a lot for the review.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ