Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542509pxb; Mon, 24 Jan 2022 11:49:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdQZgBBsrGL7dLEKpQqOdYU4bkLBcFgXAMGGqJ0gybGa2jdkhiC8D+zZ67IcjAj+TLdl8h X-Received: by 2002:a63:2cd2:: with SMTP id s201mr12821649pgs.53.1643053779949; Mon, 24 Jan 2022 11:49:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053779; cv=none; d=google.com; s=arc-20160816; b=IjATlC+TVUjID5DQl9XVZkGMxHBO7acxrsSl1itq8du9/seT668o8TtArWS9b3B7Eu UwEVInoLLD7pvRuPl2++duWF+qv1KJPJWA7Mmu4TjsSHnYsgTV81IPtfxMgmtOJFeTcN rf4/zYAq2TDrGHckAr48qY4ZvFWvveY1PWEjDf0urhuXz5x6jD4mKNX4t9TmaXRjlAaX F04Piy51HuzGqEVIkiwWLL7T0GEXEcCtTZMj56ycbCT+YfbzUtD4tvVO5gcHxs+QXhds ljnvZsiW303x8xuiFGCB4dt+VBlEXmM/FLQf8T9ToVmQ/g4v5fOhbI5s9tN5ZTZ+sF7W pemg== 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=yIiooJ7Br0briWEQqZ6uPYrewTQt0yFaU3FLKd4NjuQ=; b=qRxTEhYoVRlLzptx6QPG3uFfHfW63LYbr8q1yNo9zjzW/L9pGWqh5TSdKwIKhe9GMR ny8+4uh97yMPbFAWSBGrRThCeJBSlj1/+Nl/Pt2mk+0gQKV+2hhAIqA8vLwoMrMX5ScE cXz9WTZmJmkpyyKoGhU7x+joO3FSQ+O6U5qIqO+6GJG0nW/GTdBpkg3ix+CTMX0rM+Pu F9oas5gauQ33cfsipLzd3BbR8BR1ckiirFYPUo2fn7O0Bdp7ZuY9dISeYf7UUj2un8qq fFqBIKS0oPzEZ34KZfjwJgBzss0n3wMkRbJJrKAtlL7Fx13WfSLcAUGDzjiz8A7Ho77J dmQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eV2kpwR8; 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 g4si13312811plt.223.2022.01.24.11.49.26; Mon, 24 Jan 2022 11:49:39 -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=eV2kpwR8; 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 S244904AbiAXSEH (ORCPT + 99 others); Mon, 24 Jan 2022 13:04:07 -0500 Received: from out2.migadu.com ([188.165.223.204]:13103 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235769AbiAXSEF (ORCPT ); Mon, 24 Jan 2022 13:04:05 -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=1643047444; 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=yIiooJ7Br0briWEQqZ6uPYrewTQt0yFaU3FLKd4NjuQ=; b=eV2kpwR8xJFcM9Sl9WgGTW1GyXnj5qihypWFh4otrwjMzPW6EgMyoLvbRozNqNB3B591up y6lIiFHxnDXiOOaMJmL1wPHK4IrO3UXm0c5KMD2FNNNVtYlOxCIaZDtllz6bDRB1eeO8nD l/OGODSVkzQZX5g+F1Cv9ilY4I4R5eo= 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 13/39] kasan, page_alloc: move kernel_init_free_pages in post_alloc_hook Date: Mon, 24 Jan 2022 19:02:21 +0100 Message-Id: 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 Pull the kernel_init_free_pages() call in post_alloc_hook() out of the big if clause for better code readability. This also allows for more simplifications in the following patch. This patch does no functional changes. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- mm/page_alloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c51d637cdab3..2784bd478942 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2435,14 +2435,18 @@ inline void post_alloc_hook(struct page *page, unsigned int order, init = false; } if (kasan_has_integrated_init()) { - if (!init_tags) + if (!init_tags) { kasan_unpoison_pages(page, order, init); + + /* Note that memory is already initialized by KASAN. */ + init = false; + } } else { kasan_unpoison_pages(page, order, init); - - if (init) - kernel_init_free_pages(page, 1 << order); } + /* If memory is still not initialized, do it now. */ + if (init) + kernel_init_free_pages(page, 1 << order); /* Propagate __GFP_SKIP_KASAN_POISON to page flags. */ if (kasan_hw_tags_enabled() && (gfp_flags & __GFP_SKIP_KASAN_POISON)) SetPageSkipKASanPoison(page); -- 2.25.1