From patchwork Fri Nov 3 14:01: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: 13444563 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 0E048C4332F for ; Fri, 3 Nov 2023 14:03:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F325728001E; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F096328000F; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0E2A28001E; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) 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 C1E6F28000F for ; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 04A931A0E32 for ; Fri, 3 Nov 2023 14:03:52 +0000 (UTC) X-FDA: 81416811546.12.C835C0A Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 493A8120027 for ; Fri, 3 Nov 2023 14:03:48 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1699020229; a=rsa-sha256; cv=none; b=NC6vcl8+VpunQgqm9A03ClbTNgFzYH5vHGachM/r+tiGA8vVzoVBtoP2VB+AoKPcyfnHTw m+J2FiokOOLzjPSI9ZKSSGRhKtyKXLWUibrUhmgjTPZ8u3JlAt5AXo93ESXYTgFZ7+xWoK m8zr4n/QfENldBM1OUUKHl9fQPQKjGw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.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=1699020229; 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=8+J3qRxOBK8DBKSlvlbT9kzwQm4rIUsyVkkfO9bjcqY=; b=lJVggbaMfA8uGaJAtzDLyYn4h53zug3uq0TGAH5h94+ryhI7bNtQIHt48hDn8csBZzcoxv Op3Dv3tEtv1958knm6dhfIuTxdapJJDlZ+UIMGQbsKj4OOntIirPUHPkMIqvTNBzeFg/kb QJJ0Kx3reFQj21W/SHnaVoCQKG8jaME= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMMsk23mLzVkbd; Fri, 3 Nov 2023 22:03:38 +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 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 01/18] mm: add mm_counter_folio() and mm_counter_file_folio() Date: Fri, 3 Nov 2023 22:01:02 +0800 Message-ID: <20231103140119.2306578-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 493A8120027 X-Stat-Signature: obu8icwhbg38b4rrwoa6dzamww37pnzb X-Rspam-User: X-HE-Tag: 1699020228-657259 X-HE-Meta: U2FsdGVkX188f9rn0JDOQTD3tWHjoJfd238itw/Xtw5jkBW00jTpF615p/b2SD+jfrsbkqjRczX05T1HeFfBmBS7FO3pXDQz9+SNz//z5bVsj60vRm1ozSaT+N5cPtDdOM37lfhNJGdMpqGJHAlHPWl0VIiaV48C3bWPSZzKg+yuRoffMr0itMAgjw5OKTxANg/iZ17xWOO13rQsFgTyaIBFxzTc/nWrCZjG45aWyiNwllRddOMFM7UJfeGi/UM9tQjmbxvk/oLi5SDINCYwrAZn+kC6iCbWBapMotBZxWy5qjtOvf42tbbqVmsreMc9cbEoFN68KNz3OB7SZK5F3bbriMScIsnDbsBJ+naQdvT8KRkEkycWCKfT8po3LdkSuWJXaOA0J5syTVwHvMIIdc79W/nBxtUBkAte17SD0vQ368xyvVkJgTRy3RR5Nknp/4eyvY2f+pfetLL9xOzSPQx6GFX0pY2+juJaw0OhQMLaqimCC4kUNOjjmhDXleGeqk/M/nhMN43Kt71DwkPnnmtmHTa7lkitSIQVLvyyJjgmwH010/rJGHGwnADtsKZ7XRJPtXL+0NPho+pk+T5A3BcaSUCkRzyd5muJA92xTnRBD3Dg6g2xKxZ2a3gU1zfXZAZIQEeSHWnXDB1ZHAov/ZsiP6EzVwA1ahsVt1+fYGKIVfnyjYsZZ1fvpjrmTu6vw47KMYuvWh2gW5rtSgwb8oRMqtIsDkdPlL0H4yo9GrFz1Ad6TV+Hp71wLgiOc9PAJhK5Cppns9EYYFHKLp3lGDeGOMR1bnytX81gwOfdHaWd7Lk+5Kg4rrOWrb7uukqeNcylzexmX4MFQvC+Yxf64Qwkkvb9Og8HoZo3GqvIwwE1xvZRMPCITrE7ZJNt1pvKdX4kexswgTw3dlQXoYRyAcFhlJcQ4KLZMxYXk6MOK1/hRr6NV2r4OpLpLO1OPskuYSlwYZW0LrKYPt3Gl2c eQTmhmCa lkU7CuOwMwCPyNBO+zytzPb5AAnNs/qNi75dW3TVQYe7LgcKakrhip4fJTyttrwJGZKRHBYRmols/pWvm4MciPct5QHzVHM5XbvPQYjhrBQbJXS7ixH/S0TC2/BqHhcCC1ZDIXvpXSRE29Ti/e3EgKyfeQ4qTh2J5Mjd/tdWkyeoV9kME/fh3bqErZZnl7by0UmJy 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 two mm counter folio functions mm_counter_folio() and mm_counter_file_folio(), will be used folio conversion, and it saves a compound_head() in mm_counter(). Signed-off-by: Kefeng Wang --- include/linux/mm.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index caf13e94260e..f5f76504b212 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2583,19 +2583,29 @@ 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) +static inline int mm_counter_file_folio(struct folio *folio) { - if (PageSwapBacked(page)) + if (folio_test_swapbacked(folio)) return MM_SHMEMPAGES; return MM_FILEPAGES; } -static inline int mm_counter(struct page *page) +/* Optimized variant when page is already known not to be PageAnon */ +static inline int mm_counter_file(struct page *page) +{ + return mm_counter_file_folio(page_folio(page)); +} + +static inline int mm_counter_folio(struct folio *folio) { - if (PageAnon(page)) + if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(page); + return mm_counter_file_folio(folio); +} + +static inline int mm_counter(struct page *page) +{ + return mm_counter_folio(page_folio(page)); } static inline unsigned long get_mm_rss(struct mm_struct *mm) From patchwork Fri Nov 3 14:01: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: 13444565 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 2F450C4708E for ; Fri, 3 Nov 2023 14:04:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB21228000F; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9CBA280021; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 964C228000F; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) 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 88747280021 for ; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5422912074C for ; Fri, 3 Nov 2023 14:03:54 +0000 (UTC) X-FDA: 81416811588.10.CF6D0CC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf03.hostedemail.com (Postfix) with ESMTP id CB57620024 for ; Fri, 3 Nov 2023 14:03:50 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020231; a=rsa-sha256; cv=none; b=N9u0CGPj0YFUG0FDNMt08DSXCPM0nNUTYXfi1jEJ+hzZH61wsn5Dwa6v8DLxuET5MZWDSX XhadTJ0cNIKRzN8Oi3T8qQ+eFu/7g5JXg8ugeNn6mgwjeBl1eSO9VUSd+RvzmyUF6Vslu1 9UrquabckjN2THXs4P5XCVH/OmI7uZY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.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=1699020231; 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=KcfQLTNeQLYbZjj3Vfq0pzF4qAjIfyux433LLT/5H3c=; b=fGS3ToFBfXMdYfQpjyuGPbUF6Dz1l+IFtcEfsBsUh7yE1kOuI6Fi0GHTAik00KJ3W+Y7xV 8S3hU6+bUSm+PPxy1PGZgdCEqgIvnUVKL6tM6PeHNFdhGm5hrcfeYUEqeZ3+xvg/UCpsQD KEfxYmneWBF+iFAFG3NgQFH2lA4Uv1k= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMMmm5jbnzMmKq; Fri, 3 Nov 2023 21:59:20 +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 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 02/18] uprobes: use mm_counter_file_folio() Date: Fri, 3 Nov 2023 22:01:03 +0800 Message-ID: <20231103140119.2306578-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CB57620024 X-Stat-Signature: f43jztdr871o6xjpcjiuesd9i9xgzpkk X-HE-Tag: 1699020230-226399 X-HE-Meta: U2FsdGVkX19lyGOYpcKxDwR1mQTYNjAjbpfkZrKCpkjL0bF5+o2cKL6MmJKRdOfQVZ8TEDHqjL5R3x1AcITnmhUIjZ+sEPWw/9BJIeRlSsZ6aqJQbhedHzywrbiXqANso10/NV94b8LCmx0P//BxG1Me+oC1KvZrCzS7wgKyAbpnF4voP7H+VBIhh9oMEfLOgKG8vzI8MS6DcT/cukQbe7X+CtytG3FYeWBZl2PEFs+StZ/ePD7M6v+/fMl7ZCFp/h3qdz00lnB9rzLCWDJniiQ9pR2IzL/Vdd516/+vbHADWGILMF5Il0xUlXYLbD+zcORrsctqAzykEAOk3P5Fcy50g5UWp2ccp7P8IgcV1Dla8ns1ejm4F8GLgQUdglu8wU43BtTar6xaCvqtkYQF4d0M3iy3a7+x0Jt5r8kQrLprGR+SlfRHNf2M3jaGKDiF5uLfU7a7DAt7TBXnRjK+8auE+l+dgRo5rGwT0Z1uWWtJUUpm9TWTayzX81y4528BBIuDKnG1AYyYY6MugfZZs0dkJaPlLuRvbI3/QHS60AZt4op3d+nfiVI6ZNEgAcnP3KkaC7FasHpP1SZ0/UmDyFaXNGWu317rQyuS8ZnW9VvfFljjoVOQqKuy7IxE9VFt95BGLpgcbgEJ5/inxotI8fhwDcwsE5Le7VwfRlZ1C2s+YbzALUG2dcrb1hcMupDKT9T6/RhS82q36xWiQOze/z+JEAhzrPGYVcbjDnUMjDm7mGogSesDMW3awOn1ic6LY2b66XVvmZmyyH6qlRM0rZwSWdTTaL2EXu66AYyyG7o2LOnL3JIUZs4mVbUIm0AWbTdrCeMWlh+2kKMwTm53kmHfd4d0MJDgjbEPI1ui/vttKbqWFsUuvbBGznCY9VMsmBqIkJWLs8VWclfKwl8uSWx1ECcGep5Le0yOTD+tnW/jHIND3npxMXILgQYLtEz5O8OWvhUr2eUEWRgJIxu jwGUEfrE g0bRu11oxEM8mlYiaMlF4PvlnCk9wGzz4V8/D5DnNlNi+gxALzz+HtdzUgt4VikKnprnShihoMquXS1Gmz8EV6k5vGPEdPv2nD65btRTjOMUVFNH1ogjn5k+UAdAJtU07bjWqhOaeV9Zy8XLkhxyY6xvm9FabTTW/JWXxniTIuvnIQL2qLIrJ4bE+Ebxn/k+4pJoy 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: Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- kernel/events/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 435aac1d8c27..e2d3c89cc524 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_folio(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } From patchwork Fri Nov 3 14:01: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: 13444564 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 346EFC001B5 for ; Fri, 3 Nov 2023 14:03:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F5B0280020; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67EF328000F; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56D05280020; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4A99128000F for ; Fri, 3 Nov 2023 10:03:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1895CA08D5 for ; Fri, 3 Nov 2023 14:03:54 +0000 (UTC) X-FDA: 81416811588.16.8946090 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf02.hostedemail.com (Postfix) with ESMTP id 589BC80030 for ; Fri, 3 Nov 2023 14:03:48 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.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=1699020230; 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=vvPUq4pcW2H7sJpunngQLYXQwnMIWBCnxO4qS0TOoUQ=; b=U6qUH20LdpV6Kja50SFTub5ffhl/DTBx/EXk1pR7T0SH0xIc1NxDztyQYMrHGQrUzwEpmQ GjZXNYXGJKFPL1xJLdZt/rGpOu/Y3GgIQAVkwoHU8Uaq5tRdXqXl7mdOWVh2kg36LshIzf dLOepgzUd8Mim57eMs1JWqaxOXkEZdo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.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=1699020230; a=rsa-sha256; cv=none; b=5kP2FcwN80JetS6B+8DxqhfMtFgQVclNb7XI+gJNR3gzde60wirV68dpFL1ACA1ClHeGjd Orj5u74MUuU+jq15Ym/nKeRolGyq9fscHtULtc996v3Edhrn2NghaA8t4f3WJXtae+G/vB GR7z24oj0bbOMRNDHbhN7LmJ/V/Jgjg= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMMsm4StwzvQKT; Fri, 3 Nov 2023 22:03:40 +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 22:03:43 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 03/18] mm: userfaultfd: use mm_counter_folio() Date: Fri, 3 Nov 2023 22:01:04 +0800 Message-ID: <20231103140119.2306578-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 589BC80030 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: idzai4zd3bhy5ye6ggi3fg585gdbtqxj X-HE-Tag: 1699020228-872574 X-HE-Meta: U2FsdGVkX1+FJb9O+dpcrPTG9rONS1JIS71/13K2RkI9zCQqF25qF6Q/C/QMMPfV4sKKuKDNADFXaejYwyjTvqtTYPyMltijwO1XUGcDEuAYvZOaowT4SgGxzAmzYtq6EbOoTCBCoHyf76WXfVe5Zd+3yFmY9YcwdwsrWojtJw72l7spAs+/rUgM6SYuq/s7Xd/dYhGF4tI7GXz2xMR2cWXd3G3ZtTmfuiIYrfTk01LH/w38/FNlAAdRbJY+qrOIlEwcICzw1T5kGSHOScNNPYbf1MezMN7WDEuW0rgrvS555u8fkYE3jRDix95xOBsSNkpYMdmh3yS9vM5cA1I4OOk27cWTJTN4QbTh6nXL8GMBdXvXvPT8ErtGgt2lNHclff8V/0MOBdio8S3M/yYjDZ0gctDyoqXa7HAVBrW/KWe1Bxd/qrx02Do0D+C6RtsE9ZwMqW42qJ6+CR2jYBXy+KPuaglF0j/+4v3Ijc1CcOx5jwSfOg+Avzsspf4UNrM25PVELyGYjwW2iO9vi1fArS5AOL/2zLv7xZB/40sxmJJli2k0pkL0CzwPQytH3aN4MyjgTT1mIJXOyBia5qWWfYA8WACOCWJJRHhG9t9TLSnYwXLpQWpOn8htiFxZEtNrqWvPO7Yk1NtCDn+6qRKzWuc/Q7gbiM8X0ZVHzDcCbM56st3a7e9u8sMeLrsqUqlrj/5Hmw/y4EryNzJnP8n8eEZdhjUXLxyffHcPzPEQTFI7hDIAIH6k1gQbqAgK9HLLAYfYuBW6gRN2N1Jcr27ktCyQ9MttzeG/3t5rK+SvEpVG+krapYiJgty+CQBM618dpy7XuOa/UjfL3PxbXyfGPVYMKLHVjTHJ1LCDLXnsLFxX40A1cA2t296BDsE3hQ7lToJGppMFikDyi33GkoZxWPGFQZa6f/iks2rSy6aAZoODtXTs3pc5HVKVzD5ebuZzkNrRtiSJgLPS6g/7nJk nzvh1r5z +p9k1vJsVVbpruR9yrzb3Be9/vgDkz79EgWrct3pLpANHtpa9Ajdl9QRSyvGYXmq9Vdlo11qyj1EUPHXCtzTnTBm8TkRTIlPrUZ3KCB5H6LyVBTSoLupBVg6wSrCbr6ZrzgBa3B/NO11xWT8DDh8tYccnIcZ857DfXW7oiKLt2HsSn8OxOubsSGh7eBNDyPHBCK35 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: Use mm_counter_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/userfaultfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 96d9eae5c7cc..e47aa6c91ef8 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -121,10 +121,10 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, } /* - * Must happen after rmap, as mm_counter() checks mapping (via + * Must happen after rmap, as mm_counter_folio() 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(folio)); set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte); From patchwork Fri Nov 3 14:01: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: 13444575 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 98636C4332F for ; Fri, 3 Nov 2023 14:04:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AF6B280029; Fri, 3 Nov 2023 10:04:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25FAA28001D; Fri, 3 Nov 2023 10:04:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 127D9280029; Fri, 3 Nov 2023 10:04:37 -0400 (EDT) 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 040AD28001D for ; Fri, 3 Nov 2023 10:04:37 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D187940ECA for ; Fri, 3 Nov 2023 14:04:36 +0000 (UTC) X-FDA: 81416813352.13.38D0781 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf11.hostedemail.com (Postfix) with ESMTP id 1A77140021 for ; Fri, 3 Nov 2023 14:04:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 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=1699020274; 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=kykwL6Mmf1y36nJByARdqQ9uHESO9i+gC6/3JI+7xuE=; b=UU1XL/IUwI/v262ppeoU9AZl5ZcdntYrW9KxZbvqyWZ7XCNuXKLe9kRCSLbt659CiRswGg vPgladCGyehxWqWtmkUaH6BbYXQoh4mbflwMs9k3FwVQMojWkCGUDFcj4mbebWuMBdDsie jGRVK2wiv9n+nUtDM6QqkYL5Yvwl0mw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020274; a=rsa-sha256; cv=none; b=2GZc28KDpePtgGekSoSGHlCgAePUS+nVkfQx2pAjD3lP0ov/fnO+eJ2o4tazeR0JvJkM9H 6yD1mBHaRY/xt5tOHd/6mPFUFHWnc+1dTioWtS3QLrTFEzHiabL/+WNKAOupE8a2H/J9ZS 4Paq+tCfTPjoJ6f4NgfFoXR5HUM2l5s= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMMmn4xy3zMmLd; Fri, 3 Nov 2023 21:59:21 +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 22:03:44 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 04/18] mm: rmap: use mm_counter_[file]_folio() Date: Fri, 3 Nov 2023 22:01:05 +0800 Message-ID: <20231103140119.2306578-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1A77140021 X-Stat-Signature: rjekz1n7mgqi71uhqgdoqhgs5onw1yz8 X-HE-Tag: 1699020273-422082 X-HE-Meta: U2FsdGVkX19xeQbr541A2Aw7A8DcjU3p01JZ0ILkf7AGBBk5gLywDqSMdpE2jUerG+3O0KYi0G/v9tjNiOzeocLUKqBl5yCD8SKjesSFtNk+qKxyPDF51exxZ7EYN3cO46B4q9jnn8QxpLO7i+67yOz+NL9lYmu5w1wAuc4OcRl7CNOkyimMzpcZi47jHECdrdLh0+u8jmO+SmM5cYVrCCHI/dcnuQZvzkTWls/KpzIFXxaOii6lH8w/EPo2oGHRk8hE2kffspvlYCWymiXhPuIxDkMysme92wBUf/O5+DMTHw4+DqjSLvtLw0Pf774cSu8v+mfeqiEe7urHibzxk0UACO60bRMiRAfO0XBE+8ZTIBwGJ7yVBBaCF0Bj7cLx+hFO8K70GqqpI9SGwgqwaPfRFOJjlPUjzLiMTVw9z9IYHmUZz0LAwqJ76v8rbqZuB7imQglQY6Z5stFTWdxWOW2DWB7S2BsU9mmPlX+R6/kt+9BPSNsZU+aanp0xP2BeR3ZIxzJVIAuU1Lh+SXXqwVvwKCK5QMiFrohj36eFeaJrJ57OQsvo1druT+oQmi20KgFNCgINonj8/h1z+rUPcDqXBPmH9ViXXlPL0MVQ79HTtETQyLOwPGj7CRLHlIkc0cxdiQoYZDDtckDZLxKMMmXSwU4WOByofm+O/897wr1j/fRoWewO6eBo4JTIlWIWYOljXBKMjPGEqC46AdXqypUCuckfejpwvQEL+YXMj7+9tBjBH6KN0zW6ixPPBGDiqAeOrnaXIptPq+yOgEXLldLnrnE6zzuQxRybGB+igNVqDD2KiraZZKiqc1oABVohipvZ4Dsj+KDYQOvVDOXwtAcl8Y3nUkt33vacUYvagAL44893ozAOFDCH+3WK/xG5nL+IZwAGAqhEasTZWAC6WA4m0t/eVIccLoXiT4MwR2HI8XIU+Gp3Zv6IgnVLLVtMJh6BKab2173fXMlQsbu 0qF8g9wb LtXEZ599Ku/rzruONBLt3+0xoQIH3FuYPjtjY2h5kepp5o7P+OtZGTj7XrgM+OKb25NnZWlM+Zf9STn/kD/qbj4gUaabCih6OgGm+LpoXe5k/zi4d/E6PEw1XDcdTPPrlcpCOZvefgQosUjvPcfKCC+rScn1V4G043IozMKgXx79ycG8txul+hD1OYC9e5CBYJkFK 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: Use mm_counter_folio() and mm_counter_file_folio() to save five compound_head() calls. Signed-off-by: Kefeng Wang --- mm/rmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 7a27a2b41802..9d77975eaa35 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1678,7 +1678,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(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -1693,7 +1693,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(folio)); } else if (folio_test_anon(folio)) { swp_entry_t entry = page_swap_entry(subpage); pte_t swp_pte; @@ -1801,7 +1801,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(folio)); } discard: page_remove_rmap(subpage, vma, folio_test_hugetlb(folio)); @@ -2075,7 +2075,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(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -2090,7 +2090,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(folio)); } else { swp_entry_t entry; pte_t swp_pte; From patchwork Fri Nov 3 14:01: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: 13444562 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 CFA61C001B0 for ; Fri, 3 Nov 2023 14:03:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 372EE28001D; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D42028000F; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B2EA28001D; Fri, 3 Nov 2023 10:03:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EB06828000F for ; Fri, 3 Nov 2023 10:03:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C19E5120604 for ; Fri, 3 Nov 2023 14:03:52 +0000 (UTC) X-FDA: 81416811504.21.370CBE4 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf16.hostedemail.com (Postfix) with ESMTP id 2647718002B for ; Fri, 3 Nov 2023 14:03:49 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1699020230; a=rsa-sha256; cv=none; b=wyPivp17AvRYAZ2CwHcolvZAUTDuC3vx0pR5Yk7gjiw3yS4MVW672icu7jePsU6Q6++QmJ n3JkEy/Gg2ywcLgE21toMHpd71akZAWN+2d4YAfC4bLkwICKgYc0n+ri75Knd4mZNeyUXB f+4ADGh3GG3KIZzmg7wVeShdEnTSKtk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.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=1699020230; 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=5WjhsGz5/m2ldEiSjLl2Au0dbbriyQnQoS8lYbel4dmCH1Qn8w9l5zBRUYhykM7b79/GQY pp+QS95msJHUH7K1TZQHdA/TVZp2oZMA//ik6W19Bwwq47mNE5ICCYnWhkA2BmXCkVMIH8 VvnZ4Wy9Jmaw/fWWEOOOi6dtWbkwx6c= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SMMsm0SKlzVkhg; Fri, 3 Nov 2023 22:03:40 +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 22:03:44 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 05/18] mm: swap: introduce pfn_swap_entry_to_folio() Date: Fri, 3 Nov 2023 22:01:06 +0800 Message-ID: <20231103140119.2306578-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2647718002B X-Stat-Signature: ao1a6pxxxj587dk9uf1do6t175j43tip X-Rspam-User: X-HE-Tag: 1699020229-173344 X-HE-Meta: U2FsdGVkX1+d0sy5MtM754OYp+Sf0ZqN30eB0+bcZoazAv7IOjIX4xoDZpQtQrdQk0raZOkBG9S9N2Atc4mW3uD5C/+vdFRnxGb1qkuhW6ZtNdo6oIV3Y9QCYZIjWMjtTp30X7MswkyMjPD2hhw9dOCd65/+0GHZVjD7S2SjNpc5qS8JGwTopINJoZSkzUfr5yxpKh50QY380ZsTvCSMCMP1rP7C7VW9EaySrkXV5th0wq79be139g+Wxqng6BWCncmIdWMEhGXceGi+YxZTSV5aRTep1kLdXVBeBz2/Abh8uOTro6GDsvyOq9XluUCctv2sHnuX5Mg4FErS8j0Y7zhQfMiZ6qQZXhWiMLsSwXcWYl4a7I+H8o5bjx2vyweDFXChmdSfvb5ph7AfH2eb0nVYPXuQUqq2uNXB+KszVWHixJeBqVAYayH7nDXES43qzuXbRk3CSM7BdbFLhesMI6YaDDi8a5nNllnVruKCaJB5xE2S6G2Ikc9YI0XMMFUxj4x23+RgOHbJkC+jtuNWwkU8Sar/jLFjrWwwnr+IpOZA/+rw959K7F1Sm1GT14LqQd/UDgS18ZUy5/FRpkP9juEB/AN2xJ6d5tAJyZQUPybvOSuq+cfdY/Bv2xKr4TfCxpM6GspmQ39k9wG3WGL+I0wjVfuSB74MEOu1Qmh4N9uSmw2Mko7ITq0vsl/ucV3X6mEgdjjzYHGAj6iyFKYhBMywAvS6+3TzW6KKYh73KAMDNMWK19AQAcYkfLT/Rz/p5/mssWj0LLqC8Ak3KFCT+8x0gZi4+YairgT+QEKc3rxPxpFmj6v9mQ92MeHJivl9UlgGYQI/uGCSE+rFY7BQvfMf3G62s4tIEABlm0WDSt4lPiy73zveioty39kiHrYJD1rnkVpmZp+pvSNqX5lGlZ6dSAa0Q5Dzg63ssDXC+AMO+9qFU7VegpQ+dIRkYUbkmhOR7hV4JD9LWhi54Op yMqrYBD7 /k7Mw1k24Ea9obrS1S1OfFRWAEliGiGvaGbH5JpD5FjgdP0WYsDTforgzLx9v9s/D5Mwvc2nRf4VpF6SgANXbAusFxxIBA0hIJu3Ndfb00JnBDxMtVDqDaSmY69pqViCIGd+/V7X98jGuxFQOvUjmRMvZw8gwrkWOyXcYdUwIW2B3MyVhpNp+s9YfxPAXfrUwyJ8l 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 --- 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 Fri Nov 3 14:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444566 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 D355AC00A5A for ; Fri, 3 Nov 2023 14:04:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC668280022; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A75FD280021; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87A82280022; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) 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 78E41280021 for ; Fri, 3 Nov 2023 10:03:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5063880D0D for ; Fri, 3 Nov 2023 14:03:58 +0000 (UTC) X-FDA: 81416811756.06.98E3594 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf19.hostedemail.com (Postfix) with ESMTP id 520371A0034 for ; Fri, 3 Nov 2023 14:03:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699020235; 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=NB5R7sYpytkiUmaxuKrNkniyxkHRPvjeB+cXDTFDb28=; b=mekqGJ0ZwYfNhq20HVIcsa9qnN11pDA0MPNv5Q8MSJJMM0Hcc1CxadD28cbcx0zQdxhYwN QR8SbtQAZ814qD356sE9R2/mkbsZbBRSR8e1Dk3000MuwtCHh0kdQZ++9LPVE1DPAhyYUv IrbsMzlqckol5lZOUTOlcSi454mgoh4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020235; a=rsa-sha256; cv=none; b=R+h4djWSSWPkfSzK+Ckd66PA+cF+fHGDXosmp8nvIjvmr5Tbd0LzZDS07J8O2CqbV4RAPd +kAmS+pb2bImfGquNKnmKBOWyvKUU/nzPjt9Q0dYsm3aqFY8RHoVxAfVf3RAD65R77Gj3I 1MUWnJtXYKhJVU+PYuHE9uPzgX0HzaI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP4lT5z1P7Sl; Fri, 3 Nov 2023 22:00:45 +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 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 06/18] mm: huge_memory: use a folio in __split_huge_pmd_locked() Date: Fri, 3 Nov 2023 22:01:07 +0800 Message-ID: <20231103140119.2306578-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 520371A0034 X-Rspam-User: X-Stat-Signature: kuwshm6d716pjum1b3gc3jqofn8eywph X-Rspamd-Server: rspam01 X-HE-Tag: 1699020233-515555 X-HE-Meta: U2FsdGVkX1/VDn55h+creRDJcDIPMHS+86fvPCy7hf3Vz+cRAKX5IGhW52FOVDLwnRuQtV0DRxZTVbuznH2AN7u+Kffwy2SeVaXltPvPU2AecuUGFCcuwk0+23ykQDT6CtUy1pP17NLDSsBOhQ0bFareENoF2iNPky5YcvyIv+ZQdli0ezKHozxacz0PKKRTHNhkjyW8JKpDVeCM2VVmkK56sQFB/C1EraHxqPk7eS6/JvWrmNhJo9Uibw9aJNYqGssyqNxAtywO7tFou1iTsILXTSAfvBRv4dTyJnnoVga3o/qx+m/JQbBXMUlmn3peD5s84ljjXxsH5HOyBnNHYl3ZloqJE+wBuVrbjbJGT7G8pmCI/ISVE8hLcSWxUDJEeCiipBwDk9fuqPmAWTiqfn8kj8F213u3h+5SM2f9ssZ+5hd4MHKV7h3CURlxPOROjt9ybrRaV5v5po4hmaWmMVPySut04cDF3t5EW0VGky7vx16f8VqNeQ5TvC4InBUa7t1wbP34PwmqQcsUqXZyO+zlGn87iicLzEhHvC8JNl4FuKraO/JYu3YRqtk244aTUNTizqPlUOZWWQiBaBKrqj2vuxQ3LLNrdBnCSwtBJcW+pbUywoFPLG5vqaHM3H1ZWdax31wYyey8tRJkb9nJcxQ/oUAX28vPQP7g92VqQcC2lfB1w/0i3KfKOOspTeI4Bt/y0Lxl0gi5ZhvvmNbkXlBSLsRi7m6/KM9crIVDUrHMR5XI/0Cfd7WG/VVx6L1csH1AfKrR57a9e4z9otI8Nt9c1yVIOyba/ltS4iFTg4xwPQx7OhEiyDT0Zkca2BGZD5JaSyglfsm0DYKZg+0HXEujGLEG3Q6UAgdaeiMVLwkpuH5v6yIg9qG9syeCQW0oO1Q7lVPji0iZSOsqHE6S5JzASek20f8lJ9GzNxyG6c5PTb5oVm0AxmZz578C1TZzp/WPXm5rdrjdWweehd8 5jTd+eU4 83Fx01tA+zFipJJvsS7bLUvmAOm9/yDhpgqYiodHh+P7ZRKjMwNVR3a2gnAjy/fdUvSs7uRCcC0/QUvHARuPqZZRAQRGtcmVzE1sQfENFAqEetuvduVVMgyaQXbtZs1306Rxjl7JF/L9EimqH00Vvykw7syJej75oIPukbK8FFus09G/A06JQGITIe1DNQCvOBSzo 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: Use a folio in __split_huge_pmd_locked() which replaces six compound_head() call with two page_folio() calls. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 34001ef9d029..054336ecab0a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2117,6 +2117,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, count_vm_event(THP_SPLIT_PMD); if (!vma_is_anonymous(vma)) { + struct folio *folio; old_pmd = pmdp_huge_clear_flush(vma, haddr, pmd); /* * We are going to unmap this huge page. So @@ -2130,17 +2131,17 @@ 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); - if (!PageDirty(page) && pmd_dirty(old_pmd)) - set_page_dirty(page); - if (!PageReferenced(page) && pmd_young(old_pmd)) - SetPageReferenced(page); - page_remove_rmap(page, vma, true); - put_page(page); + folio = page_folio(pmd_page(old_pmd)); + if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) + folio_set_dirty(folio); + if (!folio_test_referenced(folio) && pmd_young(old_pmd)) + folio_set_referenced(folio); + page_remove_rmap(&folio->page, vma, true); + folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file_folio(folio), -HPAGE_PMD_NR); return; } From patchwork Fri Nov 3 14:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444567 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 425ADC4332F for ; Fri, 3 Nov 2023 14:04:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 483EF280023; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 435D0280021; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 286F5280023; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) 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 1AD4C280021 for ; Fri, 3 Nov 2023 10:03:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9AC241A0400 for ; Fri, 3 Nov 2023 14:03:58 +0000 (UTC) X-FDA: 81416811756.23.E3E22C4 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP id E06F040022 for ; Fri, 3 Nov 2023 14:03:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699020236; 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=/HAJ8XbTBaLTFFDB1GrLQZOkpvtPmYqj4jF+Og1D+HM=; b=bL5aKOTezQt7HaeqYXT1Of1rUprDsW1m4E7jZwCsCtXfYGqiRqpGWM2KQh59ksx4ZoKM8J FDHvgc9EaUTe7ImfkbTtPZaeTAX0+cJea3MJ4yao/fy8tqX+DXcLasAMSZUmqtyJBmavQ2 UxmKBQT4dd6KGxyOFSZd/v4Iz41Zk14= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020236; a=rsa-sha256; cv=none; b=WEb3Ks9z3ffw9DMLdLUR7WaN1+cSS8sqz9wFHbjkA5NIgrlCXE+PnHcn5pGuTCSKrKbLTt ucmI80z5C2P6cxJh1Td1Vhc3oeL5qoJhNBCFNGMrxMnOjo8DN6vnfirXmQKc4UfeJy3W4T B4Stv4AgTkd38lexoTuUyWnaE3lQprk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5NHRz1P7nG; Fri, 3 Nov 2023 22:00:45 +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 22:03:45 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 07/18] mm: huge_memory: use a folio in zap_huge_pmd() Date: Fri, 3 Nov 2023 22:01:08 +0800 Message-ID: <20231103140119.2306578-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: E06F040022 X-Rspam-User: X-Stat-Signature: g9fcwaidwqm4p89arxfmdyyhqsc98cw9 X-Rspamd-Server: rspam03 X-HE-Tag: 1699020235-764742 X-HE-Meta: U2FsdGVkX1+pdpQwKyFc6DRnEo7MbC0XsJnghQzG1/4bcB71IbnFoi2A4Un9FMj7UIku7Q5sB7GB++dPCTlJq90ZT22sgPgudd8WH+q5yXzXHVmrlf8c8Qf4Jyd5hXZOefl8jk6EyHKItIZ+DTU5VhGWztt3GS1Ux2ApNwCoPKU+ZS+P58dboL6HHBPIorMGL0+1RD8DdJ7/oMJ0jLC466N3u34uBHu7/h67xXrlGhUTOqstsVRa7sR2v/IBGIXa+lR4K9ac2AS27QrPpSPyoIiSLUe6Un729GHqqg23awweLVKOBVgtr1fZxNwu5YG3vdp0gkfYnN7Z5u5Ku+Jm+xhgCHU8IywHVzVl14P52czTRrBglU8ZNWrTg5JfHmXGv+pZdxPaHghK7HK5F5iWv/XCjTEGuxqvJZliu3sbprMNu4UQp0idDDY93d2jAjKgynq0R8tibuHm+kj/6dOHgbsVyUHCM8i69Vb1bJvZ1KPW/VhvMgkvU11nvb8EUzpGVV9HLEUBe8XzchyGBz7MP8NJBhbrYiF0aP1P1CeXiBUbvxDbMoq8tTUS1re11oNt7N3iI5y4O7Xe8oNK/Eo3vebYtAV2f4veb8vwUyahy0l1oZ/Ids3Bkz6ZTaYs527mhTYwk6AHTkoFMkbkyxtwSgyGjHZSbx3XKYlnXhANEQ8E5Y/x4DrD5taWDsVuikFDzWqiayiweiv4UBDuDl/rmnKuWH0NH5ypnABG9qmwefCcnncMODJgG3KSQMMEzbcZ43tWw3xi/Zz7gnqOG+zh62o7IDoQA6QBVAPf4rQnMlk+K3YdvF65dhx5auid7SJPFk2Lf4ssfJcQl/fvwei2E1B9duB23BoHszG27UEL9Jm6c47ZUkR3nBlc6ACiwm10L4zRKKLLdiYleIfR5FCOnkjKEbOGBX391GTtDG6VA9WDIpSMEwlD6fihZwDX/Vm+WVnCIZOQb2oq9AFnf0N dtrqNANs zslDiI14f3QdLanDYZFFUPUzH65iZpCA0aQ2QzDzo//0+JYKh+4Mg+uKfnOz6XS3R+r0si6L7hieEzIwT3xeY9rQ3PsP8Q99upmcde3JDECengt7CcfgMY5FyVnRow3w9Jw70Rxl1uAp1/E/zIG6R6pYp7AQFbyOKnaWpJHNksymy7IjJ1ekkmPBzT3RnRZ3/tCic 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: Use a folio in zap_huge_pmd() which replaces two compound_head() call with one page_folio() call. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 054336ecab0a..2dba4d3aa2d3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1717,6 +1717,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, spin_unlock(ptl); } else { struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { @@ -1734,13 +1735,14 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + folio = page_folio(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(folio), -HPAGE_PMD_NR); } spin_unlock(ptl); From patchwork Fri Nov 3 14:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444568 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 6E285C001B5 for ; Fri, 3 Nov 2023 14:04:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CFBB280024; Fri, 3 Nov 2023 10:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67E98280021; Fri, 3 Nov 2023 10:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5469C280024; Fri, 3 Nov 2023 10:04:03 -0400 (EDT) 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 3B8EE280021 for ; Fri, 3 Nov 2023 10:04:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 05EE6C01A4 for ; Fri, 3 Nov 2023 14:04:03 +0000 (UTC) X-FDA: 81416811966.26.558D67B Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf01.hostedemail.com (Postfix) with ESMTP id 168C540023 for ; Fri, 3 Nov 2023 14:03:57 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.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=1699020238; 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=BksiekM5fz6UlJeefImo+WZsurm9oK7d4R0JBiKe41Q=; b=fKjKl2fvkibvUC8MIqoLtMNm1ZcgaOzgAaR971FpV/GyLfSWWAeO4mHh2NsWpVattIVYqT +HWL3g0Ih0Cp+LjLV204HGMo7ojOUEoo8WTmZJr8qR0SUxc7ZYPQUQko1ydr4hzRiF+OGH IYFc8FKsbNMvTHZVexNCVP9xswQPtLw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.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=1699020238; a=rsa-sha256; cv=none; b=heAmpt9SWXQb1Wa9njoaa5WR+1LVZzxREi8A5j7mBM5pzfGpID8YI+ae4UnTbot3YjjXWR BCwkvc6uTQS1iirB54B9JY92o7J4uWJ3zO05KcNC8En59ycn8nRdO6MPOnAawR2Ey5HWXN G170iO9+37Gv3720N7+KQZx2vqkBQ6I= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5g8Gz1P7nl; Fri, 3 Nov 2023 22:00:45 +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 22:03:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 08/18] mm: khugepaged: use mm_counter_file_folio() in collapse_pte_mapped_thp() Date: Fri, 3 Nov 2023 22:01:09 +0800 Message-ID: <20231103140119.2306578-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 168C540023 X-Stat-Signature: rs7qxjx44jomd99zg7qbsouqnf9iushp X-Rspam-User: X-HE-Tag: 1699020237-632172 X-HE-Meta: U2FsdGVkX1/3YL5jpA2gItADQ+qkDDXe2gSmArmWm1703avPQaUcO76VW4+afYdrAIyW0q2mybxua+Mt6h9FO8GDgomBK8M5JbccmhzaT8GHPR276r7VcMTv5l5TC4OweHb/b3PpPhl3Ze23ciJ5YCueTAXJqQgu01jDMCFWCxymhtSdboIZllGqIe/6FxILgB/5Vl+yu2BIsxyZHHDmG5hQI0SdBcQgPEX4CJgBzN9KI1qsnCrRPalUdp49pSEfnWMQnOG1eAFC0ucT5swo7cqoJ3SG2DiERTWf/Auv2KnjO6lfOoGv5BrOCgPd27UmcKdV7N/MHEon+ksUPJubn71Rsncn0vzULgn4GoLobHaLZp4d7SkNWZv7SkYpCe7YNwHUStHk6yLnbt3GKL9ms15fwSG7Id4qLEPxcq7MB7DtHDSlvS/AUIAGlFqh/2iq1B27j0CM9ImQHfKtTWUNLdRIKTByaujE2XkSpQAuXqsprlOkEaB7uLZYFrba4jRZcRZpCs9T2ljSl00a13alKXjWvfQlUFWmV4VjV8DVTPtIzefZEf7PhQ1A9trwXKzUc1445yeUSMQPvs/qd5H0DrRtu6i8sQZrpV14yGKLuwKWMLs02U6kcKDFW8wVeLykagHF+ZqCYWNOGG1DWkne1vlsvb2ALlP5aLgxcp+sj5lkerRVhcORRvxWJUKeiLYIocroDh+u9PpfNVp4KX2zvOCnsqAgoCp9Nxcw8oOByi7ncbaf5oQlzBCyQb7ux+LoHmCx6QeyOfx93WYCVtSGGtv0ixlRgl5ga+0sg2kqa4L2WvH3J97vqd/myXsEimPC4+Bl0Ke5Gqq93xGClOsb/vRHIOKVbaR/DgFIe/t7fGaEdjoKxV9epIzBobL4NRnscNU7CpO9x1oEzEAOwrIVE5/+OLUp5VDVMuAcwGlfZH/66GRzXbs4qzWOJWperuwD59+SEaxhSiv7MLKCsTZ Py5bMlzd K9Z6hBdSdG7cYRiD9TkOXpGqDZbRdk4+MHVCXG/i7O7dtpIf5tRwq9jQdp+7Iyf5q/Rn/XkJ7qWeRHZwJzTUZBz4lfdGObwh1M7sUP5H34ltk4zGqJsKiTab3Gw1ciAxuUQ24Db3G0nd5D3p34hiTidaAUfO2miaAxT6ChD0Cg+A/H3AethANzLuF9Zmxa98hrtFp 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: Use mm_counter_file_folio() to save two compound_head() calls in mm_counter_file_folio(). Signed-off-by: Kefeng Wang --- mm/khugepaged.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 064654717843..a6805f4f6dea 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1630,7 +1630,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(folio), -nr_ptes); } /* step 4: remove empty page table */ @@ -1661,7 +1661,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(folio), -nr_ptes); } if (start_pte) pte_unmap_unlock(start_pte, ptl); From patchwork Fri Nov 3 14:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444574 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 3198AC4332F for ; Fri, 3 Nov 2023 14:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB035280022; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B607828001D; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A282B280022; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) 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 910C728001D for ; Fri, 3 Nov 2023 10:04:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5887140429 for ; Fri, 3 Nov 2023 14:04:28 +0000 (UTC) X-FDA: 81416813016.02.449B40D Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf06.hostedemail.com (Postfix) with ESMTP id 09FB3180024 for ; Fri, 3 Nov 2023 14:04:24 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1699020266; 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=ylqQuVj5ksYS6g4LV1U9DLXWq/46sIERK97vnxuNUQw=; b=5kLXLnZ9htPxiaQEj+f3Mrs5Vzck+N98IKBiAvlwlvV9RZtbjoANtPgcp0TklL76SbV4gR N+dSKwUIkHfqBxj7ust+O0mwVkMf4+mn3S1lZiQxZvhXt7HPcmbQZpPSo3a17bpWGEzhJ5 aR0ddeHD4x9dkawGFTVuj5VaMCP8IG0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.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=1699020266; a=rsa-sha256; cv=none; b=6ljB1NjfXYGUdPv+cpwKKcjv4QTjiQ+7vb0hp2zlS2QjESfQ9hhdY9KwRHdg0PiIAQAYF9 FV9l9wAELuJ5Q0Ts0ZYIzyidqO3RBbR4viI6C0Ym344tZ8Gj04AA8DqZrHzNMgSeKypab1 u1lIaZBnT/AFtgibAQRGy3OPC0nCKDk= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP5yQNz1P7pR; Fri, 3 Nov 2023 22:00:45 +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 22:03:46 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 09/18] mm: memory: use a folio in do_set_pmd() Date: Fri, 3 Nov 2023 22:01:10 +0800 Message-ID: <20231103140119.2306578-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: samz3fxyh83an1woroyxmtht9jswigm5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 09FB3180024 X-HE-Tag: 1699020264-627793 X-HE-Meta: U2FsdGVkX1869LcuZdHrZI3XlAqDd1fyvV8wfdBXSI9ubZpPp85JVWReqpdlCuBAjnMr2pdfFSg83HEFH/WmkM8RXhcJmcHcyHpubFbF8c+hdjR9Z0Y9FnFa8B+iTnktLo9lWsW0zXVKiBBihJRYfVv7A4hG8iKcWhWFTGZDtUzLiC/uMrJE36ocAuo/rx5f4fBzygBW8KZIDuP3CQM8sqdKo9jL/I3/FIPzYs3YO70KPvxlJ1+/JS0fxqAUMTajveEJLd9ySSgYUTpzmSkohup5RMXMwrTpqvysdT0n3My+wH1f7uJ9JaG0G2AA8Opp/oPUJ1DBBsOK3xCYAXNzmzrk5kLa5BLZ8MGTzOITzPmCNRdUFPrbmyVDyq3VlWPt+Y99SDkafQWrk664xefPp87NSut+xVjYAN3auDNrDxEpID/lMiFUiaMa7itpArTzRxTecnJ4S1pRyEGDuflUG6XSZauUZWyLKox2ZSbZKtGkdIY0z1UObZUMzY0g4lv3EP5QVVxchBNk8ghui7iodyQNFnOzXiSExf5zLWjOlQMaLKq5LPaci4KYekieGAGIMVyo8bRdeT6cZPNfrqbOsbeoXU+SYWmPnQtLixo2xM1dcCtD6kO/2o7neS3B8MDmi+NNt+x1KkTtGRGyXxpA9Gy/TwaF42BWLLvHmSbGAjTdstX81ZUWVEki5X5gjCypYJ0UEhNoHU99jJrqjNOtQS/KIMFu8hfwJAdGq1nbb5rYxYxyAvX0gDnGdCSjBZD9nYA/1q7FQZMB2dSJRvX8DH70PoxZZkwgLECT8fHBSwF0uqWaTDyG0bpPTS8PD8iMHC7zNt5Xicihf91cCNvRVrJD0IKM88AyEIqUAnUigJG0+y7AY/E+KXXeX9Nzz98YJrmVk8Z3tGR8Lx2HzhQXxSHiVZfT41qvcUtLDx2UMKPDd+OS0+NySSD05btei21QIwCY/2j6wOyzQ0KicN3 hyiTloD0 pnrMxDAvmQi8y/03ciKHXg7SeGgdJhALG5HqFwCktxSq3Za5kalFIEiQqJD0xNYQt2zd2nmeC8SnKIS7y0OsSj/d3oYtwMC9X9IpQNWZ1mBKYXogcPIXtmHK5xI8rF6n/5XkPj6Bh88lthaH9MHKk0N45TQJpcDnE4HrNHTJCryFCGGBEcxQ5vTLVxkz1zRumrlJw 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: Use a folio in do_set_pmd(), which save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..09009094a5f2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4313,12 +4313,13 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) unsigned long haddr = vmf->address & HPAGE_PMD_MASK; pmd_t entry; vm_fault_t ret = VM_FAULT_FALLBACK; + struct folio *folio; if (!transhuge_vma_suitable(vma, haddr)) return ret; - page = compound_head(page); - if (compound_order(page) != HPAGE_PMD_ORDER) + folio = page_folio(page); + if (folio_order(folio) != HPAGE_PMD_ORDER) return ret; /* @@ -4350,7 +4351,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(folio), HPAGE_PMD_NR); page_add_file_rmap(page, vma, true); /* From patchwork Fri Nov 3 14:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444572 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 91104C0018A for ; Fri, 3 Nov 2023 14:04:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD561280027; Fri, 3 Nov 2023 10:04:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB48B280021; Fri, 3 Nov 2023 10:04:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4AD5280027; Fri, 3 Nov 2023 10:04:11 -0400 (EDT) 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 B0F0E280021 for ; Fri, 3 Nov 2023 10:04:11 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1E4D9B61E2 for ; Fri, 3 Nov 2023 14:04:11 +0000 (UTC) X-FDA: 81416812302.15.2BAB1ED Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id C949F10000B for ; Fri, 3 Nov 2023 14:04:08 +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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699020249; 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=etASjzJe50wrJU9UBMk5yCoyKqr7D2lHehFpSzts/t8=; b=Q/FpvRf5JCcz0TIgj4g5ZrlAGL690GSm7z+YGa3EgJWP8O6PUh08sv75DPgPh6+Gl8jn+4 VW8/aGZa1YcQz3i+3lG1eLdpHsJoXY2we01LL2FluZl1sYnsLqcqoYg+jscHhVABhDpSxN tznkcHuGENhkSY2gBSrpmSQ4CURXq0k= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020249; a=rsa-sha256; cv=none; b=mgR+4igEDKLnppaCiamsl9Lkazc1dgUT7nJumgPUFAjp3QlB+MAEjPxm7ug8D0ZW3PQqJE bUrtULg/v+gGtMVPe7I4JkpP6xA/4p2KB91gJ5DrPVeReaWhqlqixFevKAluptclDNYwwP eCDZ3/HK9xhIseKva2bGxSpbQzgBaFI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ084Pz1P7nW; Fri, 3 Nov 2023 22:00:46 +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 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 10/18] mm: memory: use mm_counter_file_folio() in copy_present_pte() Date: Fri, 3 Nov 2023 22:01:11 +0800 Message-ID: <20231103140119.2306578-11-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 74o7sqak49eafaw3985iuk16zjoh79nq X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C949F10000B X-HE-Tag: 1699020248-597814 X-HE-Meta: U2FsdGVkX195WKmZRHkvqdBj7BmtB9oJxXaf5DYUrG+51PyfWyuWFd26U386rq0/0nSi+cmn88u3Wsf6UOaJYcHsf7PLJh/IkDF5AQ0KPlISphlB0zq2jWWiweFx/oQ5bo5FP0hvHVleJ2jaYiH1JrcXubhvv0M25yAV6mEnYjp0QPudEdfANFqHSQzjknkbFkOIgj7/iqcyjRxCtxvVU3rC+/E9dFk4Dm3lTFDLL0Y+C+Q4UasKvxfuJNHyOh1Af79RVr/Lm19G1XCM/tSEGXP8b9btMpKHZXUPDyEay/zdrTMeQKOPRmb6gzijt6z/kK5fPeSEHOir6gko+sJ8b8LuYTLrMnoxazUHUpU+ooqy41BTY6/XE/EPO9KdZJRJMq+ZoL60mAfeeCUqaCG6ce+rI0CBth5iXKZQnrGFur0oyww9+5ylLoLnaL+oAm2seIBI0pVDJrJfxTOuRQSo18GCJJv2+TN2A5JL9F8x462y02+j3rugDAcPRScD5gyLWPl4rXY0WDgvcADgDCpkG6eCnhKHGzD16DyYH3ozByymm5SgmDVLfiz5GiRQ2/2vgU9WthRWbJZrx1hWQc02bXrYEcCIvC62Qzx5yPMfStpZeyvpwMM7YRmVHpvqtFrYyfS++bGWCgWj40SeF+n3d6yCUYdxQq2t++5Ipvxh1RKdrO+me6h0xd+GJiC17/BYXiUTwAXsxckef1uAKKkU33YtI8dL4UtmrQ5mH2ynL+TnDyDAcagJzuNAzsrW7109ODxlVm5uTuvQceZtTwCZ3Hl7xMJhprEFV6XZKJRgZngqmhzgw6anKf3SSFUHyR1oDULbNgoSD5uUZCvZt/cCLcYsED0GNezhcxelrnb7lMg143A31a3xlHUgHWlTFzSlQOQQaN2ERXuHYaefa6f5+PJkfiV2OB9KVlbJEa8u/P6D29SaA++yXZAsGDnM5a+U0kJVhyq4YxGVd8u6YFW v7CKcLcb RtDVA4p5Szhcsy5MKRgFrVDAVf68i7vZ8dlBQPsREvWqlZSaKvtkMisRLvWDbfHq9URR8ZOTXWkCgqEAVATfUJTwoqEJYNZuqnwtWb+0G1JTkpWBDyumb5L3TJY/N9MqPV3VULFtaHV2pXWavkfm2T+uSt46/9+qmoF6qorevN8/MR7qEZuhajLFuEKkk1jxuG4j1 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: Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 09009094a5f2..d35ca499bf1c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -960,7 +960,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } else if (page) { folio_get(folio); page_dup_file_rmap(page, false); - rss[mm_counter_file(page)]++; + rss[mm_counter_file_folio(folio)]++; } /* From patchwork Fri Nov 3 14:01:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444571 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 4D6ECC4332F for ; Fri, 3 Nov 2023 14:04:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E96B7280021; Fri, 3 Nov 2023 10:04:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF80B28001D; Fri, 3 Nov 2023 10:04:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9A2C280021; Fri, 3 Nov 2023 10:04:19 -0400 (EDT) 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 B88A628001D for ; Fri, 3 Nov 2023 10:04:19 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8F66D14093E for ; Fri, 3 Nov 2023 14:04:19 +0000 (UTC) X-FDA: 81416812638.26.81AD917 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf01.hostedemail.com (Postfix) with ESMTP id 4B1BA4002A for ; Fri, 3 Nov 2023 14:04:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.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=1699020257; 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=J/rSriB3aflAPXuP/oLdhUT4o9qoZ0PrxLn1lca2smA=; b=U5YKXz9CH2aFJlnOs7NFc4K5qgIxsAXU5blM8AX5Mr3o+LKO24lwqsRIB1j6wWaQEQOa13 g9RK614SefiBRLfTfVKG6phNSqoIb70JIk10KKR7xwwrPy8Yo/egm+oVsUt5VFiCIZb216 67wpQhqGJWzXm8B2Y0F+pW1aubZfOKQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.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=1699020257; a=rsa-sha256; cv=none; b=cjAWIjil+y2lintqLOBKYfqYlRGiJbVLvoLxF+0h7fK69dQxrdfHi9/IWuzeMS21z0CmsM j32RIv5ATTPFuEoCc9PH0cDWzclVM4q3LBe6p64FBdWnNq+XcBWnggEsXxSO0NtdV6Ko8s 3Jc+30Knstzt0eLLjEQ7Tam1UV0ymP4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ0R1Xz1P7pS; Fri, 3 Nov 2023 22:00:46 +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 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 11/18] mm: memory: use mm_counter_file_folio() in wp_page_copy() Date: Fri, 3 Nov 2023 22:01:12 +0800 Message-ID: <20231103140119.2306578-12-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 5sdgdsqu9occuzw57umenedhhnea6p9t X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4B1BA4002A X-HE-Tag: 1699020256-206388 X-HE-Meta: U2FsdGVkX18QAN6qRGgKafmCs4Nmz4lpJxewhTahHYn8qnXBJaZCufLgdPCDI99EHdcH534zVRfIGfGNQDbbr7PfojLGZoyqeSOgc+1MJ1mtEWFnjQrD9+fc8AU+2R4MHqqoEalszrO4j5xYHybP4X1u/vsH4EG7+mVbeHNgXXyw2BHkG3rLZr8wpxww3Fk7EF1vIXQ7ehS/J1x5KhTMQ4Yojqy/XGvonsHlIvbvuHJV6iR/cfM/E6GQ7/C0TdtQERPmEVCffesiNMygrZJjo/5IFeCrYopfnJ7dphgjTSpmJb2dCakyvvskz7rEhcrQeTapVIH6UMOvGlj8E3tPNNaq3WbwwsTA/jhKiChZiQsutgvc7ttrZCbrpFg+fcIJotacC0SgRYQGo/gjae092l9VEbHsDUoF7tyHwtgCJPP7PCQllM2AUim2mHiHL7JIhjK3DdgqavtpQv8xw560YsY67HwU6YrPn0Mnc8Z86xxEavng5N6nSfVrPil/s0wYNDpdumBqkCdPp4FtfScrFb21ZXD/LZwfvj/9tuEDWhpgqaOC6boiAGiamSvJibFcZBpyLuT97BuU5oyS3o9QzvrLuOolE6uIuR1I0zZWTJeQtjrVCtig5GNtWJurNPtQnEcVCyGANJlJHCo54YHD97RumD7WJbqUMiV9RsJ+/QByTECWfsL2ax9mrfMuTavwn6Vb4c7vZ05AvinwNZJKbiOjLpsLe5nKG7aneDLkRe+SZbQ7FoUGmWp2hWktRtSKFvfMASATs4SiCWm1GnSQ/vT570qO0xWDZuu1EPb0r8xf6FzhrqnmgNssApfBAFTfxNmJfNWeM7rHuiucbeV/uE/V11P9a0HBxJLWuICOLqXWG4j9MESTxyJ3cgF7K2GGjDS8uR4QQYDBYdtjcMTKNUYAZAfN0Ti9JpeUVnSs0hioIf30gtRZtUoBX/hquAYzAAr4OSJkDSpp8z4tj1V Ilsutk7N spWevqaQ+HxWCg3jJf08y+pHA9u0t+prXnr7mVuXvnDFbyI3yvZu5k1OOICnN+2vTZYzCCBVwgjZ4PQzot3cAIUV0gktraoTAfng55DJdlyINshBxDKQ9VgOiIxh+iD5aHfOCd8GjyxDT2oTel7JqalvxJTHNwYZXA8zVmbk7DDV18xIwbSb4dKhEnyVO9escqhJ9 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: Use mm_counter_file_folio() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index d35ca499bf1c..661c649afc22 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3158,7 +3158,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_folio(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } } else { From patchwork Fri Nov 3 14:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444577 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 1454EC4167B for ; Fri, 3 Nov 2023 14:04:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9ECE28001C; Fri, 3 Nov 2023 10:04:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4F0028000F; Fri, 3 Nov 2023 10:04:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9177A28001C; Fri, 3 Nov 2023 10:04:46 -0400 (EDT) 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 7CB3628000F for ; Fri, 3 Nov 2023 10:04:46 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 55DA4160605 for ; Fri, 3 Nov 2023 14:04:46 +0000 (UTC) X-FDA: 81416813772.09.A187E57 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id 23F42C0075 for ; Fri, 3 Nov 2023 14:04:32 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699020274; 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=OeTPIw8gaHpYgTEOA5d0ZjkKIpqPK2yWIYgWH1aKTeY=; b=IC2RTNk0uGQ/P1z8iG005m6Ix4cD+ixTNVts2MDgkTejlTNqH6gDtMKLpkQLaRRAryHVoj C7Losz6FkZ4OUpt/iSSlLrI6cEzY+2D2+mZB6jZGomZHAMKZnQ+aIz4SfKPDyXPVfSuYdH dD37D7bm0WV+R/W37thnuGgxlmy26nk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020274; a=rsa-sha256; cv=none; b=TYEjinLPuGTDmTvs5+Lwqn5N8Vn59o2ODg2QbSIKghmr4CiZ0+MjlsZvqMmJx74BlEoBbx hTh7ib/5qSHTjNYgkYopFjZtDCpOTLyKUjixnvHKFYC0KLJ8HKa0/xroGfr5dF9I41Py2l Ttpnh6OvKqdLtlB6ynOdm+6UPdOCCqQ= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ0kJMz1P7p6; Fri, 3 Nov 2023 22:00:46 +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 22:03:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 12/18] mm: memory: use mm_counter_file_folio() in set_pte_range() Date: Fri, 3 Nov 2023 22:01:13 +0800 Message-ID: <20231103140119.2306578-13-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 23F42C0075 X-Rspam-User: X-Stat-Signature: f546y73bgu1z8iigpurob3i79e7g86qe X-Rspamd-Server: rspam01 X-HE-Tag: 1699020272-551236 X-HE-Meta: U2FsdGVkX1+yspgYhKfwMRkCekS6UK0Q/vtU14hgDOz8yVpZo1kd7glehHD3bXseXY82fzIcdnce5L6aomzIsFvsduNURxXQizDd0l4qnjTnjXekW/7e/hBWFznLmQthnx6rFKOiYuSETskqN5ehNjUFV51dhXwCBkQaJai99lkVbKDd5LLscO6SDFS160gh7oIgci60qO8nT2Tc9w2dBPt3M6JF6ImVsqluJkI4X3zwX0kb8VIN3eywMl/LQiePkax8OjyOt+FZsN0EA5IYJ6i2HP86W14Jpt8T4Wz9rKTIBKqWnKCLDH/Vp0+CwtnUuYqQIGmGobEYZucAHY9PUwUTGcK2btrTNnpLT+Y/d9JbwRiglFIKZpSMAddHonWZaRrUSPHptYKC63XVQrNtsV+JyLHPu4rFVGK23S7s6E9uE+uLoRJblQFrkzC+HdPgPK1vsRo4swULxCXeC3GPDq3W/Ljt+pyPQVB7auJGaLChKlCIujUV91c7Kz3MY0ySJ6h+SggG+9FUdAaPqdAC1g4OP77OCHvrcxQSIvf2o5ym/3CYYdXpO4gQYy0VzROYtM0UeKnVSyuV5ddkma1AVTGD6AL+fEh3PHPo5OZc/DZbujT/B6Xbm+/47ELB6QZ8Ip4tebW03yErGK8yZuSzrHBmL5F/FdtyeU1XilIYN3SGbi2EAmn56cqGsZcGrWLY2ft0S8AIYrQ92F7gFQRdnw9Y3MrB0Zse5+iPCypoG37mxPZ7d7QsJnIygQeeUlXkSnJNTBqxCV3oAS8KHNSmcgKi1rXk0iuiNKbq2ezSl9EC9h2PQoghiRUIH9aqKiJ6bLpwYac7SeqDf2z9GoXIyg0WVWcrIhP4zzifcMpIrxwARPBxbcUCTSsBED5teiXIfvpnMGS+bXnS0KehlJ5YI+FzNaEhjDxjc11vdz8soykHvSRZOrWZj6aC8CHEyepRTx+76BryILrdItZSk+9 lEsK9Z0b oFK2qfDoYuGG4eRXgasj494tMRqYdAbJjs/FBcoOv5B2FEB0SNoL29Uq9oLiMiEGniRYCXQvTkdNKKp2CwcmOlqX26XUH1HCNIU+QiSRhqmOZPlZHwDH3CBUwmyD6SROrCv9nyDpbxtHcWNfBouLQof4CwuLBkHOlwQFDGrQgQlqMdxTIzoby9pziwaZOol2/BVSJ 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: Use mm_counter_file_folio() to save one compound_head() call in set_pte_rang(). Signed-off-by: Kefeng Wang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 661c649afc22..2d90da70a1c8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4414,7 +4414,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(folio), nr); folio_add_file_rmap_range(folio, page, nr, vma, false); } set_ptes(vma->vm_mm, addr, vmf->pte, entry, nr); From patchwork Fri Nov 3 14:01:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444569 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 DF53BC4332F for ; Fri, 3 Nov 2023 14:04:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93F48280026; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EECC280021; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B848280026; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) 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 63314280021 for ; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2A9B8A062F for ; Fri, 3 Nov 2023 14:04:06 +0000 (UTC) X-FDA: 81416812092.30.1FAB43B Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf05.hostedemail.com (Postfix) with ESMTP id DC1A9100026 for ; Fri, 3 Nov 2023 14:04:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; 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; 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=1699020244; 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=MdhMIc9GunfmcgvY7/8IJnElK+TVJK6hHFkN45VneUA=; b=gqjOEWMe5DXP+VntirblWPAtU2I7hYjzxRnNezEvAAPWYi/MMrAiSgwFzimZcii6cxJtEI GDCu62nqlPI8W3J/F9Z+mnKl3urwYOeuNDdRIJq05QKe1PLqQp0DD9FKNV8SycpdVZERCB YfihRDVv/SRAaM3EhbKeVhqwEC/05Is= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020244; a=rsa-sha256; cv=none; b=v088MN8valtlWrchtrJ69lZ/Nn4hkEtaFkiRMFOWe0k2W07JpuOjsgdPENB3vfyS2AMPfz MpLQBGCKuVMLd4E3YrjqqMQkVTQZb+VSR/O/AoTK5X/9+gbjepZYMsTJPq1Gb+FLCpZv0q SnOadE6J8pQd5AJWK35kLqQi9EJKSGE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; 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; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ12P0z1P7pT; Fri, 3 Nov 2023 22:00:46 +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 22:03:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 13/18] mm: memory: use a folio in insert_page_into_pte_locked() Date: Fri, 3 Nov 2023 22:01:14 +0800 Message-ID: <20231103140119.2306578-14-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: mg65y8dsifoqf3xrn8ctfu3dif87bonr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DC1A9100026 X-Rspam-User: X-HE-Tag: 1699020241-776320 X-HE-Meta: U2FsdGVkX19mwJVJJRlGqc2Q2wPeZg566XF5WnwxMGXrmtwXBJEfkG0qdSJVc3jNHJ9At83LnL01UZ2cpIyrHLIO7C0l09gsv0v0c1/IuCL9W32j9/pue/aCSHt1rDJxYNcjJ/+PvFVSP2/gGkUvYCUJK5i4USHG/FYU+t0F9cm6uCbsmSSX5icRHqSp7XgMInhhLwtdwktxy6jSx11ZxXg7u2j2/yCMMlFweViZ5a1ST3T8TicOuIMjO4haagAuaAngEbVy83FcLROoUPd5thdOfhy3qqvF7gvQf8NmR61bdOzUZ8cZT0PirCWpm7qW8hPXj20APT0uONi/KXrFDo9rAO497QUWdBaFGI00Pm144jEC3B6tmxfJ7Vcnh4pqB8QONoG1T7zrvCGbpaQgREY9MuHgeFcy3Gczid208PtXrGH06oNcocgn/1+Tgj9lN8UCoGclkVBNfvh4svVDzGVxeosaRiDErmFMFUo0d6T91oJ2RqFDb98T3p6TLDz+7ZtmDbi8IdYO2IEtfrnzajN+mZhhPJCANmaSMQX+ZR3iW9iB/IYVi/Cdas008BHWyt0J0EH/79vn6qgMmgIrc6g7yLMLjEE89lgOW1zhqUn/58boL6x9Z82emT/xlnsSoXzzDkX3weRRQaCiLjEDegkaR5MsnE+ndF9D+Mtw/lQoDRwTD+4tPcrWN4wNaGcgFm6eGyEnZh1gKHjUvu+TPuXFvo47mWYRvqNARomiumMsNNmmsFZQ8eO2hwiRJywrNgqeHEDZ5x+4zduXjm1xfqsMWndxSyFbUrV+//qeF5XRWAh93TpdBUfyEuDC422bW2HwFfzOUPYJGDLLHSAQZxI5au89ULgONBAlt0Ni4cK7MLJHZzZLr6B1h4JMhe1oaHVtJI6/TVCFgR4BrPXmeivtjJvIuQPYnT9GLGLokM7sBq13XWZd0tFded6E40oewTt2zhZJ2lobn00zJ/b nA6/aYPB s4mC68VUv1bVmZIrE/y0GNDMsVmycXJmrYSvmNJVnb1EBTwAuEPFfdqNryI0e6x1PLSGHSoczdit7oKalqOaY0O6dissYYW7KOnJdiF/5jJNeV/E/lbEUT/cnJwf3oSmve4J5a0n7t5GJuJtKfj8Dn2pNtKf3mMeYzVBGZ3v/8Wv+IN7K42V2nYYJxsGMo/Nr6Ol8II3uweG3TzizpqBLFArOKg== 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: Use mm_counter_file_folio() to save one compound_head() call in insert_page_into_pte_locked(). Signed-off-by: Kefeng Wang --- mm/memory.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 2d90da70a1c8..584fe9a550b9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1845,11 +1845,14 @@ static int validate_page_before_insert(struct page *page) static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, unsigned long addr, struct page *page, pgprot_t prot) { + struct folio *folio; + if (!pte_none(ptep_get(pte))) return -EBUSY; + folio = page_folio(page); /* Ok, finally just insert the thing.. */ - get_page(page); - inc_mm_counter(vma->vm_mm, mm_counter_file(page)); + folio_get(folio); + inc_mm_counter(vma->vm_mm, mm_counter_file_folio(folio)); page_add_file_rmap(page, vma, false); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot)); return 0; From patchwork Fri Nov 3 14:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444570 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 232B1C001DD for ; Fri, 3 Nov 2023 14:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DCF8280025; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0632A280021; Fri, 3 Nov 2023 10:04:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E47A5280025; Fri, 3 Nov 2023 10:04:05 -0400 (EDT) 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 C613E280021 for ; Fri, 3 Nov 2023 10:04:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6EB6F1401C2 for ; Fri, 3 Nov 2023 14:04:05 +0000 (UTC) X-FDA: 81416812050.09.DD0CEA3 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf07.hostedemail.com (Postfix) with ESMTP id 8600D40014 for ; Fri, 3 Nov 2023 14:04:02 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1699020243; 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=81LlqxtowmFJT9OO5iZTzQqQILthz4G91XTOFcyCEIY=; b=HyFEj2YMCFyCzTHD0a2yA4WlRwctitR1T6Tya2M8I5DAXhjRnBUrkWekGxUCibmOU3m+Oe uf2E3vF4vEnvm+6nYUPrBC4ei1fPeLtokz2jl/NWL2YZrJbdG+tkWszQOqi6qu4dcn1Ju7 DD1NOHNfWi4AsRH7WVPxM3hA2Mln2nA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1699020243; a=rsa-sha256; cv=none; b=Q1vLr6BJrpHzoleY8I2a13hP6VqRCTacWTNkS9ObJA7HHWxjTudG8LGDKnzrA9kV3B5kEM 3RvGRFkniRmUXQk4eHZwDuiuy9lv5BauVob2LpL6qymdOF6hW/x9jcXyHMaKBE/2/gAmhj YJzZhxTG9Rl/LJfxIhqwILp6EazhkTQ= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1KByz1P7pc; Fri, 3 Nov 2023 22:00:46 +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 22:03:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 14/18] mm: remove mm_counter_file() Date: Fri, 3 Nov 2023 22:01:15 +0800 Message-ID: <20231103140119.2306578-15-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 1oend5apjjht31x8c7towtup996b7r8h X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8600D40014 X-HE-Tag: 1699020242-373326 X-HE-Meta: U2FsdGVkX1+kOIg3CMdhIOOz0ya6xlZHKPQ2v5na2yseKEQcLEXlGasp98AxMwpKtYYrVoq/3ifLWhZ55TpVJ5c1hYv5tQTiWGhlKDimHphPi1lAx2QVdWnEkgydTqvlLzFLOslYZgYaESIYX0aZaSYDxK6v89mcmoXwdBgixkyGoASoYRhkqgR8MEQqK1g0p2BfGpfydEhQBtDLxd3g1XHsOO33uucP5puoTuIayacTgL1lU96qRNtHEuY+GrnNixoiW3Qe8QFERu3I48ne2GEFf9ZUsbgcC/e63SEbriEdsa5Rqcxpc98hxn5kJcPeB0tVVKle97KUMLiu2PzGJtWOWKoJppcEkzjUA0b7xYyk3t4yYOwQvozh04qjejzxLIz+YAyks/cJR20G5/lCNeB/Lv1JEtwpOyavm/6LvibH8K9gvaYifMT3C2KWbVdqELhat5NC9qSXnNIxME1PZU1rFIK2cq3qZoHkwCg4uuoM93TvE++IyFSzypeq8RSP9WIn3zgKfM2jSVA3dtBde+C6SbVv9fl0ixXps+cdOvhlVetWB9wiJXcLBej/h4Oe4a1mIq0Yhd1fSWYQiKqABy0nCs06QiMObudYVEfu8ZMZgyt3MKg2ZqS1HJiXcM4wJSYD0fDS64FpOdMJudcDTVZFsCdCTd0sWgS2w36qmNv0VHoGE9MYFQrrUiHmfq3pdmP3P447kF0lD+0JGH7ryKGw4A979zTFOUJ1x8lnClSd9a+jX7VW1ydViUYOmp1WwvMbG2JXEGe4yfkAY7lg2AfCaQ8F9Q39/M1x/KAoA+5YlL4WHraDETNJ0m3hHNm0G6DovvioFcASA2lg8LFXeTh4C2QGdZfW9QQkk5aPx+sVdriJbvdz3sJE0G0K5rORcr5wKQVGiIHjCkVY1xcgFH3r6qQ+0nGy7dod/YdKvYLTbIi1jwBG97GjMHSVVuE+JdhSFZ00MMl9lC4YI9X WaTi8ROZ Ci066P4RMAiCi9o6m8lRlhbWWgTB4IHD0m5O0aidUZ2ckHZOzCMVT38lgy+G4ndG7EBOK2NDwmnnN1ZY/bjNPglapduSVhf/Kl3SESgDs3mi5vf9rQYmpqUZUl+jMvdDchQB2NJvCEQZeWTLIc34QIXGcOYFe8QbOi6rYMkoKDW37BiGM+d3Z5SQX5vghvpE5U+T9 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 no one call mm_counter_file(), remove it. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index f5f76504b212..9353c5709c45 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2583,6 +2583,7 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } +/* Optimized variant when folio is already known not to be anon */ static inline int mm_counter_file_folio(struct folio *folio) { if (folio_test_swapbacked(folio)) @@ -2590,12 +2591,6 @@ static inline int mm_counter_file_folio(struct folio *folio) return MM_FILEPAGES; } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) -{ - return mm_counter_file_folio(page_folio(page)); -} - static inline int mm_counter_folio(struct folio *folio) { if (folio_test_anon(folio)) From patchwork Fri Nov 3 14:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444573 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 A4F7DC4332F for ; Fri, 3 Nov 2023 14:04:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38FD7280028; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FBF928001D; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19DAC280028; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) 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 09C8C28001D for ; Fri, 3 Nov 2023 10:04:24 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A240AB6176 for ; Fri, 3 Nov 2023 14:04:23 +0000 (UTC) X-FDA: 81416812806.10.B6B814E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id 1FBF5C0010 for ; Fri, 3 Nov 2023 14:04:04 +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.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=1699020245; 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=ecal4P50fwrAghsjzr7+jLbx0qZqwlf5MiupE4LTgsU=; b=LWqY3SDseDEVPbzZlgHGlvFSrjSOBBY0uNm6dcfNY3Gw2+FLNbz+OROoVcb9uqkFKbZFPP zyR8io4aQtUptHE7SM1IJCbI8jmSsjmmm1OPhXa24RQiawC4tVBxId8bBbsuIOOu8xEuUe hJnWrCBcmqm3WT21hbbR8ytyZh5ud4I= 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.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020245; a=rsa-sha256; cv=none; b=yNlx1ZU6wqmjPGGmuR6m1tPXi0uUCsU2zCyKhazV0r+HRE8Z0YozT1CEeeL8AR/hsiQN0r ArXJY+cyAAoDlxjEiPRDBKe35g79zsUBs4gPz4a8X4EGw6WNmzxbv8EWBiB0ybTVJi7zdv +QBarLPMZJEFch6SIViDK1s+3kN5244= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1c3mz1P7ph; Fri, 3 Nov 2023 22:00:46 +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 22:03:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 15/18] mm: memory: use a folio in copy_nonpresent_pte() Date: Fri, 3 Nov 2023 22:01:16 +0800 Message-ID: <20231103140119.2306578-16-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1FBF5C0010 X-Stat-Signature: xmr7h746z563qtpz1pzwj9zfj5h4rpqq X-Rspam-User: X-HE-Tag: 1699020244-466378 X-HE-Meta: U2FsdGVkX1/5U7V8CIUbeEw9IV0MccInjXsDVMdCVAzJZx0hvsYZlSWC6pMDTAbSlvEgHN3/2mB3ifmBN7kKGZEicqiDJe7sORTi9GlcB3V22z6eqeATUv9JIN/nO4A/ZVEa1B1GVvG2NAp/iXX4XHvtZKU4eqI5aC70qYm2ca5xojqpz4eisDYMBi6wnyvLEkIbm4XWRLLIaDwR9nowco4TkCGRkUKjCLruYxzs/XloCYA+UPFHgbiYLCnZzK6ODFtdgWQ88pTD2YGnRPAQ89zdDFLmb0xP+SVtV1q8L3ATmVgVF3styhcG0V2TPxUob6pv3PzaKj/K9YVmEVfgFJZhgQ6Nw+4eUI+ULATucLJQ7ddkLvyVapz68bVxEHgNXRbRXkXWpxJ0qDgBLM/sNxl2QI+h4k0omzlqR2iJZFEBgTtOC8SdkYpz7/B0R1qGQ6z6RYLD6uMprRULjUzgT1HZxt/v8HAs7jLjNviuEda0GBZTrntFVIJ9Tw8stnrJAruoLrCTI5uCbk0WXkdzX7mH8f4vwMWwjxNo2Y0BYBk8wbkQ5gfsHrv+IYI6KZaH7gLpPE4MWWN+bQ4JBZU43BWD4Sx+9rbDj2NwxgezsSKkzaMC/1Iwa1dJGGG7jcvatDPN3stuf+UXOcdpLeNb2yTpiK/6xEvayvg+RcYj6w9SWsWFLBEgqBHiHuFE8yVEUCgSnZgqa8JFR5gDk24p6FMp4IE0417NXtQibgf7PfZzQo2IEiyS2lr+H03XNXb9e2xxQnvsayCsF/V0Li1H/EeKG7yFnP7ysIkeTQUSEdWQE9+fF/K9y9vdRklRfw5AACcn/xB9ogmmZaQID+dCBQy6nV5/hF58bE3y3jbbC5csGlLFX4gDWwnvhnWX4QAyLfbKWrOlKfIXnO06sLgEVG/mSzAGmq/+KWQd3aAsd91j0urifmMJRsPJKRwxvDS6zpJJzzANwmcxFpVDLFi LX/J8u22 WwwiyBzT+IaicDNeukEg6h27V5sa3akTtfZvyfYNORjqz65zhSPcvVvvimS1tgDalg8FXnXEB+yHsVayYPP+lBf4lDHJbuN6sjpjDbtnEoA9fPzKzdE4Uc7hs6E95cqcnB684vnTw3+s+j7DK199OtSDaTmnDL3TJMGEDCdCZs2y0ngGza/15IGxxtGiWIPo/Dh9x 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: Use a folio in copy_nonpresent_pte() to save one compound_head() call. Signed-off-by: Kefeng Wang --- mm/memory.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 584fe9a550b9..fcc04dce8e8a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -779,7 +779,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, unsigned long vm_flags = dst_vma->vm_flags; pte_t orig_pte = ptep_get(src_pte); pte_t pte = orig_pte; - struct page *page; + struct folio *folio; swp_entry_t entry = pte_to_swp_entry(orig_pte); if (likely(!non_swap_entry(entry))) { @@ -801,9 +801,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(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -822,7 +822,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, set_pte_at(src_mm, addr, src_pte, pte); } } else if (is_device_private_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_to_folio(entry); /* * Update rss count even for unaddressable pages, as @@ -833,10 +833,10 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * for unaddressable pages, at some point. But for now * keep things as they are. */ - get_page(page); - rss[mm_counter(page)]++; + folio_get(folio); + rss[mm_counter_folio(folio)]++; /* Cannot fail as these pages cannot get pinned. */ - BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); + BUG_ON(page_try_dup_anon_rmap(&folio->page, false, src_vma)); /* * We do not preserve soft-dirty information, because so From patchwork Fri Nov 3 14:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444576 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 48670C4332F for ; Fri, 3 Nov 2023 14:04:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5EDE28001D; Fri, 3 Nov 2023 10:04:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0DDE28000F; Fri, 3 Nov 2023 10:04:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD63D28001D; Fri, 3 Nov 2023 10:04:44 -0400 (EDT) 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 AC26428000F for ; Fri, 3 Nov 2023 10:04:44 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7EEB1A079D for ; Fri, 3 Nov 2023 14:04:44 +0000 (UTC) X-FDA: 81416813688.24.5F055B9 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf18.hostedemail.com (Postfix) with ESMTP id 2D0821C0035 for ; Fri, 3 Nov 2023 14:04:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699020243; 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=hFPL2wSMrPcu1hJjxD+4tynyVgkuYhp6u1rBQCBIGCw=; b=4biW4JfkrKs+PZXKrRXp5RTofrqwmWMiTQCUGz6PEb3PoagddN9j/YYXwDR3tjuho02S6v qvYKmraW/zR2OzPYb0mDz0qcxGYAEgqc3O2TPOtLNLPFTw5lc9HiQEFCnrLfy2hODBoZtg /Cyt1etECeaHRp0h6GAppoCMy+ZhyMc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699020243; a=rsa-sha256; cv=none; b=bt4lj+pJlzBvh57K+PLS7b9Hul+2iCLxKZ3ueR5RRZPCteT4UZj8YD6FiqZEPII6E+V3BS mQ0j1h+SMTqECTb3V/S0FVO8YgUXwpE658waJCgiY3/GGkJ59NXA5W/yT7ViojvVv8MFNx k5h378GMUUpHIW3+WyIT+CTDCSQrynU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ1tzNz1P7pq; Fri, 3 Nov 2023 22:00:46 +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 22:03:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 16/18] mm: use a folio in zap_pte_range() Date: Fri, 3 Nov 2023 22:01:17 +0800 Message-ID: <20231103140119.2306578-17-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: cerwuifnpdox56s36a4qdswtwt9cgcd9 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 2D0821C0035 X-Rspam-User: X-HE-Tag: 1699020242-911520 X-HE-Meta: U2FsdGVkX1/XHg+vbeNGKuvW8jiXVldtSfPaREOfinlJkVuVMIZmRLShzcAf1mhHjgg2zSt/CJSiw/002C0elwGY0WaohMAgJEqZTQc76csY3WDpRCUkMRempuBBQrY4mk2P2YurSsBjHgK053ahp4+6jSAsqZnmhUxV/bOzPrQvO7ncdA1tP4nS+X1CJueVlP1bf4xKvfZJa+zaYff02EoXi0MNKDNaKIdgsj0tEKhj1bGdCFkUhSdf93YbxBg0qlcidovU3lMzkCL9Gi52QTtzGVE3hClo8stZo1aoTYMMcWAoLm02Y8u2kCJdtusM/leGYUetlnKZPSJlq9OfOnnxzybd3RxNyBCsKAkbVcOIN3WUE30Tehl42Pur5hbkclovQg5mPIOV+VUaOLd/ojK/HQKblek9fR4s9PBr/j0y5/pPzkVaRKnAX/OUiCvQmswxwAcCIwiHVm69m4/z4LJH0mnS8XhulGuT3dbHaOhOzUtzNhVi2/9DQmDTJhTR1eq5ZgCqm7vc/IlG/sZISK6NAeMLQIr7Gywg4zmhPvllxycmvUL4hqqTRof5Q8aqKCEVv6RnMFA5yocd3mqVWs1mEqWVkHDV4HYHxtBD1iZl5t1IyEYLd9HusRlSsuf2rtadIYIuSd3tuKcrddEJpV6z5GOvT+XZZQngJA8kP43RkETDz7LnyXRPxonLaXo6g7husPM+0VsNYruRZkZB3ATcA5PDDSlxyrolfGNsAEMgBILxw3aw4eSjAlrdzBS4aSdoH1gy1YkiNCzEdFf/RJ3ad5iEIOmPvat+C/iWMDhSRSQO03wk6gskxcS/5pcF94g4QdYobNSJo3ZCJG+31v4T1QdVcGNIIyaHzf0sO0eHdcnGvCwCkUytsc0UoPu0hEqkk3uYAhDaVFBamZ9t0Srl2iL31vslJzdCFevKx3MQnoYuftGgLtcnFg51nGoJfTRwMOEYZbLscDob4YH wE6/YLQk j3vDXrFZ5VT3ap43LRvjCivdGSWpmGXNOxyUgkvEUOZSjVIg0C7c2gY1M7wC5snv1Q7CQbtbVPPs182oMw4TDGxJ6NfBISX7pcb86nVAYrXiaf5DsNuVyajx4Xs99AVdPeGSKw6suEClIka3KPlAGMRkzKJAX9VgnBh4+teBztRVX4WAHYrzKXJi4T834UQY8HGTm 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 use a folio in zap_pte_range(), which save several compound_head() calls. Signed-off-by: Kefeng Wang --- mm/memory.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index fcc04dce8e8a..9b4334de9bf0 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1358,19 +1358,19 @@ 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_page(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) @@ -1423,6 +1423,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, arch_enter_lazy_mmu_mode(); do { pte_t ptent = ptep_get(pte); + struct folio *folio = NULL; struct page *page; if (pte_none(ptent)) @@ -1435,7 +1436,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_page(details, folio))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); @@ -1449,18 +1453,18 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, } delay_rmap = 0; - if (!PageAnon(page)) { + if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { - set_page_dirty(page); + folio_set_dirty(folio); if (tlb_delay_rmap(tlb)) { delay_rmap = 1; force_flush = 1; } } if (pte_young(ptent) && likely(vma_has_recency(vma))) - mark_page_accessed(page); + folio_mark_accessed(folio); } - rss[mm_counter(page)]--; + rss[mm_counter_folio(folio)]--; if (!delay_rmap) { page_remove_rmap(page, vma, false); if (unlikely(page_mapcount(page) < 0)) @@ -1477,9 +1481,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, entry = pte_to_swp_entry(ptent); if (is_device_private_entry(entry) || is_device_exclusive_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (unlikely(!should_zap_page(details, page))) + folio = pfn_swap_entry_to_folio(entry); + if (unlikely(!should_zap_page(details, folio))) continue; + /* * Both device private/exclusive mappings should only * work with anonymous page so far, so we don't need to @@ -1487,10 +1492,10 @@ 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(folio)]--; if (is_device_private_entry(entry)) page_remove_rmap(page, vma, false); - put_page(page); + folio_put(folio); } else if (!non_swap_entry(entry)) { /* Genuine swap entry, hence a private anon page */ if (!should_zap_cows(details)) @@ -1499,10 +1504,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_page(details, folio)) continue; - rss[mm_counter(page)]--; + rss[mm_counter_folio(folio)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only From patchwork Fri Nov 3 14:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444584 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 53BB5C4332F for ; Fri, 3 Nov 2023 14:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBC8C28001C; Fri, 3 Nov 2023 10:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6A8128000F; Fri, 3 Nov 2023 10:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C593228001C; Fri, 3 Nov 2023 10:22:21 -0400 (EDT) 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 BA41428000F for ; Fri, 3 Nov 2023 10:22:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 529A2C0A56 for ; Fri, 3 Nov 2023 14:22:21 +0000 (UTC) X-FDA: 81416858082.08.B70E050 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 44627C0019 for ; Fri, 3 Nov 2023 14:22:16 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1699021337; 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=ACB6BvRM+b+Bk9pCuWZqJNSMpJoUalDpqlkAQM+jcRA=; b=c5rBwdYeR0zaswuroduPktkOShBn5+hAmuHYABPIQHkh68InxVj0NbqYwjQ0HJhm/3qexL M+PzicSThqU2Qt6fPiIKmeJqxWmn97x8Bikei+2SVksQFr9x9bgbIt6XOjQi6yeIlK/3WW FeMwquxxrgAjkrk4YLuA8by1y8zvRNo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699021337; a=rsa-sha256; cv=none; b=qOyLLNYoS7viXOqodYD5HV0FW5dmR69bxeDQ/NsrD7FW5tCQgxbyYJ7iaJgaoNbDjoUErI G4G/aAIU3BYrpOoRYUKEa7u0gFhSkIYX/8OdyQabk5I8Pf4Typ4ZQloZuKCcSQ4ZvkaUM4 N9KUPqVE51HmU8a2a8Cjh5btxZiOt8g= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SMMpP56DszrRgH; Fri, 3 Nov 2023 22:00:45 +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 22:03:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 17/18] s390: pgtable: use mm_counter_folio() in ptep_zap_swap_entry() Date: Fri, 3 Nov 2023 22:01:18 +0800 Message-ID: <20231103140119.2306578-18-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Stat-Signature: 9eqb36q7dw47sbkz6gisit9jbqw4jfwn X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 44627C0019 X-Rspam-User: X-HE-Tag: 1699021336-300041 X-HE-Meta: U2FsdGVkX1+PKpc+aLrAZ3yJmtgvZKRW3hCQuSYS7JcTkepvDjb4mzsFe18OjgjWOvfGsUnl3WivENw0W2rK5fArr1BVt+nSIW80jCFt7XyJh3blYPKN7BAB91mP+uEMCsOKbU9MGeFKifVVhVcdORfO2fQ7ApnXKxH2udLk6i0UA07BeuPQ5Us8D5Q/nAnHRrkuQzSTyiNFaRpsxFiNm2cYyDFlfF8Iv6Vcyb7Xm8UT6jVss+xWjF2+OIr6Y7IUdLO0rgU9tlNmPPZKM9sXHaEiwN0cb158UDLU0M7d8scB35M+eXS5RU55rnuEq3oed90bTZe3LWERUkaYuzzPGjuJhlVQ9q7lDRBE4LD9WOaqJ+rQDXoRglzDVAvqWpoQn8Bm4UpaH94z4FFcEF+srBdQei/l44aLTeQgpEBXEWO6azrG1be0gsfGMK5rYinzT8y4aamwm/CJ+AtExRMQ160twft7upNGxx6oI8vYyjOoJRWUGK8OinYSnnX/vPxQckGBN5t1wQtmXNjWO0n69VQ9VP9CYqBYWyJhLVXczNXNoWRjVVs+81AJPk54Cgn8qk11BoF0OT4loNWVCuzWBmfeCuWEcfUK5irUkdo85giZQC9MPwus9josen7jzVPsJjzCzFlwtdTd0jeXXrfm4WmhFj03AF+W/28+ep/RlrX7cVoRehQ7PiUKjCCuwQeRDeTBp3pXseksLxAt6Z3HsDKhj14PjX8mNlIZoW6zpEvNy5DxfWmJMg1guoQnF5uYZ6zu4IHSDRbT+/lSCY0ZYvPBr3tpd704i9YjQF4Vtj5jdtfw1mkrToAG/mpRuIp75ISgykbdvMam83M6xL50V1wddwOmCeAREBKMwQwbq4IVbAJMAwplQlAQElXoWPnD0ouyY2Ivf0U4Pmt+qNcqsVqyleERDpOO35XPVpHcC0bPtq+N4Io8ONtqZsAi81J0WXUskBsJACAyF05kjVo vLZIUGRh XltzIuehHaycyFs3EogHIxYKpK58admyhPLaFE17+SCWjdtt4TLHnSj/UAGqcDEBJFByobSFpUa7cGD3LBJD8olL0AJC1M5WnKxnoUFf8vHT5uEaJ6a18AKywgUZW7mo2FxbhNDQUCWKFN0Y981HI0ONGXNKioRqpyF8dGJZH8XDmdAghoC5HPPGOysUQjxWvKn5E 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: Use mm_counter_folio() in ptep_zap_swap_entry(), which help to cleanup mm_counter(). 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 3bd2ab2a9a34..f4a53f5b0bcb 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -730,9 +730,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(folio)); } free_swap_and_cache(entry); } From patchwork Fri Nov 3 14:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13444585 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 AECC2C4332F for ; Fri, 3 Nov 2023 14:22:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52F7F28001C; Fri, 3 Nov 2023 10:22:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B90F28000F; Fri, 3 Nov 2023 10:22:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35A3628001C; Fri, 3 Nov 2023 10:22:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 264C528000F for ; Fri, 3 Nov 2023 10:22:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EFC58120279 for ; Fri, 3 Nov 2023 14:22:48 +0000 (UTC) X-FDA: 81416859216.28.44B6BC0 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf24.hostedemail.com (Postfix) with ESMTP id 902BB18001E for ; Fri, 3 Nov 2023 14:22:46 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699021367; 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=bT9rjnlJIBzoJO+q+XewwA19nOTPGvaL2JFKF5wptBI=; b=73rSv78JjLac+k29MfdkC1yFKKhQVjUyZg6VnQoonRbiOXBsq8XnFTCP1zMpDHkFlo5Wf9 +INDfmiqjVAalWo3AelwSzqEqUHS65+4HHZm/F4UbX4z/CKKTW6Sm0rChT2c7eZQf5mQGu fEQSy09uXKjs94eSf78dn5vHDBfoc+A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699021367; a=rsa-sha256; cv=none; b=Ybhg/mNslfuqak0/V7wu2AG3+e1J52ES2fjpj04IqEuYqZ0WfnfBLm/Oku6kU6YeDoTY4w 4tJVB8igBnBrjU78Rwt0UnhJ0s4u0Hx8d3Ma3g88lwRFxykAg1X5I0arnPVNxpNqH4Ut62 SVfwdODw+iEN5KXQluffn5ZdtsGRAHE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SMMpQ6QHWz1P7n0; Fri, 3 Nov 2023 22:00:46 +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 22:03:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 18/18] mm: remove mm_counter() Date: Fri, 3 Nov 2023 22:01:19 +0800 Message-ID: <20231103140119.2306578-19-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> References: <20231103140119.2306578-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 902BB18001E X-Rspam-User: X-Stat-Signature: 85iayqeh4xbxdgacmge1pmrkxzs9dczq X-Rspamd-Server: rspam03 X-HE-Tag: 1699021366-881287 X-HE-Meta: U2FsdGVkX1+a15xl7Wtl9hn99j8bQaODH1IczifljuXImnns6JKTqaSod834/vsAIuQwRWyhgRD16Puq2tFP0QxpIvxXdyF0av8APqAmufL9A1ERPdjL9RFHGpWn/y26zohzs90ovX2HL1iF5yRlpe4AFP1s9h3RK+CaxI6tMCXbeQYTuGa6s/1cO+ClfG5oZU++hR0+Sc89GXcYrj5rPpdnA4dtcNLFqyrXNOuEPl3RGW7Pav4GboOGl7QdwgPnl/ww1+pBvcmmWIixG1DpQC1AJE8oFiwLFlFAi7uN8MMeX1jWmW5nuy2CzLS0ni/Kn1bh7A6vGKOL3wq+F0KZ+eeVw1cG5/WE4ZLGUR9QFPhPz6P1l9yvBfECZNehHKcfLovGUDV6v2pdo1dSmEh2Qw3e+TI0vVePkBTjGTVqYnkJyhl+ycpmLsI0pfOSrSbLCv5GxZchIfojEldhV0CbQLODLzdR7aUzVkiISoSuz7l0QEw3hTCn4rcVFg4JHz0VehA6TYe+9CLUE8d0I0pX30NWL7NJR7mTtSgXHRrPqPMp+Q8RHsEyZkTU62SpyFruMWsvRqNyfDDYLq5wkUmXuGTe9OxPqf0VtZO9/v8KL7BUx3c3JVKTQNPFsLRhVcVR6ramV0BBptbkzKONV2u8zrfpCeY48VigUFuA3QuodX91djoTC+l1W7mB1c48BJDocp6/oZb07ShK+KKw+UN+lKdKbYaC8wvf6jbBDh5bs7XUAf//yNhBPrYJITLa4XprMFiVoz9swnnKjaBTle6imSz7/4Vi9F3o+IKzmwhVkYPWODY/QS875mzpH1O4xQRK7L5Nwure4VpvY02qEpOVWTc8itz00HiLCtF4pho4/B8hBgSN+Ni7opPBpQHD8SnZYVMYd7hWF1fIOxF16FmCulTMPhdHSSIW8o9/nxva8ns2fZ8zh9LN6aaHOZOgrSXjmlOJ06uj4xXnobyQiBf auK0sS2G joJGpwMsM+AKqYBLc2yINCc8vkOH4Q+gQsx6fHe5Bwwyha0hHTKNPVy2Gh4d5ZYxXBMccUoCfxWoFdvW4NlD+RzcfYFTubjdjfimMg4Wdes0igG21ONd2zos+d29OG3rxQyH8eowTTzSFsdvU9MyHnswseOcZEqxK1TNrRGJtw+eVGqgT9ShjFVkcZpm5nYLYD6VZ 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 no one call mm_counter(), remove it. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9353c5709c45..fd1a27bbdb53 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2598,11 +2598,6 @@ static inline int mm_counter_folio(struct folio *folio) return mm_counter_file_folio(folio); } -static inline int mm_counter(struct page *page) -{ - return mm_counter_folio(page_folio(page)); -} - static inline unsigned long get_mm_rss(struct mm_struct *mm) { return get_mm_counter(mm, MM_FILEPAGES) +