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 65C15EE7FF4 for ; Mon, 11 Sep 2023 13:03:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF93E6B028D; Mon, 11 Sep 2023 09:03:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA9536B028E; Mon, 11 Sep 2023 09:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B713A6B028F; Mon, 11 Sep 2023 09:03:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A82266B028D for ; Mon, 11 Sep 2023 09:03:18 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7546BA0A62 for ; Mon, 11 Sep 2023 13:03:18 +0000 (UTC) X-FDA: 81224332476.10.7F26248 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf04.hostedemail.com (Postfix) with ESMTP id CAB8740037 for ; Mon, 11 Sep 2023 13:03:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=DiGitxDw; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf04.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 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=1694437395; 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=+lkCsOrmvgMZKwdhoCy1NavBv3f9A5WVMY+v90BVt4s=; b=7qSBTNaKDzubD2yVZ7OGyiX3aedktqW+rR3mlFDPdq+BN3sCJgbPwZbS8/Kd6+wx9C6J3B C12EorOkooOIUB3GbxtQeSUnKpB90O6TI87HaQHJRPOvEI78n5zi5yKtuIpO4RfQJEVGML JRiu79KMefvhhfSRkiS7RXY9RtBmYMI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=DiGitxDw; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf04.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694437395; a=rsa-sha256; cv=none; b=YfyrA0cTehqh8tedf+br9kuTi+CHwkRciTyEiF8pvVfCM3Qn1SVo4uCCJQfycXE38Xe5Su LSud18GX+NLx03mFn97QlsDiVzFORIAxsdLauBGS6GcsCOHD+0Nk2siwwL+QkTMsIPVuXb L4NfIeEeWZ7MVL1A6kclqZNjphYwaF0= 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-out2.suse.de (Postfix) with ESMTPS id 11AB11F891; Mon, 11 Sep 2023 13:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1694437393; 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=+lkCsOrmvgMZKwdhoCy1NavBv3f9A5WVMY+v90BVt4s=; b=DiGitxDw/pQ+mU4nN1HJ2KIq6mOYkeHtb2wMCjQm3rgm+YXJGw7ySwLfsfMTpuI9fH7h2a LX4b6JRDxzY4hKG1Ev/xLnveCPt5//NYkvcZONnMD7AlQzj0zN2CXW26vs5ynKEqxij24+ QwIraQZ/hydiUVZi3Yc9ShRs3vM01O8= 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 E67F813780; Mon, 11 Sep 2023 13:03:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id V/VJNRAQ/2RnHwAAMHmgww (envelope-from ); Mon, 11 Sep 2023 13:03:12 +0000 Date: Mon, 11 Sep 2023 15:03:12 +0200 From: Michal Hocko To: Matthew Wilcox Cc: "zhaoyang.huang" , Andrew Morton , 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: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: CAB8740037 X-Stat-Signature: 7msc4a4eonc4rs5dhczp166ii4od133n X-Rspam-User: X-HE-Tag: 1694437394-518572 X-HE-Meta: U2FsdGVkX1+8Wqq2nj8zwU3lM1tGpOePcKjjVSdMDDZidhlN0OXz7cSG0b2JhVS7iJ8X/QUIqlAYSYl9OdpaFngNw3x8KVMGg6+4hYzAIVTi7uvlUf2MBYXxIKiDEiinBZsqa7n6wpLEJX6OVAKZRjdNRBZ8myRLvvbdHUpVdLf12kTLOldCtt8dXe+flrxPEP+eakC14WQy1dVpxeHKUTn2a/m0ZzGjO15rfQBGwdzW1RhBVKeQo/iTUoLPlfbt+9H8r8vyqc+qlHLRtonLw/Ms0ZyOVQ/ScQwn4EtbYpaSgQJAp1dhp3+2RAYd7LhL/EhhHk5BucglZSKWcC2xt+7G68euwb9CIjMtPP0YmVnQ1rPHGtOg5y1PAllr+HW5xR7fY8EMNmbzyEw+n23fts8/6froGShox0kw3aJddOxkswNwG6c7sh9yUezkrb/qY2LsaPS7ReYP2lwxqKJu+EFwLB3/fd9WDhJ27FMeAU/yoQjqUF96puSw7ZTR7rRaWURLpSSkULDtFzw3uqMuh8yzfT3EiLjlu/KgNsYaBAKqhTTZMBjzTG52CHbjU+i5fm33F1rqQFvDoCcN7gScG/VdL2FZMuqsREpWPS1Fu29+D4KTWQOxDGW3tf/nda34oqEEPquh8Nwv/3tFuwhJxP52ntEts7/Nhy+ses2MGrNB2PDD27iHQU7Mw/Yk2F4NqZXAszmRVLuzFQVXsW7DsNIf2oepILtDltG5hnf+tZ1pWSfEkAyPyB3OpBD1La4Y0IluLG1TQqdEwYuqoJXTncHc3dv+2luyvsSlLs55kceShjjfHYxPebJdWbBGatF2dvIVKZKruGXDk0Do/8f9QWrgvl7ot/O/Z4H9IDH7tuKKqM7hXggypgM+GXjVPSKnKruX/fEImeXnK9gduEIqVwKrTfxSrnqAjcZXuKHhak7QoEBmJX3TKbwXKXoZC2uhcYyEmnL/iRJvathca/E xnDumI1r CBZNs4JJW3Cvqrgy5u8r1SG6ShbM/lCsCvcivn+kl/SiQfB3qKK2ia/LxCaNHH5dQZdVA9mf6aoQLryMTA/4cS5iaGypsQSgBlRxEPDUhBnE4sEejLPdaXq89kHcWFPeBNWIbEymoOyXZnwadAliIQH0MJ1WNR+Ag7wxWsIkvg7F1aUkYjWEfeUh+Ire92F8wtOUYSOXlNomP79R+xP83dw3Mlzc4RlT8HN9nqAifEo/WroIg2kd4qEzTikkHQPLM+O+4 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 13:47:03, Matthew Wilcox wrote: > On Mon, Sep 11, 2023 at 02:12:25PM +0200, Michal Hocko wrote: > > 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. > > This may well be an unsaafe change to make. We're not just zeroing the > page, we're calling clear_user_highpage() which tells the architecture > which virtual address the page will be mapped at. It could be that > skipping the zeroing ("because the page is already zero") isn't enough; > there will be traces of the former contents of some page in the D-cache > for this address. I haven't realized this difference between clear_user_highpage and kernel_init_pages which is used by the page allocator. Thanks for pointing this out! > > Or it might just be an optimisation. The description of clear_user_page() > isn't entirely clear; the port may be relying on clear_user_page() > to have flushed the dcache aliases. > > At this point, I don't think this patch is worth the risk. Agreed! Based on that I take my ack back. > My mind is > changable on this, but I think we'd need buy-in from ARM, SH and Xtensa > (who directly define clear_user_highpage()) as well as Arc, csky, ia64, > m68k, mips, nios2, parisc, powerpc, sparc who all seem to have non-trivial > clear_user_page() implementations. -- Michal Hocko SUSE Labs