Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542050pxb; Mon, 24 Jan 2022 11:49:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzax3Xe+025tprG7GB1L7dwQDLYD/H6FLIy8GuNbGPywBiYqpJEwksucDzsF2XJLWqKdkPm X-Received: by 2002:a17:902:ecc6:b0:14a:fba3:168d with SMTP id a6-20020a170902ecc600b0014afba3168dmr16163153plh.8.1643053741745; Mon, 24 Jan 2022 11:49:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053741; cv=none; d=google.com; s=arc-20160816; b=jpMNq/gyrfmAKLakk/w+Hdt69FTaTD60xgjciBB4k3zTblJ1R8LbgOP55FZGyI5vBF y3gHgJ7wL3hmJdZBRObseQrt2w1SPmmRyP8qy2qXel51rbcAh6F7SPwagEgPSJy4PpiU +tMWndb8bA2REQGl1p7oxHh+E5o4DuHseqa9FrFyQlsLtuvu78QapCp9rHcviikDVp9N CxYa5rwGrHxuz9d/6zbJ/oO1ZBaB1l0ePveAzH1x8cQzgkQtLYb4ALsT3L0EaB50Cdx/ c8DBKy7hCihwmOaw0Ytqjiy5yslRUuOv8gJIzYAsuQKlyKPKHfXsCmRdTqvQ5Kja1Zit RTcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ahnJF7fiV1PQKb8mnNBqV+WM+Otng1D4UaEsnbQTJqk=; b=KsV8+yTPpmFDT8DcF7JtofPaBL+GGJ4VkLtE3J0oFIEWCyCK6pFZ52z9DzUZpp1zOU o5weQNrVfNJPPxhJ5M3fyIQlgAZ6PchHWS+N4LUJOqou14PoqAr1X8RS5xLdO6tUc3Ql hbbt22qaawuwZvYjUO9uj/fTQ5pFf7g7Dfl7+WQ2QjIv5gtfQGeotYnpshjo4QxNTrie SPpNe0SpmfW2vDKfOFD2j6Bxa9j6I3x5rW5IdgKlO31iXQwJbz7fHmjn7KzbL96uMUdv GIa9l5xWj7bp3X+ixHbDywqGwpd3NOaPXUI0QJgOvkMCi7/8fgxK+OCuaFqeiy8vZ1tA gQtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=lqAs+zT4; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f23si10418717pfn.377.2022.01.24.11.48.49; Mon, 24 Jan 2022 11:49:01 -0800 (PST) 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=@linux.dev header.s=key1 header.b=lqAs+zT4; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244884AbiAXSDs (ORCPT + 99 others); Mon, 24 Jan 2022 13:03:48 -0500 Received: from out2.migadu.com ([188.165.223.204]:12794 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244847AbiAXSDc (ORCPT ); Mon, 24 Jan 2022 13:03:32 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1643047411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ahnJF7fiV1PQKb8mnNBqV+WM+Otng1D4UaEsnbQTJqk=; b=lqAs+zT4XMRomU8iZ8PbeDFJxGbPnuJNsrmN0ZaIKQRvuGypW8fdb9CucYgJ31hDACR6Ta BezECebuq+k2O73QYA+PQGGi2UmZI+mQzAsGF4+/Ciqsr0oLCCm8ufDo2GrDwL4tzRjzNI +8XZ3bmTE2+/B11BFjIa3GXBqB5SRok= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Catalin Marinas , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v6 09/39] kasan, page_alloc: refactor init checks in post_alloc_hook Date: Mon, 24 Jan 2022 19:02:17 +0100 Message-Id: <2283fde963adfd8a2b29a92066f106cc16661a3c.1643047180.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov Separate 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 Reviewed-by: Alexander Potapenko --- Changes v2->v3: - Update patch description. --- 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 8481420d2502..868480d463c7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2420,19 +2420,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; } + + if (init) + kernel_init_free_pages(page, 1 << order); } set_page_owner(page, order, gfp_flags); -- 2.25.1