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] [day] [month] [year] [list]
Message-ID: <20251016063043.AqrS2HeR@linutronix.de>
Date: Thu, 16 Oct 2025 08:30:43 +0200
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: "Vishal Moola (Oracle)" <vishal.moola@...il.com>
Cc: Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
	Vlastimil Babka <vbabka@...e.cz>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Christoph Lameter <cl@...two.org>,
	David Rientjes <rientjes@...gle.com>,
	Roman Gushchin <roman.gushchin@...ux.dev>,
	Harry Yoo <harry.yoo@...cle.com>,
	Clark Williams <clrkwllms@...nel.org>,
	Steven Rostedt <rostedt@...dmis.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org, linux-rt-devel@...ts.linux.dev
Subject: Re: [PATCH] mempool: clarify behavior of mempool_alloc_preallocated()

On 2025-10-15 15:46:13 [-0700], Vishal Moola (Oracle) wrote:
> On Wed, Oct 15, 2025 at 09:27:17PM +0200, Sebastian Andrzej Siewior wrote:
> > On 2025-10-15 11:52:24 [-0700], Vishal Moola (Oracle) wrote:
> > > > --- a/mm/mempool.c
> > > > +++ b/mm/mempool.c
> > > > @@ -461,8 +461,8 @@ EXPORT_SYMBOL(mempool_alloc_noprof);
> > > >   *             mempool_create().
> > > >   *
> > > >   * This function is similar to mempool_alloc, but it only attempts allocating
> > > > - * an element from the preallocated elements. It does not sleep and immediately
> > > > - * returns if no preallocated elements are available.
> > > > + * an element from the preallocated elements. It only takes a single spinlock_t
> > > 
> > > Might it make more sense to say "It may sleep" instead of "takes a
> > > single spinlock_t"?
> > 
> > May sleep usually refers to something that can not be used in an
> > interrupt handler.
> 
> Gotcha. 
> 
> > > I feel like the fact that we take a spinlock isn't the important part
> > > here (especially because we always drop it before returning).
> > It actually is. A spinlock_t can not be acquired in hardirq context or
> > when interrupts are explicitly disabled via local_irq_disable().
> > Therefore you should use the function in a local_irq_disable() section.
> 
> As someone not too familiar with how the locking intertwines with the
> scheduler contexts, seeing something like that makes much more sense
> to me than seeing "it only takes a single spinlock_t."

I am not too happy about this wording but I don't have a better idea
either. However "may sleep" is too broad. The spinlock_t is at the very
least documented in
	Documentation/locking/locktypes.rst

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ