From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_RED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C290C07E96 for ; Tue, 13 Jul 2021 16:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A7E4610C7 for ; Tue, 13 Jul 2021 16:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbhGMQWE (ORCPT ); Tue, 13 Jul 2021 12:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbhGMQWD (ORCPT ); Tue, 13 Jul 2021 12:22:03 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F079C0613DD for ; Tue, 13 Jul 2021 09:19:13 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id m18so1848906oie.9 for ; Tue, 13 Jul 2021 09:19:13 -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=huy3A4ZQsPTRZT7tGhT5kIwuh7my/p/nRbdB9PmgvzM=; b=W1uGwlOEfvG+vtbgUVE8EKwQtXKNJzS98MbwXZbFrPG/G2iZ0gFWmM0UOk7T3Jb8ZN DZ4QMNoTmsOtt/lSKdJCwG2SF10O1R/jw4fLknzhlJVMUj+Y0qOeiwmGv+3yBIE2Rf+d hHzVt4oDElWdFCf+WMiAXyCat6mDvZle/4q0QUKElOt3C+fJ85vEwbqQdCBEQPjoe+eF 9kIcbTW6ww33ZLYHKwNF5EcevIK68CVW6AC1IoiJE7Qls0LBNV6TRPGbXEGCkbD6VKZo /9bChu8a56PgQ1TH/U+9nCbVtF0Ww3drfo+aQ/Wvux+y2WG8NrMj9a69kinEEX5JOm9n QuFw== 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=huy3A4ZQsPTRZT7tGhT5kIwuh7my/p/nRbdB9PmgvzM=; b=uO3R5fJlwJz6QrUhRvlJJVuZ+o1WknLFFFPY0jAnTutQOt1ETdxjtGbKrBG16+bA/m TYlMQVafvQyEpaLQK5nc0hs03AqHmysTGcPXXSxisNnuXCIL9R1/6Anxg5DLRvCy9J4G DPF2YIEyGuwXifhVzpH6stzyCHvvzv+syYwxoLKfRuvNJfmm6AeNI+jdAHvKp3FWNuoO zyBl0Y8fyvC+8Tdd71II3WBWr+v7bqnDODk3KgH63Y0qfRMfAckRbNIOGGD5P6Pw1dcL wht6oIxQxWsAEtieJJWT32O1yzVJtbLyYf/ahwb5aYaMa3c+0QeZTydPfEyvZj1BkHKM OkTw== X-Gm-Message-State: AOAM531nx3iJr+37+Ifwkfh+fhq3v2TthdO6Zwb2R0DbemHBBPMCwK79 ZfUxSxKCTe6OmwOe1XzfBMxsK3rmi3DUvAOFTCy1GQ== X-Google-Smtp-Source: ABdhPJytAg3oPcgS+rfsoNfJ9pnVekMsJ3OtPlYEx+2kTpu5b2aTtBF4uluKr0tmXbqltD7U54Jjj8lVJu7wecnRsLs= X-Received: by 2002:a05:6808:284:: with SMTP id z4mr3800835oic.70.1626193152621; Tue, 13 Jul 2021 09:19:12 -0700 (PDT) MIME-Version: 1.0 References: <20210630150234.1109496-1-glider@google.com> <20210630150234.1109496-2-glider@google.com> In-Reply-To: From: Marco Elver Date: Tue, 13 Jul 2021 18:19:01 +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 On Mon, 5 Jul 2021 at 16:05, Marco Elver wrote: > Andrew, > > This series is ready to be picked up. > > If possible, kindly consider including it in an upcoming batch of > mainline fixes. > > Thank you! It'd be good to get this sorted -- please take another look. Many thanks, -- Marco > 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 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_RED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93697C11F66 for ; Tue, 13 Jul 2021 16:19:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 372F061175 for ; Tue, 13 Jul 2021 16:19:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 372F061175 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2CE4F8D0002; Tue, 13 Jul 2021 12:19:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27E858D0001; Tue, 13 Jul 2021 12:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11FAA8D0002; Tue, 13 Jul 2021 12:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id D94868D0001 for ; Tue, 13 Jul 2021 12:19:14 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CAE2B802F990 for ; Tue, 13 Jul 2021 16:19:13 +0000 (UTC) X-FDA: 78358074186.39.002DF3A Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by imf17.hostedemail.com (Postfix) with ESMTP id 92A9FF0003AE for ; Tue, 13 Jul 2021 16:19:13 +0000 (UTC) Received: by mail-oi1-f176.google.com with SMTP id w194so5849243oie.5 for ; Tue, 13 Jul 2021 09:19:13 -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=huy3A4ZQsPTRZT7tGhT5kIwuh7my/p/nRbdB9PmgvzM=; b=W1uGwlOEfvG+vtbgUVE8EKwQtXKNJzS98MbwXZbFrPG/G2iZ0gFWmM0UOk7T3Jb8ZN DZ4QMNoTmsOtt/lSKdJCwG2SF10O1R/jw4fLknzhlJVMUj+Y0qOeiwmGv+3yBIE2Rf+d hHzVt4oDElWdFCf+WMiAXyCat6mDvZle/4q0QUKElOt3C+fJ85vEwbqQdCBEQPjoe+eF 9kIcbTW6ww33ZLYHKwNF5EcevIK68CVW6AC1IoiJE7Qls0LBNV6TRPGbXEGCkbD6VKZo /9bChu8a56PgQ1TH/U+9nCbVtF0Ww3drfo+aQ/Wvux+y2WG8NrMj9a69kinEEX5JOm9n QuFw== 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=huy3A4ZQsPTRZT7tGhT5kIwuh7my/p/nRbdB9PmgvzM=; b=aoYAeBDaPdbXEM8DqqLs+HBQ0DySYG3AUbVdeAB7I7d6STaXHia8Nf4HTnIPuSMUyC rYPonTlZQgqTi2uABve2nAQpNBbDP6sFG8E/dNImHsgHJGqkRSziQY1CK2y0gI21j5fI yku3nSVWm2LU+EMNWdAC6wx02gQ32pd5xTtr3npOHXXEy3AL/jBPHSRBWfph89SLjc+l yWwRpFEdj/AxI8xJ/E0uNQ6YM1KAo5gi3+IKLjJ2ffJWq5zIKgu/24BPgDRLvqEAQ1Oy 6io4chvJ/+NxjzwfuPnlZcy7GxCwzfu9YHQFGFCZGKC8FqaySD1l3Wj1lNlWYMucwXgK Harw== X-Gm-Message-State: AOAM532ntZWPU8vmSuI0Pu4XcRzguL7DXVCT3bkETu27N/e6lYyh7MU3 xpaU9FxFgtpgS768NSi7qFncQZbLpRSog2QdQWoqiw== X-Google-Smtp-Source: ABdhPJytAg3oPcgS+rfsoNfJ9pnVekMsJ3OtPlYEx+2kTpu5b2aTtBF4uluKr0tmXbqltD7U54Jjj8lVJu7wecnRsLs= X-Received: by 2002:a05:6808:284:: with SMTP id z4mr3800835oic.70.1626193152621; Tue, 13 Jul 2021 09:19:12 -0700 (PDT) MIME-Version: 1.0 References: <20210630150234.1109496-1-glider@google.com> <20210630150234.1109496-2-glider@google.com> In-Reply-To: From: Marco Elver Date: Tue, 13 Jul 2021 18:19:01 +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" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 92A9FF0003AE X-Stat-Signature: 6f57zc3tt7c9ntpt6kcaabr5htdb1aoh Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=W1uGwlOE; spf=pass (imf17.hostedemail.com: domain of elver@google.com designates 209.85.167.176 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1626193153-242964 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, 5 Jul 2021 at 16:05, Marco Elver wrote: > Andrew, > > This series is ready to be picked up. > > If possible, kindly consider including it in an upcoming batch of > mainline fixes. > > Thank you! It'd be good to get this sorted -- please take another look. Many thanks, -- Marco > 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 > >