From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C79C5314D14 for ; Thu, 28 May 2026 21:09:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780002584; cv=none; b=nHXkJmHQ1WB3G45IG3bnutdWV9eNfXnDQiJcYG/QoMPvT2RIOTIvunzpoUstAyuOeysi1PQ9D3CAG3UEFCqHloX8eGL/5h1MyZDFbWRTMrx64BNWqnI6yzaRSKNff5VUezW23k82k7ZqrtBwLjT0IrupU37Yg1+H27WWPezw7bs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780002584; c=relaxed/simple; bh=2GY4yAUWYz/TB26PCnwoc4lzvoeVVrsRWJP6OFN8n6k=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=AcWNxPwlS19dRujdIWjhRgTF8TFeRTlhwIUXhYL7cHfMylwIKYyc3v1b3Q6h9xizciB7L0Oyl/nOJwHySWYCTN217bwhVcHmu/slfCylENCS5V0ojpk81obb9LOxhwlQjCnC+3YbkRLmC9kO6m/zq5LIJQ4gI60OmqnMuF+1GVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=QdVKGUMq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="QdVKGUMq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E00A1F000E9; Thu, 28 May 2026 21:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1780002583; bh=ttjnkg846TiOVQr/VBhwCx0vrR70Kt1d8MiwRlUR7wY=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=QdVKGUMqHsnanE2JOFLtHGkjdR91mWePXCqK2pDbgCxlpstZzRHYENHkhHEpk4oDn 47EIDjyV24mdhXCvfS3nIvxYaKltabtAscC/O4DpYdaLUQ/2hp5EovwTE5mgQTpOF9 EnqF2oHGxy+4tZqpEpHrOfIxpXiF6mL0LuIVoTes= Date: Thu, 28 May 2026 14:09:42 -0700 From: Andrew Morton To: Kaitao Cheng Cc: dennis@kernel.org, tj@kernel.org, cl@gentwo.org, mhocko@suse.com, vbabka@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, muchun.song@linux.dev Subject: Re: [PATCH 0/2] mm/percpu: Fix possible NOFS/NOIO reclaim recursion Message-Id: <20260528140942.a0e9a82aa6f98430266ce8ea@linux-foundation.org> In-Reply-To: <20260528132917.81123-1-kaitao.cheng@linux.dev> References: <20260528132917.81123-1-kaitao.cheng@linux.dev> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 28 May 2026 21:29:15 +0800 Kaitao Cheng wrote: > Commit 9a5b183941b5 ("mm, percpu: do not consider sleepable allocations > atomic") allowed GFP_NOFS and GFP_NOIO percpu allocations to use > pcpu_alloc_mutex and the chunk creation slow path. This restored the > allocation capability that was lost when those constrained allocations > were treated as atomic, but it also opens two possible reclaim recursion > problems. > > The first problem is that the create and populate slow paths do not fully > preserve the caller's allocation constraints. pcpu_alloc_noprof() derives > pcpu_gfp from the caller supplied GFP mask and passes it to the backing > page allocator. However, pcpu_create_chunk() calls pcpu_get_vm_areas(), > and population can allocate temporary metadata or page tables while mapping > backing pages. Those internal allocations can use GFP_KERNEL. A caller > using GFP_NOFS or GFP_NOIO can therefore still enter unconstrained FS or > IO reclaim while holding pcpu_alloc_mutex. This defeats the caller's > allocation context. > > The second problem is a possible pcpu_alloc_mutex recursion from reclaim. > If reclaim is entered while pcpu_alloc_mutex is already held, and reclaim > reaches a path which allocates percpu memory with GFP_NOFS or GFP_NOIO, > the nested allocation can now try to take pcpu_alloc_mutex again because > 9a5b183941b5 no longer treats those masks as atomic. > > Another possible way to avoid these issues is to revert 9a5b183941b5. > However, that would also bring back the premature allocation failures for > sleepable GFP_NOFS/GFP_NOIO percpu users that 9a5b183941b5 was intended > to fix. Thanks. 9a5b183941b5 has been in there for a year. How are you observing/triggering this bug and what are the userspace-visible effects? We might choose to backport fixes into -stable kernels, but this additional info is needed to make that determination.