From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796062328; b=lSDyOCwIb9DrgNN2s4/0ZU9F7UAkPLZH9V3adwYezTOx5yPkUyV/jjjPpGqecAwJgvot 8SSYU7UMlHtu9UWwX/5ppUmexTKu2MVQ4KinBt7b7WbyVQhIoPNj9/oBoq+vNO1JWgpl2 nK+ZvMV3r9xEQYdGQ3QV5ochL36lpRnEJBPpt26L2NmWZ4ubXxfSOZb/6yEKsLVa6PDH0 adqQvO52dtfz+p1k+ul5vdFtTPltDAiyhxMIZeFlcHKGqbukt7bWf/4TssnsjXwwjpkkY nZV3XWD3sCGgZBW+WITk3YVsAeQpeImhzf+zlOpIPomJ2kyN7SO+SV0UVRrW11Od6Ng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796062328; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=cDA9KFxYrkVUtNueBT0ZhF3RHSpVtb9q1qDnDNHyEh4=; b=peDvneRGkp9MHEa4KqvAQ16EPNtXTGeNPnpexS9B4XJGp/arjRbk8xMIseLbOfrKvHgS ALkACJTGNWiubzML6TYkj7kei37fqyHS034HGy+iaazxHulNrfm+sFnI9hvg8xiID+OV1 aOorvmF+XvItk2oVxosFxdT3IlIhWTbbTS4YbdCx5hBhS+37uk78HmHb+zAvtjWBNVc17 NGb6JNiUfrx3GjF0Xx3RRmwPSLcLuLQ/S1I2x4NZvWyUaqcLA1ZQpYoYA3LuyeHbCTgrk oZFO9XVEmOadhZX6bmFMkELw+0osWmt+U9ffi2wL7jJdYt1wn/pVEu8o9Y2ohXh8msg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=b66pywA5; arc=none smtp.remote-ip=209.85.222.45 Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 366BC606A68D for ; Mon, 30 Nov 2026 18:12:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 366BC606A68D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=b66pywA5 Received: by mail-ua1-f45.google.com with SMTP id a1e0cc1a2514c-9828fee1b4bso3432831241.3 for ; Mon, 30 Nov 2026 10:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796062327; x=1796667127; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=cDA9KFxYrkVUtNueBT0ZhF3RHSpVtb9q1qDnDNHyEh4=; b=b66pywA58jJFlyDUrvCn6B4f0Eqj7t9VmrV633zEKhgwzBAtk01Lc4/I+Kp6gtt7jU zcNTEQ9/jKmH7Iv1wuybyq8GI58UaGVbpwqlwPOdYCCzsi0nkfh70zLFAOvurlP1NQBc J9p8IaJbGWVA/Wx2jpI2lFMh67n6ir7B7z1btykdexT+c5wNXUISYiiQhF8aVwROL3oV 0nfz8WXpgxD+lSxA9f0EbgCYQzT1OpFrIswZjrIQJcHk1B8eDY1uYaBZGIWA+L7221PM uw93GtpXPSel4KLyvgUrcGt+j+RexgvDmN4IlYmFE9GB8QOmeGjAGSOuJbD2Ufp5lyrj 3WZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796062327; x=1796667127; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cDA9KFxYrkVUtNueBT0ZhF3RHSpVtb9q1qDnDNHyEh4=; b=xSZiDhC/FL4+li1ckC3uXChu/Nb/kn9SB9pMv7i3Hesvwgk79SEeR9uHToirVZNSvE aUTJqEIDTuGhyiM+ts2lltutog5ppCgHvEeXHXxj4sgCK32KrX88Cz8eCQJQpoLNrLmr GfBUkn1Uz239/GMYkXps7Es2YWMX8LP5IxT5pK88oFAFB6v6VkMvg6RqX7KL8Kk2YTgZ AS/+C+mzwaVom748EqVyuadgQDujE93O5L/bAjFckRdKl3XiiXe2O2DL+K3h50auWQuQ wmVc6eg4Ufk8HlPl98j0upWh4UGkzE9qrT/TnP8fvcLi7z4VorvDxkQf8ArGDKBYWG4/ PHhQ== X-Forwarded-Encrypted: i=1; AL+hErFwwry+gy8RD8XkhIEGGHfTh6vd8usrXLICkXhRXUpM40uUr5P+DR5wx3auLYuzv8h0rYPMlxBYFyYGbyQ=@vger.kernel.org X-Gm-Message-State: APuU4Z9eZRdwvE0dX6YmW/yyf6hHjSmV4DUrxF3uzT1AwGdnEWn7+EOj FEN1ewoZx00r8XMgyCHhcZVBeGnIYQKH0EgyVmddb3r2DL04luMXu7+oms314F8GewU= X-Gm-Gg: AZFdTZc0Su+fSEiQ98zDN+pxDFjIxZn8KmXVQ5zMzitnmCoN/k8M7EMxSIFvrDexyNC dHRBlcl101ejWNnU3QnZERDmacVz0CbQ2TuDTVpEOe+5WdUqhqYelwmHERfcwlBa1MIyYwf9a+v DbjUPKZCtzdP/mvsoHRDOLEqfxGPcO/PEml6zrRQqEciJPRn9xZ9Dpergmf8wXVBXVdFvi8qXhC Q8KZ7RkWbBtm6Wz0g3UoAKAr8v/duHB8wF0NAk23oDFhIcNhIntWqukyYDs1oHXNWevsw7u+iVJ AFWi+d7fJUZRtQ2DcCO17lCBrvkwwNVN6edU8gE/H2Qm8iFrtyCOBdIqBHyWGjXaxjJuTiOGzqs it7ERmtIS/SmgdfsURrKPplpobHKHNwI57RSxabv+TDwGgNDWODoLwdDTazD/LJZeHfkbMFknC+ NMKPC9yb2NokFFdtpdYJsQtRtz1DcsCU/jStuX8N0RAGD5ojbvYMlfnwdOMmM6Qn+parktawtzr 7v5+0ZtDUMzb2uwrwQBoAxMlb6iJUHY+0pz/k+CFqP8QvlFOL5Uc8lxj1h0Z2QmmU0RuDi3VY14 YEPjjy7LG/PoR1s5mkudiPR8VEBR6/kcLgysNrtb10bp3nzSR5Nl4/ayLfrLzOP5X7+LQpiHk12 2Y1cfGMw= X-Received: by 2002:a05:6122:552:b0:5ce:d56f:efac with SMTP id 71dfb90a1353d-5ee8af6ef4bmr22545321e0c.21.1796062326379; Mon, 30 Nov 2026 10:12:06 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-55d78880604sm289690801cf.24.2026.11.30.10.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:12:05 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 25/32] mm/mempolicy: don't wait for mems_allowed_seq in kmalloc_nolock() From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason In-Reply-To: <20261129-fixes_core_3-v1-25-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-25-f66094116801@kernel.org> Date: Mon, 30 Nov 2026 13:12:03 -0500 Message-Id: <179606232333.412063.9827468608746549903.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, David Hildenbrand (Arm) wrote: > kmalloc_nolock() must not wait for locks, including seqlocks. > get_from_any_partial() therefore skips read_mems_allowed_begin() if > spinning is not allowed. > > However, with an MPOL_INTERLEAVE or MPOL_WEIGHTED_INTERLEAVE task policy, > mempolicy_slab_node() calls interleave_nodes() or > weighted_interleave_nodes(), which both spin on tsk->mems_allowed_seq > since commit 274519ed414b ("mm/mempolicy: protect task interleave > functions with tsk->mems_allowed_seq"). The same applies to > apply_strict_numa_policy() with slab_strict_numa. > > Consequently, a BPF program that allocates using kmalloc_nolock() within > the write section of that seqcount, for example in > cpuset_change_task_nodemask(), can deadlock. On PREEMPT_RT, waiting for > the seqcount can then even sleep in atomic context. > > Let's fix it by passing whether spinning is allowed to > mempolicy_slab_node(), simply using the local node for interleave > policies if disallowed. > > While not perfect, it shouldn't matter in practice, is in line with > !in_task() handling, and slab interleaving is best-effort either way, > unless slab_strict_numa is set. > Should we just blanket ignore mempolicy when spinning is not allowed? If another mempolicy gets added later we have moles to whack. I think then this just becomes a slub.c-only change where we ignore mempolicy is spinning isn't allowed and always prefer local. That also makes the behavior consistent - no-spin = no policy. -- ~Gregory