From patchwork Fri Nov 3 07:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855226vqu; Fri, 3 Nov 2023 00:29:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFJXLVSj2h/dJuRxa2ittKWNWN2aMGQOpyyiGiX2U6IVi5bU9dwKWoWZWAJPXtghgIBkHI X-Received: by 2002:a05:6358:6f82:b0:168:e637:a819 with SMTP id s2-20020a0563586f8200b00168e637a819mr25656709rwn.12.1698996561921; Fri, 03 Nov 2023 00:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996561; cv=none; d=google.com; s=arc-20160816; b=DgkDPa9CFe9/HMKrWSxNLzw7bMA+o6haWqac5JgUMA+wDXNluyyyDHLN+AadPaR6Re szBo8yr5itUX1u23ED0uuU2CENJrRSvj76/R3Lt28+bPNr/m7s4oRCfHy89iHnIwa3kg OPh7dQBTwcz7z+qo/ki9BkPHwK1z0WzdouOTBVcFYp2Qm3vsrez0Pd7z1pgCVnISekvi ErpfViVszFyUDOWwlauhWthg1AZZTkCDn6RuE8ZKTF5Nk1l0UcwOqk9jxO3skyyAhFHe ax8Yoks9pZdBLZoUw8HMSAaRr9MSgGcEj4rNu43ARwn8x/Lj5nQE+ODOZnosumiSFJo4 kvOw== 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; bh=65ZXimHJWlN/QEzmtlIfgy4P6IXnfEiyWMRz9ZITEK0=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=Q+u23G+1zYGJwGoDUTHl3kzgoO6uz0uIWFop4WzbhX1Z6uIVDtcHpoDbS3Lf0Hm/HR LrZRPJiCtlarV3kJ5G15O009Jen+VrNuw0zIzTat4fW2nXHGPiHkJ/M76ZN0Ejz9/jQa 47yMdjreZeWpBK2gwvIsZqpGNB0LqPRj77kodeSRIOKM1L+xiMJY1Y8yj0Pve0uC6Vfw eWKiUASnIBCNOv0gQ/DUNziMUwD3+X2a6MMlTrVgtGZIvK7tczdK5pxwYHV/CVWgmav6 dSOZiV8KchT9MzfiKU2l5rkrc8CurxIKr0jM1+Lp2nJ+rk3dqfOGVBZYwoA5Obwd5z/7 PmGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k76-20020a636f4f000000b005b8ccf97dcesi1019406pgc.297.2023.11.03.00.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 720FF831EDB4; Fri, 3 Nov 2023 00:29:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345277AbjKCH3R (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232993AbjKCH3P (ORCPT ); Fri, 3 Nov 2023 03:29:15 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DB91BF; Fri, 3 Nov 2023 00:29:11 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMC314Pj1z1P7ly; Fri, 3 Nov 2023 15:26:05 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:08 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 1/5] mm: huge_memory: use more folio api in __split_huge_page_tail() Date: Fri, 3 Nov 2023 15:29:02 +0800 Message-ID: <20231103072906.2000381-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527018876099385 X-GMAIL-MSGID: 1781527018876099385 Use more folio APIs to save six compound_head() calls in __split_huge_page_tail(). Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f31f02472396..34001ef9d029 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2507,13 +2507,13 @@ static void __split_huge_page_tail(struct folio *folio, int tail, clear_compound_head(page_tail); /* Finally unfreeze refcount. Additional reference from page cache. */ - page_ref_unfreeze(page_tail, 1 + (!PageAnon(head) || - PageSwapCache(head))); + page_ref_unfreeze(page_tail, 1 + (!folio_test_anon(folio) || + folio_test_swapcache(folio))); - if (page_is_young(head)) - set_page_young(page_tail); - if (page_is_idle(head)) - set_page_idle(page_tail); + if (folio_test_young(folio)) + folio_set_young(new_folio); + if (folio_test_idle(folio)) + folio_set_idle(new_folio); folio_xchg_last_cpupid(new_folio, folio_last_cpupid(folio)); From patchwork Fri Nov 3 07:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855289vqu; Fri, 3 Nov 2023 00:29:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU1xa6uwYIHOL1eWdwBXIP+ksEKoO/BACz21ka3MmHoMTn04n3QX47miPe9Dn2JARFDiao X-Received: by 2002:a05:6a00:3911:b0:6c3:710b:38d7 with SMTP id fh17-20020a056a00391100b006c3710b38d7mr914596pfb.6.1698996573209; Fri, 03 Nov 2023 00:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996573; cv=none; d=google.com; s=arc-20160816; b=aIGgsKtnqBt8DJy759xJ+CTE6rvPghdn22Wueiw60/pR3oj4mtab/WJBypg2HRgSBl NKlKwtDDuVYl3S5nRUDU66h8BaP5ETD+31dN+3YePegCZu+gMrfqklcpDtB4DprwEYaH udHjBoNwnH1a5fa8E04iU4gzC+zGn98tj0Vyu8p+24Bmsnd3sJ1OCxzayxoFQUdE7iV2 0/eR6uOAFa0UWS3lCRo3TlYVwnXYAvfFdWBz06E+fr66VUWUxRtPBAeTjCnVZPeorJM7 mk2k51vRAgOoyFg3gAbi0gJyGAJwsgydfpHFDXwCbyhAfWggDHKk52FArQH++tQLvA6s HuzA== 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; bh=AQJiy9IXd2NR29+aOZjza5Dosuma1yW9JXDs2UHJAes=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=sadiZmtrMBJQH/X9AYX15z2idvgqnU/c3JcJQKe3ndzbnt9YcHxWpnHsKEsV4dJYeb Q4onH+ZuBeiXsi2KuPDc10svrDSvzoDet4ZS7cPVYfksqQbs3fj2SYzdKF7/giArVOHc 96xycY6VkyQcaKDYanL9ZK5QMEKxgMmX5NIQj1HjnYlemQdLT1wKExOIi+znurQo7HPW wndxAlSGUMkU3azcsUdo9lMPEZBMe3OpQjeTo48Vh4c3P5wm/7B1o+Mu7T/hUG6sTSiZ 7oThY1tsSiFvRZ7W+Ft5FEDbFzplBueM3Tn2JoObGORjH5ODz21h8b3MFlVBBHouRuFs DD/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h16-20020a056a00219000b0068780155ddbsi1076729pfi.131.2023.11.03.00.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id EAFD281A5DFD; Fri, 3 Nov 2023 00:29:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346142AbjKCH3W (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233093AbjKCH3P (ORCPT ); Fri, 3 Nov 2023 03:29:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B7518E; Fri, 3 Nov 2023 00:29:12 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMC1p61SqzPnmj; Fri, 3 Nov 2023 15:25:02 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 2/5] mm: task_mmu: use a folio in smaps_account() Date: Fri, 3 Nov 2023 15:29:03 +0800 Message-ID: <20231103072906.2000381-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527031183992160 X-GMAIL-MSGID: 1781527031183992160 Replace seven implicit calls to compound_head() with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index ef2eb12906da..5ec06fee1f14 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -445,23 +445,25 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, { int i, nr = compound ? compound_nr(page) : 1; unsigned long size = nr * PAGE_SIZE; + struct folio *folio = page_folio(page); /* * First accumulate quantities that depend only on |size| and the type * of the compound page. */ - if (PageAnon(page)) { + if (folio_test_anon(folio)) { mss->anonymous += size; - if (!PageSwapBacked(page) && !dirty && !PageDirty(page)) + if (!folio_test_swapbacked(folio) && !dirty && + !folio_test_dirty(folio)) mss->lazyfree += size; } - if (PageKsm(page)) + if (folio_test_ksm(folio)) mss->ksm += size; mss->resident += size; /* Accumulate the size in pages that have been accessed. */ - if (young || page_is_young(page) || PageReferenced(page)) + if (young || folio_test_young(folio) || folio_test_referenced(folio)) mss->referenced += size; /* @@ -479,7 +481,7 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, * especially for migration entries. Treat regular migration entries * as mapcount == 1. */ - if ((page_count(page) == 1) || migration) { + if ((folio_ref_count(folio) == 1) || migration) { smaps_page_accumulate(mss, page, size, size << PSS_SHIFT, dirty, locked, true); return; From patchwork Fri Nov 3 07:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855326vqu; Fri, 3 Nov 2023 00:29:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLRUdrbO5mF6AOCumiz/ft09C1C2ZxLxBHz25S5/g7dGeLi0k1nnuSiqpY3xYttvPNNcp8 X-Received: by 2002:a17:90b:1a92:b0:280:963d:9c5 with SMTP id ng18-20020a17090b1a9200b00280963d09c5mr2573213pjb.21.1698996578425; Fri, 03 Nov 2023 00:29:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996578; cv=none; d=google.com; s=arc-20160816; b=ktuUCGeWyd12QgBBpQuDx3KyOlyFwHHeTsCXM2rfaKKPZuf+NAAX/sbVAn/0AsZOG4 EBnn/DcqQX97Wk1nyzRxkcjX//pefEwK7v6bbQYhnkt4leKeiF0cn45Y5CPesk7KfrOS H95nf2UCqZQxtON5gSCrTwt9SjR23HMylCAaJgRqNCj8WW3ZIg3yLERkRE3VX4FgROfr x5EEzU7iKRgQFhoBCl64g2x0Jd3ZkFLKHK0UoDrKywSUa7J0j1uw7/nnYBUyXPDmMTSp 3zsd0JBD9LtD9P15K8egSPDu2pPop2KXnx5GHke3Tlf6Jq4ZkJow/uwf9M1x/K/SKipf Da8w== 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; bh=8hChM+nSnnRVSf3gsBcEIPIrRk98k1bA3SQNacWoQLo=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=IYwhbFEnM/bo3j+nkAsjSSVKU0tq8VzkJMNGIp2SY0RR58PWc32zIpvt9mQQnv161z 7PcbJ9DtCHHmGFA2c8IMYUNI4J0R/USDu7kzG9lgYoAnFmgnM6ddkXNWrMsgj8DoAsED HNOTp9Xm0pdMZMjLO9JzZY/lAlVpGq6GQwURd/SoORwK53dLUO4wyRN5bCOs/ZOuRF18 iyE3YsvDP6jCgxxdd6AMEmDVdqLF4D5vurbg2T1ksBC1gLk9/pR60XANjUT3IVSXvb0I ARUMFYNajOOMPljA7hVtj1fhOcBtEOEEKUWEb3psVHNKmCKUUsyaAg/271z0ipbAQ8Oi 5P7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c3-20020a17090abf0300b00274d3f62044si1108355pjs.111.2023.11.03.00.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 571D8825F178; Fri, 3 Nov 2023 00:29:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346151AbjKCH3Y (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbjKCH3P (ORCPT ); Fri, 3 Nov 2023 03:29:15 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 649EAD43; Fri, 3 Nov 2023 00:29:12 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMC1W2j3lzMmLh; Fri, 3 Nov 2023 15:24:47 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 3/5] mm: task_mmu: use a folio in clear_refs_pte_range() Date: Fri, 3 Nov 2023 15:29:04 +0800 Message-ID: <20231103072906.2000381-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:34 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527036423835368 X-GMAIL-MSGID: 1781527036423835368 Use a folio to save two compound_head() calls in clear_refs_pte_range(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5ec06fee1f14..869f6bb89230 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1161,7 +1161,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, struct vm_area_struct *vma = walk->vma; pte_t *pte, ptent; spinlock_t *ptl; - struct page *page; + struct folio *folio; ptl = pmd_trans_huge_lock(pmd, vma); if (ptl) { @@ -1173,12 +1173,12 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pmd_present(*pmd)) goto out; - page = pmd_page(*pmd); + folio = page_folio(pmd_page(*pmd)); /* Clear accessed and referenced bits. */ pmdp_test_and_clear_young(vma, addr, pmd); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); out: spin_unlock(ptl); return 0; @@ -1200,14 +1200,14 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, if (!pte_present(ptent)) continue; - page = vm_normal_page(vma, addr, ptent); - if (!page) + folio = vm_normal_folio(vma, addr, ptent); + if (!folio) continue; /* Clear accessed and referenced bits. */ ptep_test_and_clear_young(vma, addr, pte); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); } pte_unmap_unlock(pte - 1, ptl); cond_resched(); From patchwork Fri Nov 3 07:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855376vqu; Fri, 3 Nov 2023 00:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSkzS+9GCyS8W0GktF/AhLZd75SVzA3n/lfjcEvjBH7TEnAeAh33i6oscN074lx5Z3snRT X-Received: by 2002:a17:902:e88e:b0:1c7:5776:a30f with SMTP id w14-20020a170902e88e00b001c75776a30fmr2701068plg.12.1698996585685; Fri, 03 Nov 2023 00:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996585; cv=none; d=google.com; s=arc-20160816; b=LWMu/9dKyFD1wxElTZE50aAG8OAhWdA4iG4qsiHGh7uClnA+sGPu+RRupuSE8UmzlL Wi6JggmmbfKqvyht9fz0u797rjmSrXllH2eq57T4y+2lEHgchcukHU/PS+1KoLbPCjAq fa3JDhwLJNDApzDp7RAMCNXtIzfCVs6EmJZx7Hj/9Ib+vla2PPNi9G87NuGXUqcu/EPI 8hplfK36l/B49oRwDStkpj//iupAwTTvxzqHB98ixhTQE0An8kDHDrsTUa1yNmAN5p+Q 51VcYBsUf5ZBlvv6gUSzLJVaVTxv593nkpvZU80Y4Ms8UsYodoFfVWuH3mlc/1biDZgK Rp5Q== 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; bh=ffFsOMCEMvqrtDLA9F7plpO34zh5hKKKwxR41j/1U6k=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=qOdBN9zr4cMGWB1HOxN27bHuENkoIyfczM7ELUVQb5GB2I2xONl+puftvmnOuhIvAX s8HeWjwJgmcoGMUbTXB+tsUHR5Vbsr9VV9M0HgnQTJ3RB9tdWEEmF+aXVhOaqcMmhzby j7VyaP/MAUkndBdOX20Iow5eqvHndYidOujDQzUzGjtDtF3p6KUIzIs++AM6Qz45u1gw shNwxbWZU/7HtXxopD3q7ThcWFyucUcXttyNnI1qeBpdSx6t2NfHYR61ZZ+VQmLYW7bF 8BnnOGhvKxBq4Wy6ecmlmnt8hui1FWTMWI1opmQHji7bHQ2JAF88VpMHRvjQaKbdmmNJ x6Kg== 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:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id j7-20020a170902da8700b001cc50c56980si1120766plx.411.2023.11.03.00.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 85D1F825ED8D; Fri, 3 Nov 2023 00:29:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346169AbjKCH3a (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344219AbjKCH3S (ORCPT ); Fri, 3 Nov 2023 03:29:18 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C7C1A8; Fri, 3 Nov 2023 00:29:16 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMC6W1mdSzvQJd; Fri, 3 Nov 2023 15:29:07 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:10 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 4/5] fs/proc/page: use a folio in stable_page_flags() Date: Fri, 3 Nov 2023 15:29:05 +0800 Message-ID: <20231103072906.2000381-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527043801821281 X-GMAIL-MSGID: 1781527043801821281 Replace ten compound_head() calls with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/page.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 195b077c0fac..94ab0ba13b16 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -109,6 +109,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) u64 stable_page_flags(struct page *page) { + struct folio *folio; u64 k; u64 u; @@ -119,6 +120,7 @@ u64 stable_page_flags(struct page *page) if (!page) return 1 << KPF_NOPAGE; + folio = page_folio(page); k = page->flags; u = 0; @@ -128,11 +130,11 @@ u64 stable_page_flags(struct page *page) * Note that page->_mapcount is overloaded in SLAB, so the * simple test in page_mapped() is not enough. */ - if (!PageSlab(page) && page_mapped(page)) + if (!folio_test_slab(folio) && folio_mapped(folio)) u |= 1 << KPF_MMAP; - if (PageAnon(page)) + if (folio_test_anon(folio)) u |= 1 << KPF_ANON; - if (PageKsm(page)) + if (folio_test_ksm(folio)) u |= 1 << KPF_KSM; /* @@ -152,11 +154,9 @@ u64 stable_page_flags(struct page *page) * to make sure a given page is a thp, not a non-huge compound page. */ else if (PageTransCompound(page)) { - struct page *head = compound_head(page); - - if (PageLRU(head) || PageAnon(head)) + if (folio_test_lru(folio) || folio_test_anon(folio)) u |= 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + else if (is_huge_zero_page(&folio->page)) { u |= 1 << KPF_ZERO_PAGE; u |= 1 << KPF_THP; } @@ -170,7 +170,7 @@ u64 stable_page_flags(struct page *page) */ if (PageBuddy(page)) u |= 1 << KPF_BUDDY; - else if (page_count(page) == 0 && is_free_buddy_page(page)) + else if (folio_ref_count(folio) == 0 && is_free_buddy_page(page)) u |= 1 << KPF_BUDDY; if (PageOffline(page)) @@ -178,13 +178,13 @@ u64 stable_page_flags(struct page *page) if (PageTable(page)) u |= 1 << KPF_PGTABLE; - if (page_is_idle(page)) + if (folio_test_idle(folio)) u |= 1 << KPF_IDLE; u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(page)) + if (PageTail(page) && folio_test_slab(folio)) u |= 1 << KPF_SLAB; u |= kpf_copy_bit(k, KPF_ERROR, PG_error); @@ -197,7 +197,7 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_ACTIVE, PG_active); u |= kpf_copy_bit(k, KPF_RECLAIM, PG_reclaim); - if (PageSwapCache(page)) + if (folio_test_swapcache(folio)) u |= 1 << KPF_SWAPCACHE; u |= kpf_copy_bit(k, KPF_SWAPBACKED, PG_swapbacked); From patchwork Fri Nov 3 07:29:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 161186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp855333vqu; Fri, 3 Nov 2023 00:29:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+W9Mpd01ASdMcMqGG2Z4WtYxF5onMwUuM2QgIm7eARV0p494Zv9KbKUFObTjcgOLuJuPw X-Received: by 2002:a05:6830:a:b0:6bd:1059:8212 with SMTP id c10-20020a056830000a00b006bd10598212mr20780884otp.26.1698996579341; Fri, 03 Nov 2023 00:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698996579; cv=none; d=google.com; s=arc-20160816; b=j8pQ/OstdSRtyadoe2aNT2emn/M6F7yLhD6KWvMwhr+fES61qjLtrphcu2FVnORVVi n84ZfuQB24xRYNFJ04/JOiVPFMLTvLD5qEPQSOhEkOkAt01RbVycYeGEiYEKSr8vzbSA XkU+wvkS3NiUERJ+6sA41joioTzzK7AGIUjrOstGg5eg5s9RCx8ysWxuq2/3MoANADBs ury16UxloX3Py8V8vWAEN5di5GO+hoG3XPyTmx8AJ9ihBMPUmhR8SjRiS+o4ebss482r aRK2gyvfInRndSXqxV+EILqCWxWG112tJx0pEzZiWH0/pa/wcbiFT7LZG9OYSkATKeQ8 UZ8A== 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; bh=5eAPoCyw7ST93JlrloiSVZ/yrBLsJoeWkbzc0p5ovyE=; fh=Q7tPJ/E8MvXjzgZkYtX4LsRnr2SdvitVhN9e/tMZDyY=; b=Rvq+yrwGNgfVFZv4tTUewIOufKH5c+byJ6qDC67M19fjy1RkZrWhzE+dO6/sxRHTHF cWZEF2iq76BH2OTxIS891ha+KXI+I7owNw2YyKH0aboacB0jyM9eSGQ72/z6wMvpOd59 fSat31ZuOaDlyAoLDu1r4qcSPCbs5pwFuv6k94DuNGY4NHvJpKnJjuqxmKfgOwEKuDiX HjlOuyw0kAsaaPOz7L40OLv78K3OHRawx9Od3H6AOSS0sBUM9JM1f9XIrCsai7LLLAaq 6Pw/Z9UaJyVDVT58VhTXJewv1lE0O0Qq2y7UfcQZgtT70eMyfVVgHdeAedVp0m6+G/Zy pFKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n3-20020a632703000000b00577f4d85fdbsi1116153pgn.548.2023.11.03.00.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 00:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3C69F81B456C; Fri, 3 Nov 2023 00:29:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346184AbjKCH30 (ORCPT + 36 others); Fri, 3 Nov 2023 03:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbjKCH3Q (ORCPT ); Fri, 3 Nov 2023 03:29:16 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB6F1A6; Fri, 3 Nov 2023 00:29:13 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMC6W4d5RzvPrQ; Fri, 3 Nov 2023 15:29:07 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 3 Nov 2023 15:29:10 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , Matthew Wilcox , David Hildenbrand , Kefeng Wang Subject: [PATCH 5/5] page_idle: kill page idle and young wrapper Date: Fri, 3 Nov 2023 15:29:06 +0800 Message-ID: <20231103072906.2000381-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> References: <20231103072906.2000381-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 00:29:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781527036826218578 X-GMAIL-MSGID: 1781527036826218578 Since all the calls of page idle and young functions are gone, let's remove all the wrapper. Signed-off-by: Kefeng Wang --- include/linux/page_idle.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h index d8f344840643..1168d5f58ff2 100644 --- a/include/linux/page_idle.h +++ b/include/linux/page_idle.h @@ -119,29 +119,4 @@ static inline void folio_clear_idle(struct folio *folio) } #endif /* CONFIG_PAGE_IDLE_FLAG */ - -static inline bool page_is_young(struct page *page) -{ - return folio_test_young(page_folio(page)); -} - -static inline void set_page_young(struct page *page) -{ - folio_set_young(page_folio(page)); -} - -static inline bool test_and_clear_page_young(struct page *page) -{ - return folio_test_clear_young(page_folio(page)); -} - -static inline bool page_is_idle(struct page *page) -{ - return folio_test_idle(page_folio(page)); -} - -static inline void set_page_idle(struct page *page) -{ - folio_set_idle(page_folio(page)); -} #endif /* _LINUX_MM_PAGE_IDLE_H */