From patchwork Thu Jan 11 11:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517215 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 6A786C4725D for ; Thu, 11 Jan 2024 11:13:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0EA46B009A; Thu, 11 Jan 2024 06:13:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBCBB6B009B; Thu, 11 Jan 2024 06:13:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5DDA6B009C; Thu, 11 Jan 2024 06:13:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9D3F46B009B for ; Thu, 11 Jan 2024 06:13:41 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6429B80C79 for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) X-FDA: 81666769716.10.8B1C2C5 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf13.hostedemail.com (Postfix) with ESMTP id 2AB142002A for ; Thu, 11 Jan 2024 11:13:34 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971616; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oZZ54VdEIlacFfuk1r0uZ44GYKJKe8HsZ6PDThbFMXE=; b=bVLwXlCoRvwVgvA8QlfVxWuQY69iDKgY19bHYEQJnFmogg2rUqpHFTQr7d7NdS4rdH0Khk ibTD8cwvPcN4nIIJNRrdICwd+n/9homzdkyDWWuxCP2jbF9LjfJhOYKYgVYNNSZNkYUUcV sJqXUn4wFSbJAzjIrh9kCVzJhUIE9rY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971616; a=rsa-sha256; cv=none; b=iZuFxEbBJ20i5FEfJClDDI5Zq7Mf1SDHkViz/v57DBfq0vShcTtx3nt71ZGKU/3jlhG0YV C4btie/jOyI5PuEGuOcu00YSdSv4H6M/8pbRewCLUZ4y8gwzKARNZ+Vp3xCu+m7nBYEg/J sIQfl5czrZ7JN/09ieFjrYp9D5/ig1c= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4T9hpj0FN4zsVcd; Thu, 11 Jan 2024 19:12:45 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id DCDE818006E; Thu, 11 Jan 2024 19:13:30 +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.35; Thu, 11 Jan 2024 19:13:30 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 1/8] mm: swap: introduce pfn_swap_entry_to_folio() Date: Thu, 11 Jan 2024 19:12:32 +0800 Message-ID: <20240111111239.2453282-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 2AB142002A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ajuu3et4rn7pw9tn1tfusbziti3ei6qn X-HE-Tag: 1704971614-389185 X-HE-Meta: U2FsdGVkX18G0mJOn6O/va3Yd8LyrNAAjkVgXLebfblU3hLbYJOpMF/Ty55Dvhb6/40+yj+ZfPj1YAq5lozJPdtQpG+wV6Cp+p/t8hu+gvcH3qZGTzbNz21sjPNguZNJAGl1tWQUF0jHmmp4w8/TSKvYqF20UBRbwnnpTxgdvgrDPA7zbsDPyxWo9vfzBdu+MQxtFAkVTrRlHp0vzgxmupKLp6Rm6n7ePR8YlC0F+bxRuCDcO/DgAJlcqd3FZ74ouBGiyLqLKRC6OWqDTztzF0bmw2o5jH4vVvLeBzC6wyOO+f+NisvdEarQG6FnbgsUJJuEntY8M5yOPCCyZIj3fiQHeG2i5xMtAAcNyUpFLkulDdHctgyIrDGzZr9MOZx5t3SNpHsl8ssfJpxWPqAdTgTdUSTvh0GEU8j3+v5bQjQhweClOOMQ8pqUupfanHMUIYsBjKgA2D7RTjuWpHC69Ck3bWKrM6swdr0pBR5OWJYMpX9SQuKdC4MQB0PDGoVUAPR9sd/pDcsJNncSlxCcUXmyt++35HpILVndDmKPrP7QevCseSRFJW9VKcko9dr7hWjUu8EtDiJzol3OC2uG2q1QJWYm5KizqI3aOyO1Yr/0oLjzyBd1EBlydqPnK0kC/s3TY1CTtG56ouqWlCnnL49+4t/qw4puwOXsabEbQzjCY0GHaQS54zHkfb6x8hw2aGCA/+UcVc0t+Al6Qb6UVuX/xA6rOMUncZPxe6Q/s5F3swIXbhn2qrX3jIM4y38picAP10ZEn93rlWHW6H8C2s0iF5qyCBPZmxGmnCY2Jsb4zzSnC2mi2UiGr1SGEmuE4iaOpYsrDFoEElO5+fbQPb/gMaei6VJtLgrkIDDu1sNzs7t3/GdxrahZJY/CoY7MScQeeXlIoBplkbEdywVjN7ZwIWuO0uxF40whsagm0F6DVkvDHyWguXybUMeDBJEQYvx0Gaq+FHN47hzHzdf +XrrZCbI uU/S2mW/Jwef3xHRomr+wDlAN6YCUEIP9YZh6PmR5dejGaS0tvD3bkZIzl6PQQjeAcSxb1JcqXKXlVzdeiWPCgfChy/jthQRWEGRhRcqrz1/xr7SipikWf1M542utqHf7Qbaind34yAv3di09UdLCNtHX3uJE8S3RoOXAd8O3w1asmpE3rFsIV33X1pvQmoFcNgf9 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: List-Subscribe: List-Unsubscribe: Introduce a new pfn_swap_entry_to_folio(), it is similar to pfn_swap_entry_to_page(), but return a folio, which allow us to completely replace the struct page variables with struct folio variables. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/swapops.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/swapops.h b/include/linux/swapops.h index bff1e8d97de0..85cb84e4be95 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -468,6 +468,19 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry) return p; } +static inline struct folio *pfn_swap_entry_to_folio(swp_entry_t entry) +{ + struct folio *folio = pfn_folio(swp_offset_pfn(entry)); + + /* + * Any use of migration entries may only occur while the + * corresponding folio is locked + */ + BUG_ON(is_migration_entry(entry) && !folio_test_locked(folio)); + + return folio; +} + /* * A pfn swap entry is a special type of swap entry that always has a pfn stored * in the swap offset. They are used to represent unaddressable device memory From patchwork Thu Jan 11 11:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517213 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 BA9B2C4725D for ; Thu, 11 Jan 2024 11:13:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B02266B0096; Thu, 11 Jan 2024 06:13:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A88936B0098; Thu, 11 Jan 2024 06:13:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9501F6B0099; Thu, 11 Jan 2024 06:13:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 883B76B0096 for ; Thu, 11 Jan 2024 06:13:39 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5789E16060D for ; Thu, 11 Jan 2024 11:13:39 +0000 (UTC) X-FDA: 81666769758.07.92A36AC Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf14.hostedemail.com (Postfix) with ESMTP id 0852010001E for ; Thu, 11 Jan 2024 11:13:36 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971617; a=rsa-sha256; cv=none; b=6Q8mb3zq+vMxnnjapkj40y7bPldl1eGlo9DIRfh/bnQsCKdp3p3sqUv8wwIr4zeh0Br8ML lE6c0CnXrQ8XD+ADQHA1K6X8Gw1OrXRLHevjm0ibjwWTPR31AATtlZxhXUHRvcdDls40NC 6iwbiBwzkaIK3WSRcDPPpZMDXB7xu6c= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf14.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971617; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FH2vFiBdBjF+ugH0m9h03lcbXnOe652tPxfxmnZBAtw=; b=18ZDMO/p9mfz0m/2qGU3YetILpYFZMT3ZylJl3uWPSPFDn8FSeFdlLxVby+zoW9BcaAh4B PhEBmx+T31lKPn3TH7oOaiMYVF0HKFq/4kqPfdSPCxzK6wing5I6CdoxF6SDZSvhjKLhRS 8lo2HZ3TrXRjVDVj0EKvtxxKVu6gXVI= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4T9hkq5dbGz1FJGQ; Thu, 11 Jan 2024 19:09:23 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 520FD1A0172; Thu, 11 Jan 2024 19:13:31 +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.35; Thu, 11 Jan 2024 19:13:30 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 2/8] s390: pgtable: use pfn_swap_entry_to_folio() in ptep_zap_swap_entry() Date: Thu, 11 Jan 2024 19:12:33 +0800 Message-ID: <20240111111239.2453282-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0852010001E X-Stat-Signature: et3tz57s5q3xxe9h6fi1zkd6ryh3h3j4 X-Rspam-User: X-HE-Tag: 1704971616-394724 X-HE-Meta: U2FsdGVkX19FlO9u795BiS+FnsywhtwK6PFRGZk6Sd54Lk2kfn64QIXDo32AXCteUNDo9Vay+BYq4OwtRf8hcyftlqssF7MNOc/SMqpxu3rkp5mMCAl46IJQUUaRs8hc22vj3drL1xKPuIQt9914NMD38ISj9L+8zuL5460VYpXFZHTKZVGGMWTEkjpmCK8RpMuh6tc/dpqjpiilafUQsjgOzrS8Ip+WlRMlWzynIpGGRJymtJsbFpd8MsA7cCWf35TzuYLR37lmQkja2854wcWRTsbsgwV+9N8qWyjCiOw+STfbOgITDe+K8LzknOF6g/U+wyEeZlPx0Z0ytZ5SDQjwu9O7O2k5wNn9NHB3PFdBHEKqjOtktXLo6QctBhukWuaMBSSL+p8PNcXL8CVbTEnL2AXX4DLQd/rmJ4cTRljdmgKIjnqExYxgX4+D6pFLcKEjmmOqWJIh1utlCY8eDtEyddUKxiZtfHwSnTt7j1XD/azjiQKRyp0N1bT9uIRr5CwCltoMxEG/fRRXsgYfnM9ncF9gbM43mjLIGASVzK0D2YhvcYJzoLpoTzngWSYp+eZv1E3X1zjZBbTn9cISVbKoq1MXSsOxNB3m1d8+on054J9fB0twXTZW8qV0F7heRxxRbf+5YrpCi7CbiiCOwsqBtw8uwY18YII6xv3u7T/JpnTU6a2osYW0WcfapSiNnnWyr2s8WNmpktzfHl1IDn5TbpECQ/Ia1VmZlhXXPHd2DzMtwOmCcYTqTgWRRDgThfFDn7zMnNQs3WyupVAEmfuelIEJjoLO/KlzTHu4hVIf2HFjad9YId1On1NcozyiTALM0QzNlBk9pbIisk2BwZikAVlC2vfrS+h3yjrdSCQTtSSyyZx2bzHxFyzHsqzCzyBEOsXEeZJh1Gtug0B3TRnIrxrCWoIEo6K1eNatE3FflFWYF4j0k7WLlkp1WQ/uMQEHJaHHfu9iVs5J6FE B/SK0pLn GcPcmvV9urryW2Bc/ew3sSkZJVnUCSretgwnlxDp3u3lTCFQxpHa5LObkiKzkysgkDJwVDU9I4R3H6irPEC/PZDPIA3/EANZvSsliYdxixEZUt5IEXR9qWj5z/j+XoInidV7wsDMPFw7nOU5Es5BlORTaDSDH+p8w/QXQFxzs6yfGJWXns0YuaHcyvQGFG8jnmu6M 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: List-Subscribe: List-Unsubscribe: Using pfn_swap_entry_to_folio() in ptep_zap_swap_entry(), which is preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- arch/s390/mm/pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 99422926efe1..e8fc5c55968e 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -721,9 +721,9 @@ static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) if (!non_swap_entry(entry)) dec_mm_counter(mm, MM_SWAPENTS); else if (is_migration_entry(entry)) { - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = pfn_swap_entry_to_folio(entry); - dec_mm_counter(mm, mm_counter(page)); + dec_mm_counter(mm, mm_counter(&folio->page)); } free_swap_and_cache(entry); } From patchwork Thu Jan 11 11:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517217 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 35EA6C47077 for ; Thu, 11 Jan 2024 11:13:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70DAB6B009D; Thu, 11 Jan 2024 06:13:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BCE86B00A0; Thu, 11 Jan 2024 06:13:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 582D36B009F; Thu, 11 Jan 2024 06:13:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2C21B6B009D for ; Thu, 11 Jan 2024 06:13:46 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0CB3BC059E for ; Thu, 11 Jan 2024 11:13:46 +0000 (UTC) X-FDA: 81666770052.07.7DFD120 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id CB08A10006C for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971619; a=rsa-sha256; cv=none; b=atmGdGNXPMF8p/v2YOoqaladLpjhEzdoM6o23h56nb3VbrWWLmyuN+cDnt/JOpMW1Fnb6d sJZdpOTjiOMHA8C1HDg/QgXMvkKdbD/8G2pHf9WLwqGeoN0UvnqEjKUU/wYUonvjYucQTT C3m0ZcMceZxfX9IJsjDqgIx6RjbqIBg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971619; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RJKWCsjrvrxR0bMzo6GUQfyaGQbwhcyBfRj9xVJyA4U=; b=j4qv09Wr63usZlfNs9GFbkkwR+9qu6JW8gWtbgXHdK4yIrbmtVsuJ64dSst7lknbwdVF1a 9guWBpFGCQr77Tm1B4H1mxZkiMNRbSO2T2l2CzdKRLTJgnjfkUF1K/uVpIwXy3SjqpOyOR oTVpdov1q/huMqvFRDMOntxgnbgROs0= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4T9hpk0Z0yz1Q7T4; Thu, 11 Jan 2024 19:12:46 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id BE9AF180071; Thu, 11 Jan 2024 19:13:31 +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.35; Thu, 11 Jan 2024 19:13:31 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 3/8] mm: huge_memory: use pfn_swap_entry_to_folio() in __split_huge_pmd_locked() Date: Thu, 11 Jan 2024 19:12:34 +0800 Message-ID: <20240111111239.2453282-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CB08A10006C X-Stat-Signature: 1fh8and9yw6a7b1a48bhdzu7nb5jmrws X-Rspam-User: X-HE-Tag: 1704971618-53702 X-HE-Meta: U2FsdGVkX19t0oFeQFu8+L17H3gwVyk4pu+Y/nohwGG/MMw/+C4u04up78XGQIJlFZftW7POlm3njM5flCzt8/Uaw3FqZuY4eECsKc/1R5enhtBk+sB9AF9PuXDhHx/Eo715NkdfMpCG0j/Q44hPJFocwxXzY+aLJ7Z78UNOw2bJ42zDY3BWnH4mUk2jvVfYCLdJ6d0uNSgOBf1K98ptd8yo7geiIVLkpsmE0ExUSP5VNJ7DIBDj9DU4MRr9ah+WH051xKK1iBECRSACbXwcErAVh00gJzchcqeHXlkvqoxym6evLupPLViXipu1k/CZAApNmD4EcGQ5A627//lv9mrRkfrGwg1B+wNuWhmE9Sjsz5XYCK9MC9uGr/qL/aGuF8dCe3mu/0Gz/4qOKr8ge4pxRCuh2defp8timSwhHJrD6mSzLFCtQ0QOZFYSaXLS0CjDdyb4bC3cKtW1YA3S4JH7/pHU7TD3zPE2FtenIXu+qlESrKIerUYEeZYyiy5L0/J59dAi/wobGCQKMugtTKQu96G5LodNrSeBCLb0ihXoV74cGDbr6ZMPrRVH6/1TNBxtsnNyc+tas88OLwDWanBYGiHNTnFgg2caIa37/xFysRBRfd5UL363O7t1sO2TjoHQuNZWjAaXp2AI3Vj4175ePWGrOyiiRRRK11hWYz506UGOssdZFEZjbc9WpmfVlqhaZHbogTiz9O9nHmCnZ/o3XZcPqUN784XYclr2EbeqywFdUzN7RggjqCZEqTAkAjxJzCODSEM7zzHMN+rLqF3XKMaMOfOvyhzDDGDRDEJkUVUMMNjKRHHy73sah6KXukp71tNP0pu6ZBsJ952lr+tZ3Tu8GNdy7DU9ujoeRMTxwcbERdLOlgJqTjzUJ7yfRZhJZHcjTNzoqGqIbEYLjjjZEJyMYYjDGIi3zPiLmvqRiW5an8vx+iJtn9pK0kmQaVG0vKdjqqxMfA6xi0U BVW/gTPI teJiBuM5sbyqWxP19w+7IErNr9S+iy6U7yQH0hTIOB96iqh8zngCZ0g6EYGeCa3U5s+CnkwwiA9we694b2zxRjXEYQggRwf/Q/IrW+OUzJfp8XNUw4plG4OrAb/wOOdKFQ/rE9eB9Iqc/dXcp+cm7DPOjb0Zt2eq1t7CGK6n77+X1V9Tyr0R4SV7BWZGl0DlTzW0B 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: List-Subscribe: List-Unsubscribe: Using pfn_swap_entry_to_folio() in __split_huge_pmd_locked() which is preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 94ef5c02b459..6139887933a7 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2432,7 +2432,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t entry; entry = pmd_to_swp_entry(old_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); } else { page = pmd_page(old_pmd); folio = page_folio(page); @@ -2443,7 +2443,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, folio_remove_rmap_pmd(folio, page, vma); folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); return; } From patchwork Thu Jan 11 11:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517211 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 E0F27C47DA2 for ; Thu, 11 Jan 2024 11:13:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEA7C6B0095; Thu, 11 Jan 2024 06:13:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B997F6B0096; Thu, 11 Jan 2024 06:13:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A88B86B0098; Thu, 11 Jan 2024 06:13:38 -0500 (EST) 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 968036B0095 for ; Thu, 11 Jan 2024 06:13:38 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 65145120B65 for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) X-FDA: 81666769716.12.0FAF372 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf10.hostedemail.com (Postfix) with ESMTP id EFDC3C0006 for ; Thu, 11 Jan 2024 11:13:35 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971616; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PGFFs+EsAYRIrfI1UJ/CXRS3kHNblZGP94QrpCixO9Y=; b=DhvAYro07QrWkdgh37jiRvvzKM/Aecn3HUD5WcZHWwCCwQsV4BRRwnr/hnLA8yLKGV8Tct SyZZfF0ZhGiuv3Uvdg2HJ8M86AQAQB3jKCsy8LH02fT364h0ffhMrM6TWkZpXmp3Nb6f6p KvTqXEl4xGEUhpPNwp0BYJUqqIZJ31A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971616; a=rsa-sha256; cv=none; b=ej3K9zHEx1RmEwPL1/SKnpgKB3E/9S1l4zDbZIZHkYbThWIlZLVGMB7xtmAF05xBZGJRWI xDFZSP3nfxk/ZQ4TL/ce7qYezfzE+l3RjuUWX7Kkl91jRKbkhnnQvSR56e69rbfj5WFR2H OWgMd45AJCYiXQ1BFm1EkZVs5IJXP3Y= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4T9hqH5C5vz1wn3P; Thu, 11 Jan 2024 19:13:15 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 368751400E8; Thu, 11 Jan 2024 19:13:32 +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.35; Thu, 11 Jan 2024 19:13:31 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 4/8] mm: huge_memory: use pfn_swap_entry_to_folio() in zap_huge_pmd() Date: Thu, 11 Jan 2024 19:12:35 +0800 Message-ID: <20240111111239.2453282-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: 6ug4hk3cdtu1ntqfmejr8miqj1ehmhe6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EFDC3C0006 X-Rspam-User: X-HE-Tag: 1704971615-811722 X-HE-Meta: U2FsdGVkX1+JeBfSGDYNYsRgCdZT2bJI4HT8NaGH+66F+5mUmq0pYQsY//z+zHyX3XmxNeeasyf7ZofeS1T86ZEOu8ELpkm35zo6z1dGDn93NEY4lViIinZO28u5+wOwUw5yitWJXMIDy6NM5cvWSU9X1FU141bu8O0PYhyxrk26K6SiD/0Gno2Srg2ghGnNDKfyn6fZPCl78J7jug9BJDzbRNCndnWJlUtU4kNO4e4YKOlgrAkcy4epOuSTGJELbD+LDGnCE4XTVZS+MmmFnfzfv5udARRygw9X9LAO6GTierMEO6pxEAAqsn6TU9OlCUb+3uNGYgAUR6seBD50/I4o4gpu6IYTVzLMOVgBfJPkdnLkiRbXuBcC1hO8S4hPNPvDYmttzbDR42SO1mQLdQN5Tp4aJL1SActspK7akEcp9S1tiiiP945Lr03ieRnYQyx0Xb0mrzle9IF9W291xRUUvAZJeAEcwql3rOXFPVAaV13qHtv3xEXK4seYifUIz4ponqYgfioQRu6ygBqlCyFSa1BdOKv0/KQiXdI9A3EFxjg7LLTnprEMXzzfGeDN3+8fotDUDFAq0tDVql2LQkrgdQfM245795l1VfhsM5nc59Nk3Zo2YvYIIXz513kSW3cY2CpfJJbueezcOLM3XQcXRX0IcixHPQZw/8GgRd3nqwn+1XKpky06ka/7lQ7qpbhbWuf/We0OQcJJYtZL+GjndDj/VdM5XgtyQdpv9nbXhHUYyfUC7ElYHb6s6jxyR2Z+7jvBDJlmK/TSj5q6vCox0mbY4ko9rY0IZoHeZm5vlgwDTBQlvUyi8v9ak4u7PecUutmFa5o2DwniwDJXx8NvpDoTFOOXxYozFs0a8x3W1mNMEwHV1QwmH/1cUfZIbiLO/79qYYGfo+brK++ewb3XAtwsYAhTw9IFpHLW+tzkZ0v5aEz29Gk5XsGojTcC/YClvZtek4krYCNb/Fb tzeacu9N wv7rcdNefWDTMTb4wKpVjbrANqBVLVaCK0Op433sQva4/g2ddwqEhyI8yQGB4pj7v7ttS6cQH7d5KAqOETgIK3G2GMVdZHOu1DCP1kJ23oB1ec82mBj2rGZETMPTKnckqRq6Ok4gkYFZiA48NW6SPhyrwmMeKtAuw9aXBibQL6+OIbKENdcQRbK6GKqu/u2MBFPOR 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: List-Subscribe: List-Unsubscribe: Using pfn_swap_entry_to_folio() in zap_huge_pmd(), which is a preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 6139887933a7..b024edb55855 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1895,12 +1895,14 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); } else { - struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); - folio_remove_rmap_pmd(page_folio(page), page, vma); + struct page *page = pmd_page(orig_pmd); + + folio = page_folio(page); + folio_remove_rmap_pmd(folio, page, vma); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); } else if (thp_migration_supported()) { @@ -1908,23 +1910,24 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, VM_BUG_ON(!is_pmd_migration_entry(orig_pmd)); entry = pmd_to_swp_entry(orig_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); flush_needed = 0; } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(tlb->mm, mm_counter_file(&folio->page), + -HPAGE_PMD_NR); } spin_unlock(ptl); if (flush_needed) - tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE); + tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE); } return 1; } From patchwork Thu Jan 11 11:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517212 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 DC572C4707B for ; Thu, 11 Jan 2024 11:13:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D85D6B007D; Thu, 11 Jan 2024 06:13:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1888F6B0096; Thu, 11 Jan 2024 06:13:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 028166B0099; Thu, 11 Jan 2024 06:13:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E91A96B0096 for ; Thu, 11 Jan 2024 06:13:38 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BC893C05AB for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) X-FDA: 81666769716.07.2ED7372 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf22.hostedemail.com (Postfix) with ESMTP id 45ED8C0016 for ; Thu, 11 Jan 2024 11:13:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971616; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ajY0hzyCvNzVEUMneA6KgjTWRYNBb1SkgAiP6foEfog=; b=rUhDv/AoAWIqHxMJjszOOAERsevkzRzVbxRx9Tud3OxopnjvIYr+tOsS9ZrYtCxt1Ares9 hyAwAvk6LZREX7P2mQrQIA42sOs+Ys9yKq0f71jY0Ew1fqrN+awjszAmPaDDXjCYTn4Jly 7ootkkBieaINImSPKkxu2pBKRD8iTUQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971616; a=rsa-sha256; cv=none; b=S0+MWnug0gbQay6lXGPDIFP3kTAqgpwQ6EyWl9qXHBvKpanSbbp5A9VNPMsewQ9LRZGBBf 2cOJunDarvSWoa7A4V9CY9frfKnsoOGD/znF0d4BGCqY1t6jbuSY2VqqfpQlv0UaOjEEPa J6G0DfgntutR81kYtgi7gg1MvSutc1U= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4T9hnq6kH3z2LXJs; Thu, 11 Jan 2024 19:11:59 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 9BC6214025A; Thu, 11 Jan 2024 19:13:32 +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.35; Thu, 11 Jan 2024 19:13:32 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 5/8] mm: memory: use pfn_swap_entry_to_folio() in copy_nonpresent_pte() Date: Thu, 11 Jan 2024 19:12:36 +0800 Message-ID: <20240111111239.2453282-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 45ED8C0016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yojah4ag7ycurqm6zefpx7xgwtif1bbw X-HE-Tag: 1704971615-212759 X-HE-Meta: U2FsdGVkX1+CbxD5EI0qLsY7VSghNpBIQhaahhnWsMZKzZSnSc4L4ku/OiOXWqoKlB6gHAE4ywsMVf083syL5gklJThaXVkCjNYbaHpOUcdxP+d4pGmyImlyo5pOYW+eb6+cNSKToEALHUxCZtlu/3lVH14o1vDdZ/Q1IaKABCmcXieEoZVWZqZlwGhXPIQpwwygricyEpOipN2HZ52cGstaWOxs7A27yB5sLw+HESJK6cLH+c/Pz38ADvginnKPsdMgBrYs/HKRsB+Lzu/BGX1HSh/jdvWbsq4vtMi7UToy2e9yaX7fZ3rTwPNNv2X4DEB/+VQReiNorwyoKjrvyVtJWW/L9PIoo4iXbUJdP//8uI8k3a4IB60soqPTUtXtmFSaICSJcAk3xACCdgRmyI6+mao+D+MKrh2kYMlLvwIf5UkkUHiVFT/9aGQ9XtglawmtyGaN28jPfp6uhrXszVugrwiyhXf+YULle1Un+a0mK9hQpMXaON9UAGmVbI1trBLHCqsth0/n9TCIbMT9AtZ4pZ2iJJHTqMR5xVeV+osieg3PV35TZbS/rzypfVuFpVkwPRL2noE12bZi1EdlOYS9y0WAMjtXnjomtaXHc91LMeUONIrBpSupjpEu4bHLlR/AWznUrMdbb+Vj0gK7mF15iomYFTTmr5kI8pdWCdhgdBVWsnlrtwPmV7JDZ2oArYkCTjMbL5FJ4EC/eFjfYZVRN5ifVpQPtC7HGi+/KnyDU9tenZAADaIPBbL3yxCPvl6YQhGXhsqTa364+UXieOs1z5Np2adBQ+PHa3ANeu9xLNHG4bsNDPRS5yCV1NY8FjzlsZ+NK4+hkU2hqg05WhvNb5p9FIXozVCuK/epQnWuni4yGvCV+gSR9Oqmw+Txt3UWJ+3EUeDZOWvoBGQ0S6uuippax23mxDKBTFMuEKtvpWYsctdhtfTswztZHdmt9RMnaGYNTUzt/vE+Nka EJsf8l4O vMVstnAEgiOKaOdlg26tllSdSIY1KsOTEVS4gdgGE53YbVEjzb3PDufdwNVHdD/tdD/vf3La4YzltKKhjHpCTcJMhhWIeG8KXNAeNt0Dk9vw0xDXtdQsysYle8LKb5JBf89DnrCpnCTkdccrREbXQ98E1zQQqINLZmhGAS+vsE63kNI3usgl4QU6fAlx4A13MivLU 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: List-Subscribe: List-Unsubscribe: Using pfn_swap_entry_to_folio() which is preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index c66af4520958..7b3fbeb21534 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -806,9 +806,9 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } rss[MM_SWAPENTS]++; } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); - rss[mm_counter(page)]++; + rss[mm_counter(&folio->page)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { From patchwork Thu Jan 11 11:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517214 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 15947C4707B for ; Thu, 11 Jan 2024 11:13:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92B916B0099; Thu, 11 Jan 2024 06:13:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 867A66B009A; Thu, 11 Jan 2024 06:13:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706786B009B; Thu, 11 Jan 2024 06:13:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 618626B0099 for ; Thu, 11 Jan 2024 06:13:41 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3DC681C0821 for ; Thu, 11 Jan 2024 11:13:41 +0000 (UTC) X-FDA: 81666769842.17.4CEEC48 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf30.hostedemail.com (Postfix) with ESMTP id 76D0C8001A for ; Thu, 11 Jan 2024 11:13:38 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971619; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=28kchYy61pOQgaqPuhwZoLEfvtIaQZbp4tv//nLxINU=; b=y4YsueK4OQkEFYgxWftSZBFOy3aJfSfsZZgbUo5/0YhDVGJsaXN6rk3ilWQuWfXUlbpE7n PHrL8agni0vGFn625tO+BVL66ygHrS3zRWGeQBkYkRmeGTHQmDKReo628Cly6NcxajukGk ctG+txzX7XyWgN2sOgF5sSeH0m4GjUw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971619; a=rsa-sha256; cv=none; b=Yw9n9kJ/JrcE8IyPpWnJyvOBBGJqFwg2cO44NC79kbsovstIni1vX39SWiNwfcjtdIgkUy BjBa5/DW64qMChF/bCS4hjCpGIzzau02eEUBtQCQmKPXs/RlGi1BpO3Ma2AGIkxHyc31+5 PUSgkz73p7P2cI/Zb5L2/HXMHaN2/zw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4T9hpt1TpfzNkrX; Thu, 11 Jan 2024 19:12:54 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 1346914040D; Thu, 11 Jan 2024 19:13:33 +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.35; Thu, 11 Jan 2024 19:13:32 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 6/8] mm: memory: convert to should_zap_folio() Date: Thu, 11 Jan 2024 19:12:37 +0800 Message-ID: <20240111111239.2453282-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 76D0C8001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: kq5ysueyt6y8fcke1aricur81zosd1jm X-HE-Tag: 1704971618-429550 X-HE-Meta: U2FsdGVkX185ev9osgszxbLLI5zK5szpeHe4fTuBx37VHr2Ul5yNgs0cjOWA03E5gcWiOJiq5BoYv1+xVKMNJ6kqSknEW0QibwmgvVwHSmq7neefdN9NRkSkNlMklwSeVOZxFTD5etA26ski4mKSIXCPFvCdEpfp82mdFzkbTdnm5thaumu5baRHb3Ubx9+a1hxUS4Cfab+4AppETLKQIV+/2BMntQhP43sZ6l2BAUNC1qnRZTti16Ubkdb0pDREkyHza4Mw+5UAqDu7AWIemV0NUDUJb4/LvS0Z2U5deue3SyhNn0pfiyC0FCw2LwI6zhpYd3zszasmmC4HGl5OpBQ5pZ4mPpC7jfVScjeH4bh+mBImQem5MzgOX2uASv9FbDgCy7dKRPd28IdY1iBhGzSoR5B15bH2SadUtq7NOPEEz4QyUzTPPn0e8mm9QEGCVZb77Uo2rYSvSkOv13P+EtKUXkvA35K7oiwv6R/TW2ILjjZ/XdgHwfxx80Wca1KPERvCM0BoxwzXmWNiTu+I9tKFZY4qUNh1YlpZWN6FoxhRmEPacs118I4IFGnI573DHPVAUdyCbfK5zyeJt1lROm2i8DFZ83dGm1QIZIq9eyYLEqd18rC+XFLaGL27kVpAMHlygJZOt8ODmO3BHh5S47fovXzFPtoanxoeyCouifH42SgEw0453txL7Ff44C+F6X+dpO6a2NrRRzXry8tf/ZUQ+9Vne5eQB30LhLEJT5C04y20XzZQx4dQePApjk1kF2gmVvdHXtDeoZA2kYipVd8Wj4Fz8bQLkPZ8ovmUIXye4XZtvImK2Fd54YfK1Q9CdUIdGTJOyfCcYoPr/7BLkQP6AwF4YQZbewg+GbEDO8L75+cpWpRl8Mx/FprDxGOByKyrwoC2S2oL+AdQgYuiACuJTnytwajB2rAPuGtfI1Y1r/6hKMsW8tusVR3/xzM1bErOklqfVuG+rqqYtEw 85BCSXxE 2OE80pqh8PKRQ2VzW3bk+B/ol2jngP9oxpcg9x9MDi4kZTbVH8anIi3tT/42rNBMpG87BXe6Pva6/uONKiWcUrf2ilsqk9DMOFsbVK8/0epQ2rNvF6vzxh58N9+ksbMTHI8hQVt7qiJ5y0gpw/eQ5laurkyvcqKOIo+P423tVOpg6GnQKcSvmNMFsYuc3BfZ0xyGL 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: List-Subscribe: List-Unsubscribe: Make should_zap_page() to take a folio and convert it to should_zap_folio() which is preparetion for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang --- mm/memory.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 7b3fbeb21534..afba8b156457 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1369,19 +1369,20 @@ static inline bool should_zap_cows(struct zap_details *details) return details->even_cows; } -/* Decides whether we should zap this page with the page pointer specified */ -static inline bool should_zap_page(struct zap_details *details, struct page *page) +/* Decides whether we should zap this folio with the folio pointer specified */ +static inline bool should_zap_folio(struct zap_details *details, + struct folio *folio) { - /* If we can make a decision without *page.. */ + /* If we can make a decision without *folio.. */ if (should_zap_cows(details)) return true; - /* E.g. the caller passes NULL for the case of a zero page */ - if (!page) + /* E.g. the caller passes NULL for the case of a zero folio */ + if (!folio) return true; - /* Otherwise we should only zap non-anon pages */ - return !PageAnon(page); + /* Otherwise we should only zap non-anon folios */ + return !folio_test_anon(folio); } static inline bool zap_drop_file_uffd_wp(struct zap_details *details) @@ -1447,7 +1448,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, unsigned int delay_rmap; page = vm_normal_page(vma, addr, ptent); - if (unlikely(!should_zap_page(details, page))) + if (page) + folio = page_folio(page); + + if (unlikely(!should_zap_folio(details, folio))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); @@ -1460,7 +1464,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, continue; } - folio = page_folio(page); delay_rmap = 0; if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { @@ -1492,7 +1495,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, is_device_exclusive_entry(entry)) { page = pfn_swap_entry_to_page(entry); folio = page_folio(page); - if (unlikely(!should_zap_page(details, page))) + if (unlikely(!should_zap_folio(details, folio))) continue; /* * Both device private/exclusive mappings should only @@ -1513,10 +1516,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (unlikely(!free_swap_and_cache(entry))) print_bad_pte(vma, addr, ptent, NULL); } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (!should_zap_page(details, page)) + folio = pfn_swap_entry_to_folio(entry); + if (!should_zap_folio(details, folio)) continue; - rss[mm_counter(page)]--; + rss[mm_counter(&folio->page)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only From patchwork Thu Jan 11 11:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517216 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 D5166C4707B for ; Thu, 11 Jan 2024 11:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13E386B009B; Thu, 11 Jan 2024 06:13:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C5956B009C; Thu, 11 Jan 2024 06:13:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E80856B009D; Thu, 11 Jan 2024 06:13:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D49216B009B for ; Thu, 11 Jan 2024 06:13:42 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B01F9140CA9 for ; Thu, 11 Jan 2024 11:13:42 +0000 (UTC) X-FDA: 81666769884.19.2323342 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf12.hostedemail.com (Postfix) with ESMTP id 1206F40012 for ; Thu, 11 Jan 2024 11:13:39 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971620; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B8KWnsevHVsv+Uq6/BJzxKrvTn/e00meplDlNP4dt2c=; b=vf4asVynxV+zRrWxMUGAAW4gNqYcboZ8Q716a6Kq8ufAoaT3YOSerueqTfrt5wAkgDI1Yc z1Ba9/6P5MEa9oPhMSqmO0ioDnOcnoXxZLnXeGCOqUWLxZY58YeVFDh14zRV5D+OEL7Bmz FVQ73o/9CqL7S+khlZzpXKbvhsyaYF8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf12.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971620; a=rsa-sha256; cv=none; b=xas3xBiWT2gCzrWer7QcrZc5svob9T7dmd1s2rPzof/38YxAQXAT9yhF6WiehEb+ol3SkO JrfZo5Xa4/NKjVJ4L1dOChb5uiHVcgyxUn6B67YgBVlfJyfg+p3g99h9UZ5TGLixj0R0Le tScEhQHL3QfUfsco+ewF3P4AKKPA6Fs= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4T9hpc5HTZzWm4Q; Thu, 11 Jan 2024 19:12:40 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 7DC5C180077; Thu, 11 Jan 2024 19:13:33 +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.35; Thu, 11 Jan 2024 19:13:33 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 7/8] mm: convert mm_counter() to take a folio Date: Thu, 11 Jan 2024 19:12:38 +0800 Message-ID: <20240111111239.2453282-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 1206F40012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gqgcdt9q4oa3dzhjm75g3em9uq94mp1y X-HE-Tag: 1704971619-774576 X-HE-Meta: U2FsdGVkX19ev93NMVt63wejkXjD/5IvtQ2Ll2gNIBC9EuiqGQplutQtz541Ll/NgFfNviCEFauj0ozbdld5x0MdW18HpWsTQywm6jT9F3hf3xTd8L/u5FSQhWcigUo2SR6oqneli5fzMvvNzzMciVBoH6kt6hFEZ0xb90fZNL4wtijsFH/AcCRSxCSFQQO1w14djl6wr6HmFCleU8BmfNfF2rPJBLuani+ogMZ11YQaXPk/XHLXAmgmR0scEhbgrFDw4ip2dn9JAl03j5AYR6OZjINzOPAJINW3vI8FIfCgRPQJYf53W3WLqiOpgcaYxuDtOSV5XIMh7dwo86L26E0lx41Uy8cmtLyrbc62+D7Xth63RKwp7n6d6nnCJ5fwXGzG2u3cweUeNHFNyJWfcGvrcCCRD4V6tKMIqY7kMmd7kgwD9rgNvPW08PTHWP1+bCuvgEFaVyjhpJpP9u7dGsjUxBQ/isjo9Y98ruQqI+3s0vqY7ymC4OegaPfMmT4zMux259EDFFhwyAjjpOYiCV7GOjM/wgWRqOm2XuD5wPK3FjDJ18Ow781dN0lpWsMbcBhes8BP84K57eHOGghN5j7VBOufeWQwKbu1n360aBR7Sw2uHz9yro6eVOzAu6TLoCf42cwRfvQd6oGgAr7/779HjvMmI8kIbi9h3Ui8Eb0hMwEFqKLWx4OtDPBdnvqemnpfU9plv+GcVHbnzM2ef64rbx5Lo+t0T7AxW/ExSidSaM3BAgRQ1KKLwVIagKSHBLAysAuhHBgG1YnJwZc5yHzuoKW4z5OFa5hNWzrvY3iSg6HrtFEqbnOXh+EOVCaMoyzCax9QEcVgNZ0z7wxCWTvlKWrVP0LeWxaBn2Nm2kvCITORNHeJGL9IwMmme8sme+6ISPst11O1eh7E/8/ZJPWmTBuojIKqwJkN3ddmLGf7P+8/8zktT54QOkl0nIkUKucwM1rw0+C+RcsK4Xn pPQxF2Vv FMhFEWJgj4PfHeJkJ+BA1Wb7rAVyoZR0+PqSNZ6n4PJtsBM5/eERo/XRok/AljGXd504QxJuKtHWCtUliiku+k1SSoX55s3VLFi5YaDD+WBQUdJRJqTBddt/V3BDteLK5sX3mLI7A6vsqZ0X2kffXQsLGAotMUvgnQJxyYFF7VqRkfgAy2d7rizZVc5U7mM2q+2T7 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: List-Subscribe: List-Unsubscribe: Since all mm_counter() callers with a folio, let's convert mm_counter() to take a folio. Signed-off-by: Kefeng Wang --- arch/s390/mm/pgtable.c | 2 +- include/linux/mm.h | 6 +++--- mm/memory.c | 10 +++++----- mm/rmap.c | 8 ++++---- mm/userfaultfd.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index e8fc5c55968e..4c92b08e3c59 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -723,7 +723,7 @@ static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) else if (is_migration_entry(entry)) { struct folio *folio = pfn_swap_entry_to_folio(entry); - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } free_swap_and_cache(entry); } diff --git a/include/linux/mm.h b/include/linux/mm.h index f5a97dec5169..22e597b36b38 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2603,11 +2603,11 @@ static inline int mm_counter_file(struct page *page) return MM_FILEPAGES; } -static inline int mm_counter(struct page *page) +static inline int mm_counter(struct folio *folio) { - if (PageAnon(page)) + if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(page); + return mm_counter_file(&folio->page); } static inline unsigned long get_mm_rss(struct mm_struct *mm) diff --git a/mm/memory.c b/mm/memory.c index afba8b156457..2f858263e5a2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -808,7 +808,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } else if (is_migration_entry(entry)) { folio = pfn_swap_entry_to_folio(entry); - rss[mm_counter(&folio->page)]++; + rss[mm_counter(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -840,7 +840,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * keep things as they are. */ folio_get(folio); - rss[mm_counter(page)]++; + rss[mm_counter(folio)]++; /* Cannot fail as these pages cannot get pinned. */ folio_try_dup_anon_rmap_pte(folio, page, src_vma); @@ -1476,7 +1476,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (pte_young(ptent) && likely(vma_has_recency(vma))) folio_mark_accessed(folio); } - rss[mm_counter(page)]--; + rss[mm_counter(folio)]--; if (!delay_rmap) { folio_remove_rmap_pte(folio, page, vma); if (unlikely(page_mapcount(page) < 0)) @@ -1504,7 +1504,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, * see zap_install_uffd_wp_if_needed(). */ WARN_ON_ONCE(!vma_is_anonymous(vma)); - rss[mm_counter(page)]--; + rss[mm_counter(folio)]--; if (is_device_private_entry(entry)) folio_remove_rmap_pte(folio, page, vma); folio_put(folio); @@ -1519,7 +1519,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, folio = pfn_swap_entry_to_folio(entry); if (!should_zap_folio(details, folio)) continue; - rss[mm_counter(&folio->page)]--; + rss[mm_counter(folio)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only diff --git a/mm/rmap.c b/mm/rmap.c index f5d43edad529..4648cf1d8178 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1780,7 +1780,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -1795,7 +1795,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } else if (folio_test_anon(folio)) { swp_entry_t entry = page_swap_entry(subpage); pte_t swp_pte; @@ -2181,7 +2181,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -2196,7 +2196,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } else { swp_entry_t entry; pte_t swp_pte; diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 216ab4c8621f..662ab304cca3 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -124,7 +124,7 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, * Must happen after rmap, as mm_counter() checks mapping (via * PageAnon()), which is set by __page_set_anon_rmap(). */ - inc_mm_counter(dst_mm, mm_counter(page)); + inc_mm_counter(dst_mm, mm_counter(folio)); set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte); From patchwork Thu Jan 11 11:12:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13517218 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 082A1C4725D for ; Thu, 11 Jan 2024 11:13:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD95E6B009E; Thu, 11 Jan 2024 06:13:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3BA76B009F; Thu, 11 Jan 2024 06:13:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B5A56B00A1; Thu, 11 Jan 2024 06:13:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 67FA66B009E for ; Thu, 11 Jan 2024 06:13:46 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 30AA2C0A15 for ; Thu, 11 Jan 2024 11:13:46 +0000 (UTC) X-FDA: 81666770052.04.3302235 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf19.hostedemail.com (Postfix) with ESMTP id CD2981A0003 for ; Thu, 11 Jan 2024 11:13:42 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704971623; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=67896kKKZq+e8pFZOsbKwompVoQWD/wMy3wcQ6ATEuM=; b=Fh02Bvm9TTwV+v4iihZf4WglDPdIV0pfSlP3JNlXXZ5QC8GWceICgNnbNBZxRsXHw2roUX DwWrLP8bRMQywQk5H2/divmMFe9s+Y4J2X0yOejlw93R1p4COaZNaDJBTIU2+jvZ+ILedi s2rF+Q4myn8iQQOaRbjP3wGNrEH/emw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704971623; a=rsa-sha256; cv=none; b=a6IM51ltq49ep9nOfGLhlVveb+Z2kdtjrEYdVDd9V1osuJmY6FJOmsltD+BgcG4PdDSbdZ OE1zkAb8lHWkZHSyClngeaai60Qqtic12zUZbuE5K7jiTj8kEn2Gy5Y/THZ4wOj3GLX6Ti mfFSVsVyUM9ryTH8WRP5FkYYro/t2Go= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4T9hkt2xsVz1FJFx; Thu, 11 Jan 2024 19:09:26 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id E976A18001F; Thu, 11 Jan 2024 19:13:33 +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.35; Thu, 11 Jan 2024 19:13:33 +0800 From: Kefeng Wang To: Andrew Morton , CC: , , , , Kefeng Wang Subject: [PATCH v2 8/8] mm: convert mm_counter_file() to take a folio Date: Thu, 11 Jan 2024 19:12:39 +0800 Message-ID: <20240111111239.2453282-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> References: <20240111111239.2453282-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Stat-Signature: apngdycwti61itxpsf8a53swo3q86tdj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CD2981A0003 X-HE-Tag: 1704971622-808022 X-HE-Meta: U2FsdGVkX1+sCjXGGw/2yR849Na2IGe9PUlhMLqVtpW+8qoMQBHNiQIKmywb/mf0v8BAt0z49PvE5M5sTjjd6QzfMoynGQ/K+U2yx66kUxZGr+EqOD3b2hf/z4QyRqsO4BLKhwJNb7rm89pCyBTKuWG6ppneOLIMVG/meaU5E6Yn3HeHa9evg36QNTley4pm4P1BM0r1cxWakCQIlOQzlVrzN6sKMvohMfzn3COAmvFJpGCT4ODf4cijmEgew6r7X4+xw0IhEOZbIDbJCCFYKCJyAJyPOaxz9oqBvus/Ulm2PrW0mnd66BTeRcSx0VpBGVkXxBAC4KeZzfVjoAQa6z1+phLTUF5vYHmCZ0XebMFx+1E1TWPR8zcs+bk0jhDXRwgsErAZP+pxI1lMbskI2j7zTRdv1nhwJYgXQhLmyLuHzNUykqF/ycx63Q9xomgUiCEWTgiN2oMuYZl0bIkE/seHKoBsMEmW9VsB5pxUhHEmb9ik3j6KSQE+0j63YHVzy9xqhxRpawa5M8/Rao2Z7D5TfZKljeriXlukx42fVxTx0HSGpSIDtsqwwYnB9riVd35L/i9KE2XFSMbGSaqTDOFTg/78jQZjWvC4mS1bMBT3qHr8aeskG5IkGjSJ84CaSwFP5551E1j/k31j7m/Z8qjoh7+cTvO3yniwSS0JJO9Ud/7Loxqza9EF5MdNqjJ9GaEjJiclHJR0kGYA99aNdY033iAgWLrvAn8TNY16kYFHPSQPR7zzTfXODhPa1cntZuSA9ofzpsrZ9AXqiiLFDYKVBL/7ZMrzZiGOF83yo6T/MuU+qLxsFP/MLhBsLEgw4uAGwATSPFAix4sZixRmOz67L+kEYZ5GIwEm3KJAo6AfDirVvRLw8vLbHybO7YTdzbSSdU7ODt9cCv2W8FW8qD35sK3YxgYKqHIfyWfToUxI0MFMlqccL+Gl9Fd/8i109hQL8rGNCtCJ01VNaGm Zz1nmSee PH4MTLfzLtI/PUkZwRpiUg/ST3CKrQe7teftoyh+hd6pByDpHT+auCjLBggSbyEyrf9yVm1E+SNeVZCWPDn87sdNI6xgw7H4iqKmQJQMkBRvNK9nuOTOubANuTeva9J6OLHVbOgqK3to/04TMvhQon9mnxztzmxsLD9+cm3yJFjrjkXyZSP9IcVvEhF6kiV0brbBH 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: List-Subscribe: List-Unsubscribe: Since all mm_counter_file() callers with a folio, let's convert mm_counter_file() to take a folio. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 8 ++++---- kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 4 ++-- mm/memory.c | 10 +++++----- mm/rmap.c | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 22e597b36b38..ac6b71cbdffb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2595,10 +2595,10 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) +/* Optimized variant when folio is already known not to be anon */ +static inline int mm_counter_file(struct folio *folio) { - if (PageSwapBacked(page)) + if (folio_test_swapbacked(folio)) return MM_SHMEMPAGES; return MM_FILEPAGES; } @@ -2607,7 +2607,7 @@ static inline int mm_counter(struct folio *folio) { if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(&folio->page); + return mm_counter_file(folio); } static inline unsigned long get_mm_rss(struct mm_struct *mm) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 485bb0389b48..948c2e064ca3 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -188,7 +188,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, dec_mm_counter(mm, MM_ANONPAGES); if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(old_page)); + dec_mm_counter(mm, mm_counter_file(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b024edb55855..f40137f927dd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1921,7 +1921,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(&folio->page), + add_mm_counter(tlb->mm, mm_counter_file(folio), -HPAGE_PMD_NR); } @@ -2446,7 +2446,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, folio_remove_rmap_pmd(folio, page, vma); folio_put(folio); } - add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR); return; } diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2b219acb528e..fe43fbc44525 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1634,7 +1634,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, /* step 3: set proper refcount and mm_counters. */ if (nr_ptes) { folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file(folio), -nr_ptes); } /* step 4: remove empty page table */ @@ -1665,7 +1665,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, if (nr_ptes) { flush_tlb_mm(mm); folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file(folio), -nr_ptes); } if (start_pte) pte_unmap_unlock(start_pte, ptl); diff --git a/mm/memory.c b/mm/memory.c index 2f858263e5a2..033035c58b8d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -966,7 +966,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } else if (page) { folio_get(folio); folio_dup_file_rmap_pte(folio, page); - rss[mm_counter_file(page)]++; + rss[mm_counter_file(folio)]++; } /* @@ -1873,7 +1873,7 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, return -EBUSY; /* Ok, finally just insert the thing.. */ folio_get(folio); - inc_mm_counter(vma->vm_mm, mm_counter_file(page)); + inc_mm_counter(vma->vm_mm, mm_counter_file(folio)); folio_add_file_rmap_pte(folio, page, vma); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot)); return 0; @@ -3178,7 +3178,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) if (likely(vmf->pte && pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { if (old_folio) { if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(&old_folio->page)); + dec_mm_counter(mm, mm_counter_file(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } } else { @@ -4463,7 +4463,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); - add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR); + add_mm_counter(vma->vm_mm, mm_counter_file(folio), HPAGE_PMD_NR); folio_add_file_rmap_pmd(folio, page, vma); /* @@ -4526,7 +4526,7 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio, folio_add_new_anon_rmap(folio, vma, addr); folio_add_lru_vma(folio, vma); } else { - add_mm_counter(vma->vm_mm, mm_counter_file(page), nr); + add_mm_counter(vma->vm_mm, mm_counter_file(folio), nr); folio_add_file_rmap_ptes(folio, page, nr, vma); } set_ptes(vma->vm_mm, addr, vmf->pte, entry, nr); diff --git a/mm/rmap.c b/mm/rmap.c index 4648cf1d8178..1cf2bffa48ed 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1903,7 +1903,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * * See Documentation/mm/mmu_notifier.rst */ - dec_mm_counter(mm, mm_counter_file(&folio->page)); + dec_mm_counter(mm, mm_counter_file(folio)); } discard: if (unlikely(folio_test_hugetlb(folio)))