Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3843480pxv; Mon, 5 Jul 2021 07:06:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtsVfXKciPc+oQRqTfEgvxcaPUYcW8G/1ubr+E5UA0AWX3qOXRp+OJ6FRCtM5tarDDN93r X-Received: by 2002:a92:d10c:: with SMTP id a12mr4496681ilb.100.1625494009582; Mon, 05 Jul 2021 07:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625494009; cv=none; d=google.com; s=arc-20160816; b=nkq+dkt2JvZ7E/Ct7qX5brJ/pI+LCpJgZBywxHOxFGxGsOTK7HYWqMHUj4d34vPCqV yHANLQiOQnxbSnY9Qts/kMqqIRndeD7qqMqjtW0X907Lprd4RlHJdPjgM9m77XFuoAlB M8fZwHQ//y+JGJqtQBegxFVQjmb1fBalKj29ZHdcyC8TiqYTq9jyexersVULQ/VlZT8f /CkyFAxZWN2//HN5NR8JKB1jqcDiJIPAhz8i0Gb6tht9WbmU6AOI3rvFAtJ6k7XOcI3/ HVmK51gUmb4IjuYtrZOArIvwoOJ5HqXki4JDJ2TzaUJvrjYTnpjKZF3eCf5f0CompuQ4 qfUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ORehuuFLRHngj4BfeJzGKp4s1pOaJxbH1Vm9Xu/XC1M=; b=XUcfR/44wUq1F1h3FsdKdjn1xaq9FUFugQvY3wVV1Rx60ilpr2jAjTQsdWoFtcvi4W p9qWv5WG/4qnpYurH2Dv/n3Qr6Erte5jlNHmgw1kb7puiGGIFOoz1DnIHLAujLYMqI68 R/02DzbpqF3jLQYoEbNRVht17rrrLQnoEQF0fKUzQfBV6vkHcUM/e6iDAMTbq6NuDv+s VldEA9HzH1i8sXFKYnLNW77hEu9q0Xp62uhgz6FRwqGCdmtsKWhm9026n51CuxSwuoLb nXuQx00mtRC7wGnP2yPC1mAqUq7WblFOsHI/JOgoEtDApvmp8d0Z+yCkvzpY3YkuLx/d 4ilA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Su+vopsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si7986442ili.126.2021.07.05.07.06.38; Mon, 05 Jul 2021 07:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Su+vopsm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbhGEOIm (ORCPT + 99 others); Mon, 5 Jul 2021 10:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbhGEOIm (ORCPT ); Mon, 5 Jul 2021 10:08:42 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3056EC06175F for ; Mon, 5 Jul 2021 07:06:04 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id p21so10941653lfj.13 for ; Mon, 05 Jul 2021 07:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ORehuuFLRHngj4BfeJzGKp4s1pOaJxbH1Vm9Xu/XC1M=; b=Su+vopsmQhtsd2F1gNDaJSmu0WVcyTt0V1ibrc+uIbCRi+M/8PgO/A8D33Mz9mH7T0 WQhn3iPeWexedTFUx+5vPk36vhAmp5v3wDJF/J3S/dc3CHjxh44cDT5PMhkWGoctey6V sJ0Z1qkOWM/b8ZNMowf/6Q/+q7xSEquYKtkOWoMAx22KY7uSValdpJz0S0D8EKYhTest k3VFZw8ZC+mxdmoa233hZg7Js72bSQ1+GbV/TWv17ILcGlY21TFoWJKsyI3Kn2j2Vzeo wQTmxIRqLsEjlKksrZpUEvKGSDumv4qWN7+nzlU2cNrmQMKiNgWCkecWcYnjzrw9DUUd rrIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ORehuuFLRHngj4BfeJzGKp4s1pOaJxbH1Vm9Xu/XC1M=; b=tWLZUf3J/toWfRyXR1moZ8HYu4jKsqsrePjCq7zpq1wzLlCZ8jzyW3YuCIv6NxCwY9 cTnBJPjglLZp2Ji9IQpiREk+tfNOWfwQPbQYmvHS1YSa+xs+jJ08kdkj9y1uEyAByWuJ UoTax1HASWvhsCbPZtKiu/pEY7VSvMBclt47JyZCw7jNsZ2y5dnQ4E8pnTEB6d28A0eN LYZVeSqmjqNLHckC642cEX9WkPtw+95x2qAybNa5x5KnIB8LqYXKGM7EE3rBvV9LYNgJ duxVOimTM6FgaGAF/HZNAaTDuaGTrBSzcATdzgUDK3qmyyf/2I203lXOWTThqXvhepNl oRPw== X-Gm-Message-State: AOAM532vOwte6ogM6YTipW6PkDFXTj/TnCOqkBmd0oUh/E3fjajfmJE4 teZg7FH/LcSYen3p51ZcwpUuRFaxn2ojbYxCv2Pc+A== X-Received: by 2002:a19:6803:: with SMTP id d3mr10752593lfc.235.1625493962095; Mon, 05 Jul 2021 07:06:02 -0700 (PDT) MIME-Version: 1.0 References: <20210630150234.1109496-1-glider@google.com> <20210630150234.1109496-2-glider@google.com> In-Reply-To: <20210630150234.1109496-2-glider@google.com> From: Marco Elver Date: Mon, 5 Jul 2021 16:05:50 +0200 Message-ID: Subject: Re: [PATCH v4 2/2] kfence: skip all GFP_ZONEMASK allocations To: akpm@linux-foundation.org Cc: dvyukov@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, gregkh@linuxfoundation.org, jrdr.linux@gmail.com, Alexander Potapenko Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrew, This series is ready to be picked up. If possible, kindly consider including it in an upcoming batch of mainline fixes. Thank you! On Wed, 30 Jun 2021 at 17:02, Alexander Potapenko wrote: > Allocation requests outside ZONE_NORMAL (MOVABLE, HIGHMEM or DMA) cannot > be fulfilled by KFENCE, because KFENCE memory pool is located in a > zone different from the requested one. > > Because callers of kmem_cache_alloc() may actually rely on the > allocation to reside in the requested zone (e.g. memory allocations done > with __GFP_DMA must be DMAable), skip all allocations done with > GFP_ZONEMASK and/or respective SLAB flags (SLAB_CACHE_DMA and > SLAB_CACHE_DMA32). > > Fixes: 0ce20dd84089 ("mm: add Kernel Electric-Fence infrastructure") > Cc: Andrew Morton > Cc: Dmitry Vyukov > Cc: Marco Elver > Cc: Greg Kroah-Hartman > Cc: Souptick Joarder > Cc: stable@vger.kernel.org # 5.12+ > Signed-off-by: Alexander Potapenko > Reviewed-by: Marco Elver > > --- > > v2: > - added parentheses around the GFP clause, as requested by Marco > v3: > - ignore GFP_ZONEMASK, which also covers __GFP_HIGHMEM and __GFP_MOVABLE > - move the flag check at the beginning of the function, as requested by > Souptick Joarder > v4: > - minor fixes to description and comment formatting > --- > mm/kfence/core.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index 33bb20d91bf6a..1cbdb62e6d0fb 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -740,6 +740,15 @@ void *__kfence_alloc(struct kmem_cache *s, size_t size, gfp_t flags) > if (size > PAGE_SIZE) > return NULL; > > + /* > + * Skip allocations from non-default zones, including DMA. We cannot > + * guarantee that pages in the KFENCE pool will have the requested > + * properties (e.g. reside in DMAable memory). > + */ > + if ((flags & GFP_ZONEMASK) || > + (s->flags & (SLAB_CACHE_DMA | SLAB_CACHE_DMA32))) > + return NULL; > + > /* > * allocation_gate only needs to become non-zero, so it doesn't make > * sense to continue writing to it and pay the associated contention > -- > 2.32.0.93.g670b81a890-goog >