Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542036pxb; Mon, 24 Jan 2022 11:49:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwq5OtAtA9BNhDbNxv2+qhCQxAijRTIyDcBYZh6zs055m/L0rel2Ca0o+CVHeoV6S+CmEe6 X-Received: by 2002:a17:90b:3b4c:: with SMTP id ot12mr3401036pjb.62.1643053740540; Mon, 24 Jan 2022 11:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053740; cv=none; d=google.com; s=arc-20160816; b=xP2B78SKnBkCmFbxA8ZpzyPXpmnuvEG02KhCqy5svR2AZQIn8cOJsEjnoHrYz0+HGq gm7GZVrvffqV+AZ8FzSd795MionhCnON34320Li/AwkB8/YzFzbEq9DzLnmnhMxHSkUH IIod7GS5BzRKKAYHTX1PdZ2lRNZovzP+40/8S0qSVji678W9DgYbMD+irqbXX9OT42ZJ ys5dKRFT5mAJRt1ObSmSeWSO6iVxGVeEqUIDHp3pkWckX8LP0VEW89sTCQB+4RfYMP3+ JpnDnsnQ8U2s4aDArkgFIcjbLksA1mMKDzaRc3oU+I4hsNyBMuRTW0h0M+aFpe7/XXGJ 6Yzw== 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=bVjXHubzfURs5BxSD6VmUXrd7L08/2QwTbUc3U13ubk=; b=GM3YtM6aqGu8l05UJ+C5YT4l92OhtwwUj5xPcRxPYjpCcG1ojrWujOlkCSJoIykfsR TTg9LvAnP6sLuY3kes2DlInU+ry9JucYld8Bi3FKst6ASdZIONRksSnxTvRFtMshXKq8 BpOYrgo+dhyKySaKEFllbYf2VAv5tOIBHyD3CKerFMDD3spHelRgGOvIthHwdAR8jLkQ TOjAuFjFloXiQXBGwIIZDlUMk4Vg6sO6py60250tOXLe0piHrm+vhkWbj9mTxa84kiWe ZBOMmft1K7hQiKfcKRU5jbYeNS8ehFiuveRoUbwfZxRBv2joaUsx3qeKUg4fs+lNnIvs R3bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SU6d7Bv0; 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 g63si3604679pfb.179.2022.01.24.11.48.48; Mon, 24 Jan 2022 11:49:00 -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=SU6d7Bv0; 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 S244925AbiAXSDv (ORCPT + 99 others); Mon, 24 Jan 2022 13:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241599AbiAXSDk (ORCPT ); Mon, 24 Jan 2022 13:03:40 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84C88C061401 for ; Mon, 24 Jan 2022 10:03:40 -0800 (PST) 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=1643047412; 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=bVjXHubzfURs5BxSD6VmUXrd7L08/2QwTbUc3U13ubk=; b=SU6d7Bv0jM8rdpvS3ByZodPHSqJwNhhIh1C5GGE+qIK54FHXGgfEEuFAWlWZWbpM56lPIa 3V5ngkYGoZkQ0KGTFSgK9gU2Ny7WVkm0hyeyUb6R2lxPbTfW9ylzwegLBVHl/mBkcS+Exr jlcGSX6VPjRBE0wJIMSKqS/8ph5A0O0= 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 11/39] kasan, page_alloc: combine tag_clear_highpage calls in post_alloc_hook Date: Mon, 24 Jan 2022 19:02:19 +0100 Message-Id: <587e3fc36358b88049320a89cc8dc6deaecb0cda.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 Move tag_clear_highpage() loops out of the kasan_has_integrated_init() clause as a code simplification. 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 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index abed862d889d..b3959327e06c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2419,30 +2419,30 @@ inline void post_alloc_hook(struct page *page, unsigned int order, * KASAN unpoisoning and memory initializion code must be * kept together to avoid discrepancies in behavior. */ + + /* + * If memory tags should be zeroed (which happens only when memory + * should be initialized as well). + */ + if (init_tags) { + int i; + + /* Initialize both memory and tags. */ + for (i = 0; i != 1 << order; ++i) + tag_clear_highpage(page + i); + + /* Note that memory is already initialized by the loop above. */ + init = false; + } if (kasan_has_integrated_init()) { if (gfp_flags & __GFP_SKIP_KASAN_POISON) SetPageSkipKASanPoison(page); - if (init_tags) { - int i; - - for (i = 0; i != 1 << order; ++i) - tag_clear_highpage(page + i); - } else { + if (!init_tags) kasan_unpoison_pages(page, order, init); - } } else { kasan_unpoison_pages(page, order, init); - if (init_tags) { - int i; - - for (i = 0; i < 1 << order; i++) - tag_clear_highpage(page + i); - - init = false; - } - if (init) kernel_init_free_pages(page, 1 << order); } -- 2.25.1