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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A47DAC433F5 for ; Thu, 16 Dec 2021 11:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5HItQda/Pj+0NKWLD4cbgiQN0JmhD1gXB9Eh5VXHjTA=; b=TlSIAK1vDpk6KQ WeYJvqxSnhbnGzUqnaGqFBFcCD5irR6lGkgiprj8fan5lradyAFkzPL0EHg+n993qYgNS8fwPzCUT YUnuswlN98ZyAs3HXcv6feM5CGjH1++FhvhwocqalD0IFtKqgBgzBm0TA2hdVxmh78kXD2/CxvV4U lGwqBs+m3kPE4YBSZCfKRokd50g66/TraNpWouqpdj0Kl2w9oiJX5z+P72CiCl+l751R2RI5or1KD s9TJqEANAZ4nyEUcOHcP7t0M8gz37+Rcc8Ab692XrpDD6wXJ7ek5SEVwXu0sOIc7qBk+wZOFH+euw 5zaJFLYZN800Ie8EdNVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxoUp-0050az-5k; Thu, 16 Dec 2021 11:00:24 +0000 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxoUk-0050Wp-Ix for linux-arm-kernel@lists.infradead.org; Thu, 16 Dec 2021 11:00:20 +0000 Received: by mail-qt1-x82e.google.com with SMTP id q14so24984266qtx.10 for ; Thu, 16 Dec 2021 03:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KnBQJR/TMzh78I8yqUIjs7VdtqfCQRZRo/Chv253Z68=; b=GezK35ONVgcuhJJR9plrCRkI9pOw0Cz7eqzaOyGvWHp2KW/HeY8FI+58hNZJdGmiVi uzKqtD7F7sqrVEgZMi43OW6jV0Fj9RM+U+DKg9M5Peq0VTr4Z/X5SKfUgLOHOm8EW7MD 3aFfiV+PrYPhedbM60AhoGMbEOTGcEInQBdFToAUkh4HTWe+i0Asn6HI7LZEzLxfZdLX k3+n2HGRq8+XcluqX9Zw1i3LIIVb/Z7N2CuybxnhpO4UkyHZAIki8aLBv9hiK5ny9wm0 yOvL40sCuQRP4gPVu/QOgCMHIHx3SAB63AORfTMtqrbTVKGTJQcoGOKBUSgEojKM/nbc Qlzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KnBQJR/TMzh78I8yqUIjs7VdtqfCQRZRo/Chv253Z68=; b=ZL0BeMCzHjOsA83yB8zeObYIfwZZuNbJFcjSMtuPFGnIAb3kUH8gKI5coo+QWbC0be zthUCOSh3zQbUJs75OrmTCMY92bZCsHK41m5DyyUcUpvaDDWLvxURO2o3m82HgGktFuR w8vdxFvFONm3f70PXnVIdn2Qq97z6JwmnZABzJ8+8vaKXM3W41DrugKpvPzxz3t1OnQJ MWDk+DuOpNvM3f+ckKUxygIQQF1G8r/7PzT9vaedJSKpft01BRXkInM1dHop/T9pZfKp wsT5Gcysf+c8+/e5FhPRuS6pjjmWckkR26aXaKjMBof1mP8B37gXdPEgjSaSX1fRfhgX lCNA== X-Gm-Message-State: AOAM5304WU+qexCruygWgGI1vrbIA7R+Ox60NHXNRspyOYhR30Yu4Ugh tYZ+W+2EaOrrI1KCmE5q47VblneA3LuitDywD1azzA== X-Google-Smtp-Source: ABdhPJwfGfQGB0BT1ZzJnkSVVFHCTAY13k5P2iioommCl//Y954NEMtEyBrfWxsiHxd16//ozpaMeZDMNAqUuXtQyJU= X-Received: by 2002:ac8:4e56:: with SMTP id e22mr16609220qtw.72.1639652414512; Thu, 16 Dec 2021 03:00:14 -0800 (PST) MIME-Version: 1.0 References: <984104c118a451fc4afa2eadb7206065f13b7af2.1638308023.git.andreyknvl@google.com> In-Reply-To: From: Alexander Potapenko Date: Thu, 16 Dec 2021 11:59:38 +0100 Message-ID: Subject: Re: [PATCH 08/31] kasan, page_alloc: refactor init checks in post_alloc_hook To: Andrey Konovalov Cc: andrey.konovalov@linux.dev, Marco Elver , Vincenzo Frascino , Catalin Marinas , Peter Collingbourne , Dmitry Vyukov , Andrey Ryabinin , kasan-dev , Andrew Morton , Linux Memory Management List , Will Deacon , Linux ARM , Evgenii Stepanov , LKML , Andrey Konovalov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211216_030018_665622_AB7BEAC0 X-CRM114-Status: GOOD ( 30.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Dec 6, 2021 at 10:09 PM Andrey Konovalov wrote: > > On Thu, Dec 2, 2021 at 5:14 PM Alexander Potapenko wrote: > > > > On Tue, Nov 30, 2021 at 10:41 PM wrote: > > > > > > From: Andrey Konovalov > > > > > > This patch separates code for zeroing memory from the code clearing tags > > > in post_alloc_hook(). > > > > > > This patch is not useful by itself but makes the simplifications in > > > the following patches easier to follow. > > > > > > This patch does no functional changes. > > > > > > Signed-off-by: Andrey Konovalov > > > --- > > > mm/page_alloc.c | 18 ++++++++++-------- > > > 1 file changed, 10 insertions(+), 8 deletions(-) > > > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > > index 2ada09a58e4b..0561cdafce36 100644 > > > --- a/mm/page_alloc.c > > > +++ b/mm/page_alloc.c > > > @@ -2406,19 +2406,21 @@ inline void post_alloc_hook(struct page *page, unsigned int order, > > > kasan_alloc_pages(page, order, gfp_flags); > > > } else { > > > bool init = !want_init_on_free() && want_init_on_alloc(gfp_flags); > > > + bool init_tags = init && (gfp_flags & __GFP_ZEROTAGS); > > > > > > kasan_unpoison_pages(page, order, init); > > > > > > - if (init) { > > > - if (gfp_flags & __GFP_ZEROTAGS) { > > > - int i; > > > + if (init_tags) { > > > + int i; > > > > > > - for (i = 0; i < 1 << order; i++) > > > - tag_clear_highpage(page + i); > > > - } else { > > > - kernel_init_free_pages(page, 1 << order); > > > - } > > > + for (i = 0; i < 1 << order; i++) > > > + tag_clear_highpage(page + i); > > > + > > > + init = false; > > > > I find this a bit twisted and prone to breakages. > > Maybe just check for (init && !init_tags) below? > > I did it this way deliberately. Check out the code after all the changes: > > https://github.com/xairy/linux/blob/up-kasan-vmalloc-tags-v1/mm/page_alloc.c#L2447 > > It's possible to remove resetting the init variable by expanding the > if (init) check listing all conditions under which init is currently > reset, but that would essentially be duplicating the checks. I think > resetting init is more clear. > > Please let me know what you think. Ah, I see, so there are more cases in which you set init = false. Fine then. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel