All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Uladzislau Rezki <urezki@gmail.com>, Thomas Graf <tgraf@suug.ch>,
	oe-lkp@lists.linux.dev, lkp@intel.com,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>, Baoquan He <bhe@redhat.com>,
	Alexander Potapenko <glider@google.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Marco Elver <elver@google.com>, Michal Hocko <mhocko@kernel.org>,
	linux-mm@kvack.org
Subject: Re: [linus:master] [mm]  c6307674ed: BUG:sleeping_function_called_from_invalid_context_at_mm/vmalloc.c
Date: Wed, 22 Apr 2026 09:17:54 +0200	[thread overview]
Message-ID: <aeh2Ii9CxtgfsX_p@milan> (raw)
In-Reply-To: <aehdcxC14ycvY481@gondor.apana.org.au>

On Wed, Apr 22, 2026 at 01:32:35PM +0800, Herbert Xu wrote:
> On Tue, Apr 21, 2026 at 02:36:26PM +0200, Uladzislau Rezki wrote:
> >
> > <snip>
> > diff --git a/lib/rhashtable.c b/lib/rhashtable.c
> > index 6074ed5f66f3..a892766dcedd 100644
> > --- a/lib/rhashtable.c
> > +++ b/lib/rhashtable.c
> > @@ -473,7 +473,7 @@ static int rhashtable_insert_rehash(struct rhashtable *ht,
> >  
> >  	err = rhashtable_rehash_attach(ht, tbl, new_tbl);
> >  	if (err) {
> > -		bucket_table_free(new_tbl);
> > +		call_rcu(&new_tbl->rcu, bucket_table_free_rcu);
> >  		if (err == -EEXIST)
> >  			err = 0;
> >  	} else
> > <snip>
> > 
> > Could you please check? The problem here is
> > 
> > rcu_read_lock()
> >     rhashtable_insert_rehash()
> >         vfree();
> > rcu_read_unlokc();
> > 
> > we can just defer freeing via call_rcu().
> 
> I think we should fix that warning instead.  The memory
> that's being freed here was just allocated in exactly the
> same context through kvmalloc with GFP_ATOMIC.  I can't
> see why you're allowed to call kvmalloc but not kvfree.
> 
> That makes no sense.
> 
There is vfree_atomic() implementation. Regular vfree(), historically
is not supposed to be called from non-sleeping contexts:

<snip>
 * Context:
 * May sleep if called *not* from interrupt context.
 * Must not be called in NMI context (strictly speaking, it could be
 * if we have CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG, but making the calling
 * conventions for vfree() arch-dependent would be a really bad idea).
 */
void vfree(const void *addr)
{
	struct vm_struct *vm;
	int i;

	if (unlikely(in_interrupt())) {
		vfree_atomic(addr);
		return;
	}

	BUG_ON(in_nmi());
	kmemleak_free(addr);
	might_sleep();
<snip>

since your GFP_ATOMIC context allocated chunk of memory using vmalloc()
sense kvfree() uses vfree(). The simplest fix to free via RCU.

--
Uladzislau Rezki


  reply	other threads:[~2026-04-22  7:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  7:45 [linus:master] [mm] c6307674ed: BUG:sleeping_function_called_from_invalid_context_at_mm/vmalloc.c kernel test robot
2026-04-21 12:36 ` Uladzislau Rezki
2026-04-22  5:32   ` Herbert Xu
2026-04-22  7:17     ` Uladzislau Rezki [this message]
2026-04-22  7:59       ` Herbert Xu
2026-04-22  8:18         ` [PATCH] rhashtable: Check for vmalloc in emergency rehash error path Herbert Xu
2026-04-22  8:32         ` [linus:master] [mm] c6307674ed: BUG:sleeping_function_called_from_invalid_context_at_mm/vmalloc.c Uladzislau Rezki
2026-04-23  3:34           ` Herbert Xu
2026-04-27  8:53             ` Vlastimil Babka
2026-04-27 14:17               ` Uladzislau Rezki
2026-04-27 14:37                 ` Vlastimil Babka
2026-04-27 16:19                   ` Uladzislau Rezki
2026-04-28  1:29                     ` Herbert Xu
2026-04-28 12:04                       ` Uladzislau Rezki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aeh2Ii9CxtgfsX_p@milan \
    --to=urezki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mhocko@kernel.org \
    --cc=mhocko@suse.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=ryabinin.a.a@gmail.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.