From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07B223BFE31 for ; Tue, 2 Jun 2026 08:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780387514; cv=none; b=FVroZo1ImYLS/7SUV/EIs+M8Au+ZI1NSFE2Wf2IVQYbnF0fnQYkS4qvKLUO2qPuL2Fu6QGjDPfIJhP7wruJqzhRZ0Bh2Zh3qCZq6x8dZVDAnQHxvCHdskXt3c2AH3FZShS8/tsfUDtMq+SUDktEbW0+qqk6BwGmX7fEiGwVEUmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780387514; c=relaxed/simple; bh=Is8UNNawHDpbO35O437+ypRNOjV0l+iTICeec47W1ck=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tTWyAuH2mn9ojdGDKchqVhmWFfa9Q2j4nMWmxvwW0NIV0FnbjHM+7vSbA3fp3INGueKoPTZ0t7s+M3WdUU1cOlmB8XkjDqNvdK/xaYrlmruoHTG7xmakUCfo7L/xMlYQb0wICJ+kY0nm+BqAOMxo1zmNDJ+BnhSaY2oxkAuUZJc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=JzyCRShz; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="JzyCRShz" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490a765d410so24754565e9.1 for ; Tue, 02 Jun 2026 01:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780387508; x=1780992308; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=+73prwKKyusKu0UeoZTCHGTOBel/fBfTSc0ORj8rmnQ=; b=JzyCRShzAbNLieLnWsKpyd6h/GtQ6l57FMBi5u67tC2535drBmDO1dlabVZ91m3Ggb MtUGpKLK9CP+3/NPXTB8i5m+YL/ZbCRWLoC2RcaamRGqObzrZL8Fc9394Z6nzAadmJVF KV7LHJrWirK8c9/cmxXZC01J9cqwZLfuF2R/HC8VE2FrksiorcSJXlu7sxD1/02+dIGd 5l9sA45awuc8X1yuuxLnVpfgDEbGg/MRC4Mw3lM0jIDZRRcqFnnM3qdFyc49PFxtUvlW BZ6RAuGVwBFW7TIRKbKNKdDNkX5OGsi4Ft70jDJbL+P3zPo/vR+HOa2zqIC8p3lhbAmo GaCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780387508; x=1780992308; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+73prwKKyusKu0UeoZTCHGTOBel/fBfTSc0ORj8rmnQ=; b=liLssgJu8EZscrzdazCrJ3IhZUdZQDYH+mpMXUfpYnR8GM/LsS9eE9k6iIbwibEeum n18rggE/AgYgTCp3UwKbQ/GID0KUenMkzaROeX4AHZsi1zndK5gtHNQsQh5ikuTVAHZ5 QEO/P/rZwOD1B0n0M7HfN47QdTx8M6fOLav25CH/8uP0VU6jZww9aSDDH5IEfUDTirfn 6vTjvGnRAo07cgdn21RkFrcWelcVYNzkAQMTqS3o/B0y2BZt4ywuy9o3CsqbR/fILnmY Es8T4cCunXGhvb3TRM33JAvLwnS6ZYP4EmX/004WLPc62XFOULdWD9axIG1uGib4K1oI 11Kw== X-Forwarded-Encrypted: i=1; AFNElJ/rTL1ilOqRJwoRuLQ5w4tm4DgkFi4eCHnn+wpeCNMcJ0FRQtQpDzuUgQTGK36yWnYzkkSVLO77X7k23c8=@vger.kernel.org X-Gm-Message-State: AOJu0YxftWiTTJFGh9InkH4RmeSQ1kf3OAKBvm2PSe9Pu8rIhUkDPghY i77/amIPTb5GG/qsF22XmLLEFI+0nzmT6bNuNGburvmP5fzIt3Z4TimRcBVLYUdwYWI= X-Gm-Gg: Acq92OHgxgCzLHt34V6YHYy82mU40NWybMGWRW7YrWcIhh1BWG2dTXkFh0/RS0BhEqF D9L9E3cUJqac4rJ31+MjgCXLRdoEOZArZzc8ZZnPstXo7/kRyb4UxIop2i+7It9MfqpjgvrRvJV xinzLBdqD8aAi+yNYC8GKVivwSTxI+Dsz5rPNlC5sQWfFhfAg8n5nBv04777h02xg45xdzH3nbO KtpE4y7zqjdCkDF0UAdFnHEY0+cOEFCkWCLFwE0JT5fOSV6ztHXCfRE7mV98BObexPjZORRLQEx mohlq8IdNrpNSA3+keVjoVV5DUBDJjTL3msh03i0to//6l+aXfH4SS4QvFflx1YTbuZEFW9eetQ 9ypmKsW6mGbMZeZV3d7VuzamVcu0/riuTui5zGg5A9wbqOZ51h+dzDQ7CItFBCdhbPJjNQOdr2F ozhvuNjCfqNzOmuta1ssSZQws0d4MyqloYGEfisJ+9Sly1gXI= X-Received: by 2002:a05:600c:8582:b0:488:b187:3c with SMTP id 5b1f17b1804b1-490a29399fcmr211068615e9.14.1780387508166; Tue, 02 Jun 2026 01:05:08 -0700 (PDT) Received: from localhost (109-81-85-133.rct.o2.cz. [109.81.85.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef3587072sm32018554f8f.34.2026.06.02.01.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 01:05:07 -0700 (PDT) Date: Tue, 2 Jun 2026 10:05:06 +0200 From: Michal Hocko To: "Vlastimil Babka (SUSE)" Cc: Kaitao Cheng , Dennis Zhou , Pedro Falcato , akpm@linux-foundation.org, tj@kernel.org, cl@gentwo.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, muchun.song@linux.dev, Kaitao Cheng Subject: Re: [PATCH 1/2] mm/percpu: Preserve NOFS/NOIO scope during chunk create and populate Message-ID: References: <20260528132917.81123-1-kaitao.cheng@linux.dev> <20260528132917.81123-2-kaitao.cheng@linux.dev> <5a4aa532-77a0-436a-8f5e-1bbcf2db6bbb@linux.dev> <7e913ba8-fa91-4916-a871-66de7c80cd29@linux.dev> <536ea40b-8501-4a81-84c7-de5f12f4eaf3@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <536ea40b-8501-4a81-84c7-de5f12f4eaf3@kernel.org> On Tue 02-06-26 09:16:24, Vlastimil Babka (SUSE) wrote: > On 6/2/26 05:03, Kaitao Cheng wrote: > > > > > > 在 2026/6/1 23:45, Michal Hocko 写道: > >> On Mon 01-06-26 10:27:53, Kaitao Cheng wrote: > >>> However, if we revert 9a5b183941b, it seems that all of these issues would > >>> be resolved. The only downside is that the failure rate of pcpu_alloc_noprof() > >>> allocations may increase, which might be acceptable. > >> > >> That has practical impact on some versions of iscsid which do not have > >> PR_SET_IO_FLUSHER. And maybe some more so I would rather not revert > >> based on a theoretical concerns which I believe is the case here. > >> > > > > Based on the previous discussion, I think we have a way to address most > > of the concurrency issues around percpu allocation. > > > > However, there still seems to be one remaining case that I do not yet > > have a good way to solve. For example: > > > > Thread A calls pcpu_alloc_noprof() with GFP_KERNEL and takes > > pcpu_alloc_mutex. Since the internal allocation is not constrained by > > NOFS, it may enter FS reclaim while still holding pcpu_alloc_mutex, > > creating a dependency like: > > > > pcpu_alloc_mutex -> fs_reclaim -> FS lock > > At the same time, Thread B may already hold an FS lock and then call > > pcpu_alloc_noprof() with GFP_NOFS. It will try to acquire > > pcpu_alloc_mutex and block, creating the reverse dependency: > > > > FS lock -> pcpu_alloc_mutex > > This can still form a potential deadlock cycle. > > > > Does anyone have a good suggestion for how to handle this remaining case? > > Or should we simply treat all GFP_KERNEL/GFP_NOFS allocation behavior in > > pcpu_alloc_noprof() as GFP_NOIO? > > > > If there is no clear solution for now, would it be acceptable to first > > fix some of the issues introduced by commit 9a5b183941b, and leave this > > remaining case as a pre-existing historical issue to be handled separately > > later? > > We don't need to solve any issues that are only theoretical and based on > scenarios that nobody sane should be doing, i.e. Pedro already pointed out > "As in no reclaim path should be insane^W daring enough to do pcpu allocations?" Yes, but you do not need to do a pcp allocation from the reclaim path to hit the deadlock. All you need is a NOFS pcp allocation - e.g. one done from NOFS scope. Then you have fs lock <-> pcpu_alloc_mutex dependency and a potential deadlock. It is hard to know whether we have any of those in the kernel but I know for a fact (9a5b183941b) that there are scoped NOIO allocations so I wouldn't be suprised if the same was the case for NOFS. Not only that having NOIO is a weaker reclaim context. > Elsewhere Pedro said "The proper way of fixing this would probably be to > release pcpu_alloc_mutex (or not have it in the first place!) while you're > allocating memory." I do agree with this. Back then when I was dealing with the NOIO issue I've tried to look at the lock and drop it but it was not really straightforward. Maybe my lack of close understanding of the pcp allocator was an obstacle there. So if there is a path forward like that then it would certainly be the best. -- Michal Hocko SUSE Labs