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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3953FEE7FF4 for ; Mon, 11 Sep 2023 12:12:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F1D06B0285; Mon, 11 Sep 2023 08:12:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A1E66B0286; Mon, 11 Sep 2023 08:12:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8913F6B0287; Mon, 11 Sep 2023 08:12:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7C8596B0285 for ; Mon, 11 Sep 2023 08:12:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 53FFCA0268 for ; Mon, 11 Sep 2023 12:12:31 +0000 (UTC) X-FDA: 81224204502.02.1AE230F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf30.hostedemail.com (Postfix) with ESMTP id 6665480023 for ; Mon, 11 Sep 2023 12:12:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=AFfYbBiB; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694434348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tf7tRdXV7UNidkw8jKJWLwlUfOkHdMG5nA5zEy+A7gU=; b=ebrQdba0Alw2NWcVd4gTSwtbJ+7uSftA5YJFO3Xa04Ms6oPBjwYeyDsbwYLWrLX8qhhant Ya9Wy6xJrBDZLO6k5xFsMzpFMvhiUpOCI6BmphpCAvcLlTexV2OP0ZFU8Ss9MyBjNFKQ+4 BX+QUcyMasbxsK5+oyOcuj9f318cNDM= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=AFfYbBiB; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694434348; a=rsa-sha256; cv=none; b=MscjvGZfCCIQOHj1STT3VgxQF/At6JO7bHeWaGOIl9gEaqab9Ptz9I1UZbld7If3tq4Yhh 87AO/5UgGSmvMPSzSC1qtIhy1xhgEYzSuSW4QQZdC8uy1LVDFaTxHQTpii5uUG8Sy/jDq+ rKobNaZHXIPzTQvQryLxhmT1dz7Zbco= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3DE74211C3; Mon, 11 Sep 2023 12:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1694434346; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Tf7tRdXV7UNidkw8jKJWLwlUfOkHdMG5nA5zEy+A7gU=; b=AFfYbBiBycdQ/2GmktSMV/Pjt55ov/8QmZZf97c1lCCggS/qdwO6Y7QmVSqA0cAWWBt5zg orVTV43YzbN/432DUSHe671rHSPe8G1zxlndiS1Dd9QhitBEujAnQpCEHk5RdvtIVWShKA RLuidco961+1lUqdwpq33w9qVPmQ6fk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 199B9139CC; Mon, 11 Sep 2023 12:12:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cjAoAyoE/2SCAgAAMHmgww (envelope-from ); Mon, 11 Sep 2023 12:12:26 +0000 Date: Mon, 11 Sep 2023 14:12:25 +0200 From: Michal Hocko To: "zhaoyang.huang" Cc: Andrew Morton , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , ke.wang@unisoc.com Subject: Re: [PATCH] mm: remove redundant clear page when CONFIG_INIT_ON_ALLOC_DEFAULT_ON configured Message-ID: References: <20230911104906.2058503-1-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230911104906.2058503-1-zhaoyang.huang@unisoc.com> X-Rspamd-Queue-Id: 6665480023 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ask657cmwskmawa4mjpqepzdskjt9iqs X-HE-Tag: 1694434348-402081 X-HE-Meta: U2FsdGVkX1/J/yD1jhLP8JykTmgSVt/LzFFV4IPYscb/ikIjgMmc1EusrMzfYdVcm3DZmJMru2ZXJSEBkU/vRO9kYXSvq255lBmU1nvG7BugGfEI5oEhG205l3xqEsT3GQIRzvv5+BZ3ArbIn2k4QKwJy0NBrNVENi7SKzBsU6uuagsvDWJ8IdojyFLwJeg1rcSY+t6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idW//o7SHV64RMVzjjVzxkEd3/lNBA0UBNUc1r+ 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 11-09-23 18:49:06, zhaoyang.huang wrote: > From: Zhaoyang Huang > > There will be redundant clear page within vma_alloc_zeroed_movable_folio > when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on. Remove it by judging related > configs. Thanks for spotting this. I suspect this is a fix based on a code review rather than a real performance issue, right? It is always good to mention that. From a very quick look it seems that many architectures just definte vma_alloc_zeroed_movable_folio to use __GFP_ZERO so they are not affected by this. This means that only a subset of architectures are really affected. This is an important information as well. Finally I think it would be more appropriate to mention that the double initialization is done when init_on_alloc is enabled rather than referring to the above config option which only controls whether the functionality is enabled by default. I would rephrase as follows: Many architectures (alpha, arm64, ia64, m68k s390, x86) define their own vma_alloc_zeroed_movable_folio implementations which use __GFP_ZERO for the page allocation. Those which rely on the default implementation, however, would currently go through the initialization twice (oce in the page allocator and second in vma_alloc_zeroed_movable_folio) if init_on_alloc is enabled though. Fix this by checking want_init_on_alloc before calling clear_user_highpage. > Signed-off-by: Zhaoyang Huang With the changelog updates Acked-by: Michal Hocko Thanks! > --- > include/linux/highmem.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/highmem.h b/include/linux/highmem.h > index 99c474de800d..3926f8414729 100644 > --- a/include/linux/highmem.h > +++ b/include/linux/highmem.h > @@ -227,7 +227,7 @@ struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma, > struct folio *folio; > > folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, false); > - if (folio) > + if (folio && !want_init_on_alloc(GFP_HIGHUSER_MOVABLE)) > clear_user_highpage(&folio->page, vaddr); > > return folio; > -- > 2.25.1 -- Michal Hocko SUSE Labs