mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: Khazhy Kumykov <khazhy@chromium.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>, Christoph Lameter <cl@gentwo.org>,
	Tejun Heo <tj@kernel.org>, Dennis Zhou <dennis@kernel.org>,
	Kaitao Cheng <kaitao.cheng@linux.dev>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/percpu: avoid IO dependency in alloc_percpu
Date: Tue, 16 Jun 2026 07:53:13 +0200	[thread overview]
Message-ID: <4983aced-49ae-4440-828c-09231b344be8@kernel.org> (raw)
In-Reply-To: <CACGdZYKvi0CGGUfcp3WZVqTOvtYDFMOyd1TPkySyPM4OiHYbJw@mail.gmail.com>

On 6/16/26 04:08, Khazhy Kumykov wrote:
> On Mon, Jun 15, 2026 at 6:23 PM Khazhismel Kumykov <khazhy@chromium.org> wrote:
>>
>> percpu_alloc users within noio context may block on other percpu_alloc
>> users doing IO due to the shared pcpu_alloc_mutex. pcpu_balance_workfn
>> already grabs under noio context - update remaining holders to also run
>> under noio.
>>
>> Lockdep reported this as a circular locking dependency, with one caller
>> having entered fs_reclaim holding pcpu_alloc_mutex, and the second
>> caller (elevator init) grabbing pcpu_alloc_mutex in noio context.
>>
>> Fixes: 9a5b183941b5 ("mm, percpu: do not consider sleepable allocations atomic")
>>
>> Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
>> ---
>>  mm/percpu.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/percpu.c b/mm/percpu.c
>> index b0676b8054ed..50057403ae79 100644
>> --- a/mm/percpu.c
>> +++ b/mm/percpu.c
>> @@ -1749,8 +1749,13 @@ void __percpu *pcpu_alloc_noprof(size_t size, size_t align, bool reserved,
>>         size_t bits, bit_align;
>>
>>         gfp = current_gfp_context(gfp);
>> -       /* whitelisted flags that can be passed to the backing allocators */
>> -       pcpu_gfp = gfp & (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
>> +       /*
>> +        * whitelisted flags that can be passed to the backing allocators.
>> +        *
>> +        * Allocations must be GFP_NOIO, else users in noio/nofs contexts may
>> +        * form dependency through pcpu_alloc_mutex
>> +        */
>> +       pcpu_gfp = gfp & (GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN);
> ah, this is incomplete since we have subsequent allocations that use
> "GFP_KERNEL", I'll send a version with memalloc_noio instead.
> Apologies...

Please see https://lore.kernel.org/all/20260612022648.13008-1-kaitao.cheng@linux.dev/
 
>>         is_atomic = !gfpflags_allow_blocking(gfp);
>>         do_warn = !(gfp & __GFP_NOWARN);
>>
>> --
>> 2.54.0.1189.g8c84645362-goog
>>


      reply	other threads:[~2026-06-16  5:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16  1:22 Khazhismel Kumykov
2026-06-16  2:08 ` Khazhy Kumykov
2026-06-16  5:53   ` Vlastimil Babka (SUSE) [this message]

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=4983aced-49ae-4440-828c-09231b344be8@kernel.org \
    --to=vbabka@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=dennis@kernel.org \
    --cc=kaitao.cheng@linux.dev \
    --cc=khazhy@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=tj@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®