Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2646026rdb; Tue, 12 Sep 2023 08:05:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXz9Q6FsklZyyK7Hqac+tgPmGedidflAvMzCRRQk42hTgZ+8do5R47kxCmzHHZGLkRTFe8 X-Received: by 2002:a17:90a:5411:b0:268:b7a2:62e8 with SMTP id z17-20020a17090a541100b00268b7a262e8mr11913073pjh.7.1694531136140; Tue, 12 Sep 2023 08:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694531136; cv=none; d=google.com; s=arc-20160816; b=tPJ5XYQrn1WIhSFNsi1THSxhJ+gzVXctwgcPIaP54mMedb3/dx/OotruJIX6X+RZV+ Y396tB9VFnk+Y4nLHSrH3Azm5zFZavrRRqpc1gX4PxmJrYqgHsRbKZsB9CjOeFzIWqDn Nx0TR1CXbX9ke8SAZcZOY7m5ONWAjSx8P6EF1qQAov4DrDUa4kE+LZpysUAmVkX8IIF3 cgjRJlx3hXcaj1z6ZIsEi/OXS8WhcR6PqVy1EJwfveoP9L7e9z6iXgpbTlq1Vg49PmLs yl/yHamRqPzeitGe1qF4ZgLfo21/5aU53RROcDh6dqanupbvIt7GrFlpQd9gV8Fo7O3g 4GKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8/SJd7uAeq+C6xNw7E5T8lhkAqYav/AoZkSdrJ8MoKw=; fh=5dfqZQeMHNVusjM/fSJLZeiIOFxayjrToMSVEAKq+ho=; b=rRCj9hXJIKOVGnJOwTGQv+g4MWEqWJ+uy46lj3OBUlEkRC1lIa1OtLGQTG1qz6SxHg x9LxtOqAx2LjEuBSO1ydFl5t9fF/p3zPrjAcy8gKjjdqtBA2q1zL5s9L1poyb9fbXp2O cv0gf21SWbuMPAgnGDbHOYXiwqaIodajF4+J+bLGWQ6hihpDB0g303FeBq/BOCVAtt/S U1bLgEfrkUofoeUtn8MraMebnZvaG+gx4LuEwgSB1HgN8vCLaxqv3OCKpkasx1rKd09A Cdi0y7hE5bW8L7W9xW1LM5uuMA0kuXH9lLlCIvmSZ7gkipk2IDkmkjgulkDLFFpOnWxh 7pqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=P2fGgS+N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id y90-20020a17090a53e300b00273ecc30968si6274269pjh.41.2023.09.12.08.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:05:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=P2fGgS+N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 349E781167A6; Tue, 12 Sep 2023 05:18:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235070AbjILMSG (ORCPT + 99 others); Tue, 12 Sep 2023 08:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235046AbjILMSF (ORCPT ); Tue, 12 Sep 2023 08:18:05 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9025F10D2 for ; Tue, 12 Sep 2023 05:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8/SJd7uAeq+C6xNw7E5T8lhkAqYav/AoZkSdrJ8MoKw=; b=P2fGgS+NSCITBCYpab2tKiIUMc ua7MWnLjEr4edXKkTTXlW+/r+64NTQ2mv0lAr0AxtCloRxXCIBWGoQkkkD7eg0sqkmj91m4+fYsaz j9gIivwbqeZPQ8QmQuUCdoH1C6Mf9cW/05ZsqgYDmpSj219sVDycFJ2cVmCPeejRv24IPXPG62CFa XzlxwgjORqVcyIzzIOSZHMRHNWKSjl96Ct7tzW/lWZDsT2zoKtw55G2peEHFLQNvjgFtEfcI60D79 igRA0Q8j+oMlorXeDYXwfSVMa3LSrqIMNymA6ibgXQN3P42C3YLQpmftSvAlYYHOYoiyPyS4JWGQH OJfY3RDQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qg2Ki-007VF8-0o; Tue, 12 Sep 2023 12:17:32 +0000 Date: Tue, 12 Sep 2023 13:17:31 +0100 From: Matthew Wilcox To: "zhaoyang.huang" Cc: Russell King , Andrew Morton , Mike Rapoport , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , ke.wang@unisoc.com Subject: Re: [PATCH] arch: arm: remove redundant clear_page when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on Message-ID: References: <20230912103334.2074140-1-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230912103334.2074140-1-zhaoyang.huang@unisoc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 05:18:07 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Tue, Sep 12, 2023 at 06:33:34PM +0800, zhaoyang.huang wrote: > From: Zhaoyang Huang > > Double times of clear_page observed in an arm SOC(A55) when > CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on, which introduced by > vma_alloc_zeroed_movable_folio within do_anonymous_pages. > Since there is no D-cache operation within v6's clear_user_highpage, > I would like to suggest to remove the redundant clear_page. > > struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma, > unsigned long vaddr) > { > struct folio *folio; > > //first clear_page invoked by vma_alloc_folio==>alloc_page==>post_alloc_hook > folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, false); > if (folio) > //second clear_page which is meaningless since it do nothing to D-cache in armv6 > clear_user_highpage(&folio->page, vaddr); This is, of course, not the only place which calls clear_user_highpage(). Please explain why this patch is safe for all the _other_ places which call clear_user_highpage(). > return folio; > } > > Signed-off-by: Zhaoyang Huang > --- > arch/arm/mm/copypage-v6.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c > index a1a71f36d850..6f8bee1b3203 100644 > --- a/arch/arm/mm/copypage-v6.c > +++ b/arch/arm/mm/copypage-v6.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -45,6 +46,13 @@ static void v6_copy_user_highpage_nonaliasing(struct page *to, > */ > static void v6_clear_user_highpage_nonaliasing(struct page *page, unsigned long vaddr) > { > + /* > + * This criteria only help bailing out when CONFIG_INIT_ON_ALLOC_DEFAULT_ON > + * is on. The page has been memset to zero when it allocated and the > + * bellowing clear_page will do it again. > + */ > + if (want_init_on_alloc(GFP_HIGHUSER_MOVABLE)) > + return; > void *kaddr = kmap_atomic(page); > clear_page(kaddr); > kunmap_atomic(kaddr); > -- > 2.25.1 >