From nobody Tue Feb 10 20:46:55 2026 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.74]) (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 011BC1B3948 for ; Fri, 24 Jan 2025 12:02:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737720133; cv=none; b=ZiXV+7pCHTJOCwhgrojJQ/ILJL3YT87XuiU/a1cz+1EqqZgd2k993o84hKvIv+B39kqydXMycr2xdaHA13f4khm47p2Q5ntVmGX5OE+iFjqVTkD8jvc8M9X2aPGMsWHNpcYvrVWCVEjgoawN0Iojm8h6dCeKLiJCDEE8DfFiZJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737720133; c=relaxed/simple; bh=QeW4yNmyhKcSxco3mWl6d6Jx7WGwmWAuIZ+mWtqLXI8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jMFMJYE8dmX+o3P7yr55VAIt7twL6KYLATKi3ABA+0krntjyhtcVQGw/pRPTCucm0QxjaxAX+H6qXHjosImXwFnpcF6RYSodkT5qMZsl96J0rfRuVoDeXYnxMS/w4CozEBvw8SdDqs4PAutpK7MkjqYpWAQBrXmXDiHjRffgl2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K35g97N9; arc=none smtp.client-ip=209.85.208.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K35g97N9" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-5d3bf8874dbso2526712a12.2 for ; Fri, 24 Jan 2025 04:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737720130; x=1738324930; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=zD6StW0rYzOmQ2GqSmARPsItuuT3+0nfZNTObiJebWo=; b=K35g97N9fDgaKGlY6y8T1io8ZGarJ0lA1LC6KCLLE7KxZVi8XA+7ehfx1ov8bkdJYC C4wkm2gJdUcWfQhuNMjTXg9pbxQpMfdHtpRrAmKwBuG0RVykdCVvlhHEInnVKtL2siEf WdLRamqxZnbW2BLZE7LQjPWzAQ1jTj6Z77ox93cBeX2e7wqGf41zUA0qVrKBB9/GoutS jqC9+OuO5wn3LxaITKMaDrLidd1r5LY5D7Ho67Urnizm+3goh+4fj6VzXwXK3zUzXx1P 4LlYMXWPtfPfxk/P26cZGlchsjueWVZBcXn287oLPv7QfUQ3BlizoOLV6jwhRtVQQwZn mrWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737720130; x=1738324930; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zD6StW0rYzOmQ2GqSmARPsItuuT3+0nfZNTObiJebWo=; b=nUfiMKLUQJGpPSZulYKA/S1msOPpIFdHI8PqBVAkwJAoFFzAHPwXqQewCJU6DU77fn Ct2wIZl6dnyIr3vP79eSrC08rN2VxB0q0I3Vz31pRZESNBWxF8eJD57Ix4v/mAvGOpxT Kvb4pSiznpcMOx3bDoJi4tyNVF5/QP/7PVGPiRz7BzCObVh1iFk7faSR6OYunjPyNPN8 PXrt1GFqMvJKsKzAAMo+k6/koz1iBagb5Jxpq5f2DdOpcSmQzz0oV7RKQQv3gZ7mb/Lw 3qPvZ0ENeUO2l0tiuee/ea1RIiWRlWlvbBYDXRHl7upPMxx3rJ6LeDfXEK8SQmC+aoWy 2ulg== X-Forwarded-Encrypted: i=1; AJvYcCV4Z6B45EUpsOsQ3YWIzL1u1y4mLxQ0fvs//q/pxuunytmbHlMQsSPnC/JwG0Vp9q4xG29lD+t6ZJYKpjA=@vger.kernel.org X-Gm-Message-State: AOJu0YxqygqlwmTXgEFt8haNqqvIXQASyiHCCgKFW2Z2iH7spQj3twu+ I28xN0IAxWNdGydPeSttVpB1UZsIsn6l6mmUEinonxn40oD1XDpRW0bLuQIKJHPLrvi+G4qsjQ= = X-Google-Smtp-Source: AGHT+IGNFpOULcDrHD56b/yh05c68gjc+fDIs2J39MXi/+4aqEjglZpsvwZBUEMUnzpUaNwRYkyqzdJI9Q== X-Received: from edbel15.prod.google.com ([2002:a05:6402:360f:b0:5db:e8e8:da25]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:2803:b0:5d2:723c:a568 with SMTP id 4fb4d7f45d1cf-5db7d2f105fmr25991316a12.10.1737720130343; Fri, 24 Jan 2025 04:02:10 -0800 (PST) Date: Fri, 24 Jan 2025 13:01:38 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250124120145.410066-1-elver@google.com> Subject: [PATCH] kfence: skip __GFP_THISNODE allocations on NUMA systems From: Marco Elver To: elver@google.com, Andrew Morton Cc: Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vlastimil Babka , Christoph Lameter Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On NUMA systems, __GFP_THISNODE indicates that an allocation _must_ be on a particular node, and failure to allocate on the desired node will result in a failed allocation. Skip __GFP_THISNODE allocations if we are running on a NUMA system, since KFENCE can't guarantee which node its pool pages are allocated on. Reported-by: Vlastimil Babka Cc: Christoph Lameter Fixes: 236e9f153852 ("kfence: skip all GFP_ZONEMASK allocations") Signed-off-by: Marco Elver Acked-by: Vlastimil Babka --- mm/kfence/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 67fc321db79b..102048821c22 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1084,6 +1085,7 @@ void *__kfence_alloc(struct kmem_cache *s, size_t siz= e, gfp_t flags) * properties (e.g. reside in DMAable memory). */ if ((flags & GFP_ZONEMASK) || + ((flags & __GFP_THISNODE) && num_online_nodes() > 1) || (s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) { atomic_long_inc(&counters[KFENCE_COUNTER_SKIP_INCOMPAT]); return NULL; --=20 2.48.1.262.g85cc9f2d1e-goog