From patchwork Fri Sep 22 09:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 143287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5431999vqi; Fri, 22 Sep 2023 02:28:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGz513Sxw3Te02btO0ZgkP38sogj9JPInSBG1s/Ox8ekmg9XgYeVorSiK9ewfMLGjuMH8CV X-Received: by 2002:a05:6358:ee94:b0:143:688f:f922 with SMTP id il20-20020a056358ee9400b00143688ff922mr8049689rwb.1.1695374926909; Fri, 22 Sep 2023 02:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695374926; cv=none; d=google.com; s=arc-20160816; b=QAJnG9WR9xQANJdMa/EeMvcLK6vMKUPb+80r3n5K+TSWIlc4vMkFdDGBwYvOBqa81u UDH3m7yru6VOwRyRt0MRm6alu69fhXPMUVe6KEtFLmOb9co5sW6lZXloBUANtE4Iu2v4 vX21hNHT7W3WppZoyPtqVUpGnGYqAodp4fznz8upylZUwmp7OPk9AdSpbiwB6dd1RvEb TsjN9J/EFBuIoAu9zFiuEdS3w3PO0+BPb7ArlM0RLv4k7wTvSEDgQJRoMpQnS5IjLa4H kjM4VU1GBRyfjFvb2JarbcZmOmxFtYqZc0wEIpkAvZaoKkiDVfjX2QhXpI5xx950cuEw fWJQ== 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 :message-id:date:subject:to:from; bh=EtwsjmH2deAB2tkzqrv05s1FTlEyCbpyu4rOwuNpG6g=; fh=QhBEZ9YpbU9kaqwGrFR4Y6Kc6nCGCTYJYQJUSn2eHH0=; b=IqjbrkBlOm+CE5DF+aXrfNjbC9WD+wvIpzPk/j/BMyKfzZ64HHFOtWLvgNTaCTNoQb /gFKEi8E8PBpbMlShw2AcJd0R89GPD26KsDKfSth34xJSz/Pl90pQnlKDSBnz2LBGJzS mYpHH0g7O3Kyi2gZzvBz2DYlnSx9lwS+2Pjxw0uCAkTJIJLy5M4f94ZRd0LT935Z9CBT vqyDW9VLgF7nc3lY3aQbhH4y3y3De3xbHuKJk/NMQ2jHEIUWFF1gQFe36DnaUqzGqU0Y BmhwfSDRuWy9y09xkJMP9bUkMh6i8add16uEWlj2JzPSrMnPqG6I4O+GjMiD5d/PyBZW VRfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id o8-20020a056a001bc800b00690d02ac9acsi3319438pfw.77.2023.09.22.02.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 02:28:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id A95158292683; Fri, 22 Sep 2023 02:16:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbjIVJPz (ORCPT + 30 others); Fri, 22 Sep 2023 05:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbjIVJPq (ORCPT ); Fri, 22 Sep 2023 05:15:46 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08541B2 for ; Fri, 22 Sep 2023 02:15:32 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 38M9FBK6033971; Fri, 22 Sep 2023 17:15:11 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4RsRNP2mzdz2SdWY0; Fri, 22 Sep 2023 17:11:49 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 22 Sep 2023 17:15:10 +0800 From: "zhaoyang.huang" To: Russell King , Andrew Morton , Mike Rapoport , Matthew Wilcox , , , , Zhaoyang Huang , , Subject: [Resend PATCH] arch: arm: remove redundant clear_page when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on Date: Fri, 22 Sep 2023 17:15:05 +0800 Message-ID: <20230922091505.2196197-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 38M9FBK6033971 X-Spam-Status: No, score=-0.8 required=5.0 tests=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 lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:16:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777729459790597750 X-GMAIL-MSGID: 1777729459790597750 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); return folio; } PS: Here are all positions called clear_user_highpage which are paired with alloc_pages. IMO, it is safe to skip the second clear_page under armv6. drivers/media/v4l2-core/videobuf-dma-sg.c:441: clear_user_highpage(page, vmf->address); fs/dax.c:1612: clear_user_highpage(vmf->cow_page, vmf->address); include/linux/highmem.h:231: clear_user_highpage(&folio->page, vaddr); mm/memory.c:5974: clear_user_highpage(p, addr + i * PAGE_SIZE); mm/memory.c:5982: clear_user_highpage(page + idx, addr); mm/shmem.c:2621: clear_user_highpage(&folio->page, dst_addr); mm/khugepaged.c:796: clear_user_highpage(page, _address); 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);