From patchwork Tue Oct 10 06:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414874 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 E6270CD68ED for ; Tue, 10 Oct 2023 07:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66F308D00AD; Tue, 10 Oct 2023 03:07:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61F3B8D006D; Tue, 10 Oct 2023 03:07:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50E288D00AD; Tue, 10 Oct 2023 03:07:31 -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 3DF6C8D006D for ; Tue, 10 Oct 2023 03:07:31 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D9A021401B5 for ; Tue, 10 Oct 2023 07:07:30 +0000 (UTC) X-FDA: 81328671060.24.D06366F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 4EA5E120022 for ; Tue, 10 Oct 2023 07:07:26 +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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696921649; 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=0xbzl+RRPO9YDRU0w4/UNxHSJngCPUgSKYZLF88odr8=; b=0q/PSUcmQqFQn53CyoDeWGTlFZoUPK3WuZS1YNPCY5VR75niDWzpQiQSPZA6v3u9Lb10OZ WNk/dNY++I+hysGWMxv9tNDJhZ52ODX55K5r91CAU6QN2mQFTdLgylJguKfCc/Sunnb/to Fz77km7A3SOwwS/YG9KFpcJo80TVgr8= 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696921649; a=rsa-sha256; cv=none; b=0qRwkVHcxujv07Oti29Zfwep8LWOWvn9nBCVBjPVhTcjJaCy+X1EZlzgIoVRcoe65ce9sh beIEIkNdFVI1mJNmI//C/9LNUokcWg36xVEQ7hC8rNmktJjUEpmT3JcujY8IxBpaHWmgva ItNg+RqfBIRHtj5YkFqgYeQF0e8RDxY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S4RDZ0Y2gzNnmZ; Tue, 10 Oct 2023 14:43:10 +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; Tue, 10 Oct 2023 14:47:05 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 1/7] mm_types: add _last_cpupid into folio Date: Tue, 10 Oct 2023 14:45:38 +0800 Message-ID: <20231010064544.4162286-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4EA5E120022 X-Stat-Signature: dfz9stn7c664yjkedsefan4unfonkuiu X-Rspam-User: X-HE-Tag: 1696921646-505273 X-HE-Meta: U2FsdGVkX1/FyBzVRh8hYwEI+MgIeGL7V6rmTWe8YKWVWmQOY6EeBNcd6L6v4nD6MvkPwsL3MNOJUPecdbPzASR/BRJjE0AKeia/L05RncAeCGOXzP6Xjwtt3WG64cpr59qHnSjFIazVAlybUN30hBv3uRIQK8rKaXJzTNZzS77Z0w4D6y2roIXau4v9VVDQwQcpA2ke4n/JPGVUMa8MA+dzkPN+si1uxqVoCKfgoBXHDdEmuN7fgjXQ8/cCd6zoeJiuWCgSaaqfpZGBpM/fuFkMZnPNGeo3G95PtXgZxUpEngvOws8UH1bh10gcTR1xSMTePHMcakKr1HhIgsGzGiLt7TreFpgAA4jtwDdOqmbT8blmuajgH0vynIY/13gxE7bVjcMrlaJMfuxx9G4Hs4UrbGp/1Ih9XyqJ7rysYDJqO0PFJdeN1rLJZ+KmW5hKJgiz/yVWff7OPalC+k2/y88smBIJSjYwJsJbldqL5FGfybz/tWJroplUWbMeudsz/xDUdg6G7WnHl/bM/wz1V+4gy/Shv3SgXaTyoAMbVr0qoq2TMGCRp20mhx7rQyMawWl+wFG0+1X5Zixfv4QI96L/Nq4V0brIeqPftYZpRmrRLjX/hPledau+qLTUfrGEFphOaStnIwelsyTEeGDDdKoFEB0eqKaOSqzS8KX4bzPl9HnYMCv867bzPb8H7kKzQdM+dF9SaHdSWp2WP7R2hvkK5MEBwy0RL3JCPTtldW9/2Y2UsUwqFIZKH3vCw9L+JD5p1jzWNGyO1jpVeTKXdUPsKjSMCPOkQMfGqED0tsgeUxQvJ5jQeUfAzR30AuZStdje7S6uFMR/TprwMLN1j7/VNZkN/SsAKCznqgMz9zTFm3pFNhjgKbqvZPpe0AFsLG7pF4YUlDtlFn4ISRTmHLXdbnG5pSCef9/ql1ymTzT6DH7/6vGS3Pbj0RkoTypzu2Y7C4ISPGwJEjwrSEt MHvpCQCR VjGxvRToAgPMPS/UVMik1/FdCsR0b55+W/xqnLsGjs3IjUMR+Efti12mpTbZhYLnvdthk68TGIGGbaZ7IaMYBJAviFO2OC5R0qUFlzN1M3Ty4n2FotdqscfTeJNztAvbSLWX0Nc5qarSVCRJMJPpVj88qiZ0vFuEeOtPAPiFh2hoiUOTyVvDbiQzFHRUHC1zMPHCb 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: At present, only arc/sparc/m68k define WANT_PAGE_VIRTUAL, both of them don't support numa balancing, and the page struct is aligned to _struct_page_alignment, it is safe to move _last_cpupid before 'virtual' in page, meanwhile, add it into folio, which make us to use folio->_last_cpupid directly. Signed-off-by: Kefeng Wang --- include/linux/mm_types.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 36c5b43999e6..32af41160109 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -183,6 +183,9 @@ struct page { #ifdef CONFIG_MEMCG unsigned long memcg_data; #endif +#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS + int _last_cpupid; +#endif /* * On machines where all RAM is mapped into kernel address space, @@ -210,10 +213,6 @@ struct page { struct page *kmsan_shadow; struct page *kmsan_origin; #endif - -#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS - int _last_cpupid; -#endif } _struct_page_alignment; /* @@ -317,6 +316,9 @@ struct folio { atomic_t _refcount; #ifdef CONFIG_MEMCG unsigned long memcg_data; +#endif +#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS + int _last_cpupid; #endif /* private: the union with struct page is transitional */ }; @@ -373,6 +375,9 @@ FOLIO_MATCH(_refcount, _refcount); #ifdef CONFIG_MEMCG FOLIO_MATCH(memcg_data, memcg_data); #endif +#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS +FOLIO_MATCH(_last_cpupid, _last_cpupid); +#endif #undef FOLIO_MATCH #define FOLIO_MATCH(pg, fl) \ static_assert(offsetof(struct folio, fl) == \ From patchwork Tue Oct 10 06:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414848 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 650E3CD68ED for ; Tue, 10 Oct 2023 06:47:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBE8A6B01F3; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CED026B01F5; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6636B01F6; Tue, 10 Oct 2023 02:47:13 -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 AC9196B01F3 for ; Tue, 10 Oct 2023 02:47:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6BA9D140199 for ; Tue, 10 Oct 2023 06:47:13 +0000 (UTC) X-FDA: 81328619946.16.8CF7389 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id ED646120013 for ; Tue, 10 Oct 2023 06:47:10 +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.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=1696920431; 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=fVfwzDbo5Kc4i4rlTbkYOzLkB4fLvg8axYuIJPcNuUQ=; b=WIO47HvCG47k21RCy+gJW4NHuiQU/9i/Z9rRjXMnAREK1EnKya0+Z8+THSUk92AxWCbAdl i53FGZfIj+TCbhI7nYjHw24WXOIxc+xfmMgARgPt0s3+q5c90xuUTpuRvYAgguy3Zv+uQz TFDI3T14NCMvJdH/k2Jv0bJrzQeCF4o= 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.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696920431; a=rsa-sha256; cv=none; b=gsCnw7R2s/UWZsW7VaiAUorJVw9WprIlmjAtp9TO5a7CySRleArWDiBIIsh54RO4wMv5yB c+D3JkvCZfSABkAR70yQpmrOWL38oANNGQ6Z3eVFAZE+tyhKAdHc+ZPYj0OYtvmLsCFGPE MQAqQnw9lssw3Ah6Hi8MJAurUSMGEkc= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S4RCp2SByztT2f; Tue, 10 Oct 2023 14:42:30 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 10 Oct 2023 14:47:05 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 2/7] mm: mprotect: use a folio in change_pte_range() Date: Tue, 10 Oct 2023 14:45:39 +0800 Message-ID: <20231010064544.4162286-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: ED646120013 X-Stat-Signature: cxiy6enkpzpfx6j7b7ed96z466z84czx X-HE-Tag: 1696920430-122846 X-HE-Meta: U2FsdGVkX1+K+sQ8PV5XVaLjDWyO9ADgUsekxksalw/0qG7WgYTYT4KzNal5UUhs9sBnFjHAvT8xDksnUww1+Qppg//FGxhtJ+ctO5XPMxODFuKTXBcbeEbpKwFW+yD59nInVXQd/mHi7598dvfuSxJ3DHP4rOUjNBQ1nDQJJ+CSGQqMuvOOUnp577+xB+kwHuV7XksDydPdpYKQYdjfBFqQt0bQ+N1RmzQnsxxFSyNnGjcbteqbJGPhpgWj3wcceUPLCaIyf3Jw6gjjSW7bFuB5+vbHoQAc71IxdpLRno9xI0O738IpSy135EuCRURXE0YA8gl/FFK3lrAIn1EG3X5ewvXDkcFFjyE+bF+5oRWB4zV0L3PTqlzaZPUWHwEkxECNEHT5jvJUXIE0tRfCBkt3U4K2oYbMJjo5UdGq3IyVQvBAQ/Kl0E2klz3QfzAAD2NXyT3k0G3JYPSZuEaYtBP9ivdGoQSRc1OE2b1rub1CJFL/kh0ZqxD5wI4YldBGjKq5xtUendO94Oo0WOAZhxao2CO8+ksi4hMje+1R/Hi/RMOcgR4Nm4t42tMrGLka7eLx21VycdhDYVpl4n1XFmH/6IlvdG9sebiomThqHv1lyNuzvurSryKl0pZGLcR3/ciz97Y4JGl+corfKLB0sUE8768xigM6wY16xjxtc+a11dX/mwFyUCNOkOvSd9C8cWuvdk5wtbgFi9Kk3NsLr4vPuMbxy6qBhQy/vEIRJNOIvIHFJqPuICfqPP4bd8Exy1aidqfKL59YW8N/X0UUwb612wDkWZh67XWxHraoMYz1SxkQGUmtdQ+hXi5lSkF3numX7o6jG7xyXpfYGa8Id2sc9o3Ej8u+qB0EmGpgnz5bQGxHO58rl5YCdaCyCfJNPugUSp+gqA0Yg1tCE5lesdu4mo4dtxvJk9s8UWfx5edtYfwVSqtAMWLODcPi5I/aAjDRKr4/yOzfaiWLV5G zCcJO5f9 ypLIXgoWoOLRItGOo4qIY2to84ijfraw7XW4ARBaMrJaCsWjBeX9xkmGz9W7xUjk72Py7NDvKx3A1WiR1X0G9kN/pGzqMetNVMTN8R/pojE/dc5Jq2klhAec9Q5t+LLOKD/KWcFJD7c6/SxMW1Gg1xp95IeQfYoLuTZ4YMknF1i7Jl1BhrkRIgpBypF2pygRT+jVmR4DH+a+sfWTnShpZLWo1o8JGnvDPeE39b/3k1Q3F2AZ+gIitrToE+0Nuhady/xphA2D4XblduoFpd3Kzc+C5StUz5Vt8e61O 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: Use a folio in change_pte_range() to save three compound_head() calls. Signed-off-by: Kefeng Wang --- mm/mprotect.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index b94fbb45d5c7..459daa987131 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -114,7 +114,7 @@ static long change_pte_range(struct mmu_gather *tlb, * pages. See similar comment in change_huge_pmd. */ if (prot_numa) { - struct page *page; + struct folio *folio; int nid; bool toptier; @@ -122,13 +122,14 @@ static long change_pte_range(struct mmu_gather *tlb, if (pte_protnone(oldpte)) continue; - page = vm_normal_page(vma, addr, oldpte); - if (!page || is_zone_device_page(page) || PageKsm(page)) + folio = vm_normal_folio(vma, addr, oldpte); + if (!folio || folio_is_zone_device(folio) || + folio_test_ksm(folio)) continue; /* Also skip shared copy-on-write pages */ if (is_cow_mapping(vma->vm_flags) && - page_count(page) != 1) + folio_ref_count(folio) != 1) continue; /* @@ -136,14 +137,15 @@ static long change_pte_range(struct mmu_gather *tlb, * it cannot move them all from MIGRATE_ASYNC * context. */ - if (page_is_file_lru(page) && PageDirty(page)) + if (folio_is_file_lru(folio) && + folio_test_dirty(folio)) continue; /* * Don't mess with PTEs if page is already on the node * a single-threaded process is running on. */ - nid = page_to_nid(page); + nid = folio_nid(folio); if (target_node == nid) continue; toptier = node_is_toptier(nid); @@ -157,7 +159,7 @@ static long change_pte_range(struct mmu_gather *tlb, continue; if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(page, + xchg_page_access_time(&folio->page, jiffies_to_msecs(jiffies)); } From patchwork Tue Oct 10 06:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414853 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 C65AACD68F1 for ; Tue, 10 Oct 2023 06:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B6746B01F8; Tue, 10 Oct 2023 02:47:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 267B98D006D; Tue, 10 Oct 2023 02:47:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E0F96B01FB; Tue, 10 Oct 2023 02:47:19 -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 EB0B66B01F8 for ; Tue, 10 Oct 2023 02:47:18 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B9FBC120187 for ; Tue, 10 Oct 2023 06:47:18 +0000 (UTC) X-FDA: 81328620156.06.258907B Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id 83BFCA001C for ; Tue, 10 Oct 2023 06:47:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1696920437; a=rsa-sha256; cv=none; b=mhloFbfGuChHtjEnSKSvbVExi6q0qDLU7qdTfebsSjeHVUCxdcKQwzhOI6UQluLdkRoEyq lF8fi7YcGqfNU80rGCCieR1BY534j9OItXmUsbv7B+rGmrtkwGr8BNFx68wpgipyE+eFE2 Dc+7nbpsKlOjcf6cxD/3sg4VigngEpo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1696920437; 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=D2Q+I9WNfmiKTucK67xuyjIk0gAn9DIZRjRlHWYIALk=; b=lnsDbCcQagdgSJq4fwyivEkkJuLvDE0+aBv4P0cPCLD9k03mjBJcPvcWSLiEExtKQhPV/x BQPRqUSIkHEDhoctc9rD1R5qPFmSkqg1rdUcS9Xb3hQ6SVa6tqtU32Ubc982n0z4JhxuZp W1ppE83NtdZbCVuKl+mSpu8Qsn7rAMU= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S4RDZ077WzkY36; Tue, 10 Oct 2023 14:43:10 +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; Tue, 10 Oct 2023 14:47:06 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 3/7] mm: huge_memory: use a folio in change_huge_pmd() Date: Tue, 10 Oct 2023 14:45:40 +0800 Message-ID: <20231010064544.4162286-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 83BFCA001C X-Stat-Signature: 88kxy87uisw5zsy78xg5yboi4fxmipqx X-HE-Tag: 1696920436-31342 X-HE-Meta: U2FsdGVkX19pW7MYoRNjRGTcGyrClCKaAP9/aZpl3eCNAf81Q/XNSdsnd8giDc98S/gAbgdvS8pF1M3mT7zf+CkYzskPCqhM9JIPxxZ01uqtlhBDaB8s46w1ARZaGbzgoATlkzSLtXExDM5HPo/I1wLIYtwETNpJmk8bAaetPWsxeu6pGGBqMn+GGDMinTefHMui+2PuGtri76Kx4SNrJ8KlNmWow5vC2Fz8+ad73+MrQ9u7Mnf8NRpIPo4kvjeXx5sCu/FO3lc6y9gj2YjnayJZ5j3WzAa72gTbXmD4oVvpto7Cntah/mtiriqB+nI8vuXEHWXXVa5WY5NR3AJPV+xQzajVIO2HIyjj40uOaC5Wm4Oj17b3EU6fYWpb6W43Zq6OuzMdbomuidDZ2O+bDS7Qp/aknEUf73pNjHf1n5aS1idi83HKkdV3b7Hj8U7DLOYuAlxDGA6gQSerdgndMMe01YQTB2Xd8is6RaNGTP8Qp3GDCLvnitK+A+paBiyWjjgCz7KD39rn1wFCki6+tPrm/Kam5BAV0e/ZsFb6cDTxhcobz6BUrKg2lynSQ/5pBf3yVdUJAvmfU5H/mWf9aoJUqn3Fq0bTq5/cLx2WZrsxylvRPunXpGeVsXVJBSnPfls8wTltNrmWsTce3jCy3zD75/XUT3zcWi3cHyo1/9NR5ilSbrwYOlq8ji4FiglJV1oiG3k2NS2noGgz1PxgazS3Rfil14Olfv2ydOCB+D8NOUCcIE/C7KsQQiHs9h5/DPsGh7Zx3HxPzzv8heTAwZwMHD6hROS7FqLktOUT9kPYGN81m5E00VrUi+NznRQaNE/x6EKnElki4Tkgp7ZDNRCd2a04vX4z5tcuwPeWAwCyxzt1kTPrJDb0DD7mRP+Z95I7Km32Oh2Bx0VX5HTj90fGQATJ58PMJDcshz7l7kJiNmbQ2sxnpm2ceOdFKfmv1ybdTQUfBWWj0ENhgzu 3TJQsnxB jCdLXNs5ftBCwodu9El9/OSxtaUf+s3y3k/7n4Dwe+3s+GDdI8w8vyTmRaFzJspWz4GZ0hv9PNgLdvXB4hTaLGwdHUmoWkzqmAb+jc0aVLZ0zqk370XYMveng1GG8ki3u5XPa6YkX97ZXNhnXvZTqVLL1eg1z9gteWEsHdYFb8nGmKdQflLtvxlk2aqR5IGMWt0SA 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: Use a folio in change_huge_pmd(), this is in preparation for xchg_page_access_time() to folio conversion. Signed-off-by: Kefeng Wang --- mm/huge_memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index c9cbcbf6697e..344c8db904e1 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1856,7 +1856,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (is_swap_pmd(*pmd)) { swp_entry_t entry = pmd_to_swp_entry(*pmd); - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); pmd_t newpmd; VM_BUG_ON(!is_pmd_migration_entry(*pmd)); @@ -1865,7 +1865,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, * A protection check is difficult so * just be safe and disable write */ - if (PageAnon(page)) + if (folio_test_anon(folio)) entry = make_readable_exclusive_migration_entry(swp_offset(entry)); else entry = make_readable_migration_entry(swp_offset(entry)); @@ -1887,7 +1887,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, #endif if (prot_numa) { - struct page *page; + struct folio *folio; bool toptier; /* * Avoid trapping faults against the zero page. The read-only @@ -1900,8 +1900,8 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (pmd_protnone(*pmd)) goto unlock; - page = pmd_page(*pmd); - toptier = node_is_toptier(page_to_nid(page)); + folio = page_folio(pmd_page(*pmd)); + toptier = node_is_toptier(folio_nid(folio)); /* * Skip scanning top tier node if normal numa * balancing is disabled @@ -1912,7 +1912,8 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(page, jiffies_to_msecs(jiffies)); + xchg_page_access_time(&folio->page, + jiffies_to_msecs(jiffies)); } /* * In case prot_numa, we are under mmap_read_lock(mm). It's critical From patchwork Tue Oct 10 06:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414875 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 CB173CD68F5 for ; Tue, 10 Oct 2023 07:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 696958D00AE; Tue, 10 Oct 2023 03:07:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 646438D006D; Tue, 10 Oct 2023 03:07:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5356B8D00AE; Tue, 10 Oct 2023 03:07:34 -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 449798D006D for ; Tue, 10 Oct 2023 03:07:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F45A1201BA for ; Tue, 10 Oct 2023 07:07:34 +0000 (UTC) X-FDA: 81328671228.20.DDA78AD Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf15.hostedemail.com (Postfix) with ESMTP id 7D96CA0011 for ; Tue, 10 Oct 2023 07:07:30 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.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=1696921652; 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=0uwKJj99/Y8Pf2rPvldDN6ng+RGtC1wBvwQMrNRaK7o=; b=wp8QZhFxMi0kKtxNXCnLyl0Ba1fhUTn4DLR0HuR2GBQr0r7IdsHaghhplAJnv8OvCDEDOe IWGf+0dS9Kjb0RpK5bC+v1HfiVrx1eKs/eNkmGlWDixhNNZ4igkly8uekIjCkkXEdPG3ku pEA3g3rYdrS+JG5jihTZa/jq4XD8Aog= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696921652; a=rsa-sha256; cv=none; b=7ALCVu7kiXFOfBTsDIfmMdQvsipGxU3JwNSPwhLigZd8ZwVDfXXT1u3W5G7qHTiMpnSn8m jln0v+ctumU1B/5m7l7DqfiIHFsxpUGH3yhP+RHtYJdWnPYFN4wKP6sDLuAGemZKwU11t5 XGVjkRm6tuBib30bFJLGOHKL/7Cf3RY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.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.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S4RGC0pgcz1M9D3; Tue, 10 Oct 2023 14:44:35 +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; Tue, 10 Oct 2023 14:47:06 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 4/7] mm: convert xchg_page_access_time to xchg_folio_access_time() Date: Tue, 10 Oct 2023 14:45:41 +0800 Message-ID: <20231010064544.4162286-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 7D96CA0011 X-Rspam-User: X-Stat-Signature: fyf4dta5ggnxmqrwgftej3hitperr844 X-Rspamd-Server: rspam03 X-HE-Tag: 1696921650-818112 X-HE-Meta: U2FsdGVkX1/iNlSxEXTQB3BuHxiyFNVsrH+oqouA/YK69zcKWYtqGGaQ+cpfzmldSsUGF15B2TIoJyCsV41qHIdb1FYvXYAvM4j438QugeUC1FDXFclbKi8gKHCYvf6KzL6CAFty5bXBbGwXkYyNn0XuRP24xKqKVs4wqlaICso+ncvLBdDe9Ecok0uteVqBQnVMDFOL0uLrKTw5Q0JsGseIMAH6bb8fz1wdw4bCzqLFgYCflD4FlExw5RufHG/goDK5Mt+w69RpVOPLv5JEd9z9eeQ51rNWVmy9S7wgeJcVpTWSe8U5jePJI0F4G27pi/eQMLaJl0yyX11GGSKvThTv/aMWl98EKBZb3GsVqW53h+enGhWa3jik/J8+XVGwhjzF7JFGrrkrYFKeSVSvNVDiNAiU6aUGnmR2yJPEYFcBbL35EEo04twdpZFGl/5SC15BBymm8b3IPfBy6hL327IVA90CD8W0uuv5CJmejRb+pVQxZt+6w0LPQROOxOxh+8qukI97wNCIQZolLr6R55TEdE2WF4/YS4Ut/2QkyOsDLBQHqxWWs4g3XYgpSFDC8Gwnu06FR4cJvRTeZcUzQzV4dNaswdoH7EJ714hrrx1sWAtPI1/rcFad+kx1rQFJ7JI80rZIS09zQzLa2MrPWRkZ/paxoaoe1Z/6DNO29R3ojosRXx6Tt4MHJu+hD/XKH+3KVqmjE2jfKljufGCPgl0c9/XvqKiz9mCeYsNNxgNqkfLyXdspJ+meACILjIxvDM9crMR8PnxlBtuHUvV498ri4bPE9Y4BfOeEgnBuVQFV5XEH7evcXpPB3IU5bjLrjCS0L28gooA/uzO4qko8334dXmbcGhjsynrMiNsU0H9ySRqHDxF27mbojSrqt+WEvzo7XJhA+r2C9helf+dRL++SA4P0ao+IqoQQ4yiX1TbMsNcja+5CACIZDzQ9XCZ5o5TH8TbTpkAV7OmqGZK Go2ffSSP kM5AxYuR6WiOomL8/EhkSXDYI0NnzOdliY15QXxm+7HD0qxyBWI7xn2osNpKSOwmbwHv6UWqTvQ3jj28lQeYf7qcJyyqym+IUlXgsS8PE1ZawJnHufZvR7msO+vKE2AvjY747EeAU4t+934LFyn+BOMSN3HEsBGdrTWofBnWnmmxWCJ4vc5xqERL1HOW3HEVT+hR4 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: Make xchg_page_access_time to take a folio, and rename it to xchg_folio_access_time() since all callers with a folio. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 7 ++++--- kernel/sched/fair.c | 2 +- mm/huge_memory.c | 4 ++-- mm/mprotect.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a10b8774cc6f..13ca63efacf7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1711,11 +1711,12 @@ static inline void page_cpupid_reset_last(struct page *page) } #endif /* LAST_CPUPID_NOT_IN_PAGE_FLAGS */ -static inline int xchg_page_access_time(struct page *page, int time) +static inline int xchg_folio_access_time(struct folio *folio, int time) { int last_time; - last_time = page_cpupid_xchg_last(page, time >> PAGE_ACCESS_TIME_BUCKETS); + last_time = page_cpupid_xchg_last(&folio->page, + time >> PAGE_ACCESS_TIME_BUCKETS); return last_time << PAGE_ACCESS_TIME_BUCKETS; } @@ -1734,7 +1735,7 @@ static inline int page_cpupid_xchg_last(struct page *page, int cpupid) return page_to_nid(page); /* XXX */ } -static inline int xchg_page_access_time(struct page *page, int time) +static inline int xchg_folio_access_time(struct folio *folio, int time) { return 0; } diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 682067c545d1..50b9f63099fb 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1722,7 +1722,7 @@ static int numa_hint_fault_latency(struct folio *folio) int last_time, time; time = jiffies_to_msecs(jiffies); - last_time = xchg_page_access_time(&folio->page, time); + last_time = xchg_folio_access_time(folio, time); return (time - last_time) & PAGE_ACCESS_TIME_MASK; } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 344c8db904e1..e85238ac1d5c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1912,8 +1912,8 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(&folio->page, - jiffies_to_msecs(jiffies)); + xchg_folio_access_time(folio, + jiffies_to_msecs(jiffies)); } /* * In case prot_numa, we are under mmap_read_lock(mm). It's critical diff --git a/mm/mprotect.c b/mm/mprotect.c index 459daa987131..1c556651888a 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -159,7 +159,7 @@ static long change_pte_range(struct mmu_gather *tlb, continue; if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING && !toptier) - xchg_page_access_time(&folio->page, + xchg_folio_access_time(folio, jiffies_to_msecs(jiffies)); } From patchwork Tue Oct 10 06:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414852 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 0325CCD68F5 for ; Tue, 10 Oct 2023 06:47:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 920CC6B01F6; Tue, 10 Oct 2023 02:47:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A81F6B01F8; Tue, 10 Oct 2023 02:47:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 797556B01F9; Tue, 10 Oct 2023 02:47:18 -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 6B47C6B01F6 for ; Tue, 10 Oct 2023 02:47:18 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 409DA4019A for ; Tue, 10 Oct 2023 06:47:18 +0000 (UTC) X-FDA: 81328620156.10.1BAC152 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf10.hostedemail.com (Postfix) with ESMTP id 9E0C7C001C for ; Tue, 10 Oct 2023 06:47:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1696920436; 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=baB2eiq6BCK3AFEnCs/tq/2dYE5yNXN+wqPc4weU9iw=; b=iIb8zHcs915pbdO9mrl9ZxK3eRGgeK0P9nf3/3CED390wpUHjShz3a/VrURID45MIH3+bd wcQknJ7NmOL9KNluCHS6FvRmVXMjk4IZZhzZTRC7KM0BjocefaGKquxm4C/MRTT+qryx8u aPS/4edzX8rAtA15/E6LsF3wNBlGrf4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.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=1696920436; a=rsa-sha256; cv=none; b=iozeL0XspDRvHUBEgd6v3npkMv3GOjSuaglvfK+57FbO/ogqBcvdFTlwGKdNmt7f4TogNC rP6r2Md0Y/w1YzIoROb2+Rhf8Kr7Fq7nEpyt+P5MlLkGe4hDgAvozdEGKdZc+OhzlefoXV WNEV/lcGhJs7uwB3zjwrpYHeDyZyYwI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4S4RDZ6fnSzkY3J; Tue, 10 Oct 2023 14:43:10 +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; Tue, 10 Oct 2023 14:47:07 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 5/7] mm: convert page_cpupid_last() to folio_cpupid_last() Date: Tue, 10 Oct 2023 14:45:42 +0800 Message-ID: <20231010064544.4162286-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 9E0C7C001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: huh3n5fobgqumr69q1e6tiyz9zs6npwo X-HE-Tag: 1696920435-394086 X-HE-Meta: U2FsdGVkX1/0dg2/Nune2QlkAzcepnQ9msNPEmxIrODCpz5AYwn7DgEsloPIk40LNuevAtfC8EEIZNvzq0pOKdQ9lW/M/6l77KubdETfSfoimJDsLPPmtO+kNP1CXmtxlOOlTIdBoBRzurDPi4nov/0N/JiQB6ofUFImmxNuHCj2/5PijdTTbdHW4eAe2C6l7EJ+Iq5xg127NkrBeExBtYLv0vlY1KSHswQqbHTIY789Aqr5p121wM3KkBpL37281Dr/dvc2iaPhEysjH3fIysxDjCMDnXjXd6ALig4V8LeWD8CELJxXKC+RrP/GQdTC2q5IK+EvDneoQ2xCQ4SGoaCQNDD7F1+UjImQ8mfpXTjizyMDKayah/5P6o3K71Qu2jzwx/lBZ3byMNaF50EE/mYWZMtkGA6/tdwJhEXygppc0ou8jVZXns6qslw8lk83zgOqEaBmXVmBdmzXmP2DOrqyXWhJmKVmrWmPGd0jiKuFEtD/vWQCk7SW264v1HGIWm3c59Dtb56VmzYzuCFC1qo32IPvsX/yVMQDWdf01z/y6G3cM2QY9PaAyajZ1JNuFveq0xfPJ3JqAVppRfWydPIus/Dgz524AtHvRtUJ9LPY6xkVHKVUOHGfbBR0B3ELhVtDneAYqt6CwBsH07IECYonaAvd4Puk4ElVvfgjj/7FB7y8EgWfdWlwzMcqT3jacd0ekylcK3O4/4uiFU2xrnVc3g/1O7r+CCHBQQME6y/TcT86lDVk+3CSDpQeoiDhvaQIsHzIWNlNSSM04sWTzZxeN022uKbuOU0pBw2vCtD1Pg3Lo7h3tmXBlN12suvp3TD+JLdmQ+bsepxiJ5gxUb8HhGpnhW3MEdiy0Dd7edjKPdqj2hvlyO9OEj9M14/k8LktofvPTzopMZYhyqjK6gshXoeQhz5abyqb5+nYvCgJAoUKih2+YTR0A7TTdympUSx/05aDVbOgty1iBN3 T8w4t7Wp TW5qNRL+Te3Vn3UJW2nTb4+RLEKBkeZTK2ml8dBgH0sMGRsQ6vPTv4mA9aTICbhlJUJrv0LqVtuXb7sBeLMYjHgijlRayX9YoS/eN5rQaXYs4x3wqaK/pyW3p4FTfFlcAi9GCSTjV+GFg1aejoi0tf3q3Q3AP1oGVFdkiXLneiLJhiI9Wx/vTaEkxBYZNDG8XoZxa 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: Make page_cpupid_last() to take a folio, and rename it to folio_cpupid_last() since all callers with a folio. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 12 ++++++------ mm/huge_memory.c | 4 ++-- mm/memory.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 13ca63efacf7..e0bd8abae6c6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1689,18 +1689,18 @@ static inline int page_cpupid_xchg_last(struct page *page, int cpupid) return xchg(&page->_last_cpupid, cpupid & LAST_CPUPID_MASK); } -static inline int page_cpupid_last(struct page *page) +static inline int folio_cpupid_last(struct folio *folio) { - return page->_last_cpupid; + return folio->_last_cpupid; } static inline void page_cpupid_reset_last(struct page *page) { page->_last_cpupid = -1 & LAST_CPUPID_MASK; } #else -static inline int page_cpupid_last(struct page *page) +static inline int folio_cpupid_last(struct folio *folio) { - return (page->flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; + return (folio->flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; } extern int page_cpupid_xchg_last(struct page *page, int cpupid); @@ -1740,9 +1740,9 @@ static inline int xchg_folio_access_time(struct folio *folio, int time) return 0; } -static inline int page_cpupid_last(struct page *page) +static inline int folio_cpupid_last(struct folio *folio) { - return page_to_nid(page); /* XXX */ + return folio_nid(folio); /* XXX */ } static inline int cpupid_to_nid(int cpupid) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e85238ac1d5c..3b37367eaeff 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1562,7 +1562,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) * to record page access time. So use default value. */ if (node_is_toptier(nid)) - last_cpupid = page_cpupid_last(&folio->page); + last_cpupid = folio_cpupid_last(folio); target_nid = numa_migrate_prep(folio, vma, haddr, nid, &flags); if (target_nid == NUMA_NO_NODE) { folio_put(folio); @@ -2515,7 +2515,7 @@ static void __split_huge_page_tail(struct folio *folio, int tail, if (page_is_idle(head)) set_page_idle(page_tail); - page_cpupid_xchg_last(page_tail, page_cpupid_last(head)); + page_cpupid_xchg_last(page_tail, folio_cpupid_last(folio)); /* * always add to the tail because some iterators expect new diff --git a/mm/memory.c b/mm/memory.c index c4b4aa4c1180..7566955d88e3 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4861,7 +4861,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) !node_is_toptier(nid)) last_cpupid = (-1 & LAST_CPUPID_MASK); else - last_cpupid = page_cpupid_last(&folio->page); + last_cpupid = folio_cpupid_last(folio); target_nid = numa_migrate_prep(folio, vma, vmf->address, nid, &flags); if (target_nid == NUMA_NO_NODE) { folio_put(folio); From patchwork Tue Oct 10 06:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414851 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 A03C4CD68F4 for ; Tue, 10 Oct 2023 06:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DD606B01F5; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 684176B01F6; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54CBD6B01F8; Tue, 10 Oct 2023 02:47:14 -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 3B4B86B01F5 for ; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1300440174 for ; Tue, 10 Oct 2023 06:47:14 +0000 (UTC) X-FDA: 81328619988.12.4B29748 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf22.hostedemail.com (Postfix) with ESMTP id 83B27C0016 for ; Tue, 10 Oct 2023 06:47:11 +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=1696920432; 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=7gdOMeLQZKF43HKLxI174ZWFuLbnPjI8+vrUMsgpZqc=; b=67AoyLqSCV+6g0Pzshox6Jk4qiuLhegfGlHk6ABjkFe3KpfiJdc2xVy25CM9Vgq0ONO1Iy NpNGJ/5WqIFKprVHxwZCMqprQ6YgfRZtg/hIt2Qxk5MngHVPevzhc3YLNAZMniRj62fHuS wsIhuy8BdZ5VidLJW/9T+iIdU4thBEk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696920432; a=rsa-sha256; cv=none; b=hcLC5Iys8azRRArE5OBZGeY6vgy1WxkSztZH4vwrisp3vzgUPy9hHFmi/DDMqRrkx8Fh5u 7ipy+ommXk9AlPjTu84N+67pJgy2yEKIdL91+NnzYLSklip7ARxjawgfbhTlg++oINoq6v YcwxyKSJ6VJt1nsjor5HbofG5Fi8R9I= 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 Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S4RGD0GDHz1M92R; Tue, 10 Oct 2023 14:44:36 +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; Tue, 10 Oct 2023 14:47:07 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 6/7] mm: make wp_page_reuse() and finish_mkwrite_fault() to take a folio Date: Tue, 10 Oct 2023 14:45:43 +0800 Message-ID: <20231010064544.4162286-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 83B27C0016 X-Rspam-User: X-Stat-Signature: 4dn7jxcwdcq3kquttxurp8a7jehtocg5 X-Rspamd-Server: rspam03 X-HE-Tag: 1696920431-739640 X-HE-Meta: U2FsdGVkX1/XirNqX7rOxI9QFdnLn27LwWDHVH8xcL3ng2WTiAvINz/7NLf+j8c48Gr9QEjKAwhiHgnvXbFz9jIoHXZCaYu41NgkX2hyYjBzRSIUMX3wo49xEpQRl0IjRsYGXl+Ekm1FDuGToCYoLB3M4CgR65+xhi3Txej0f6BY+0kYSQdgn4FYiHcceX4eCZ2hidJEMHU+/aOq89CWfazqCNDJVCfKeTpRzEYGLB/yAiP1Ahn/bZdugCTiK2+hJFHdPCN57QGD/GIjlmMWvs8oIAbU53hX1edXB8CFlobYA2IPrqFVvF7yRTY+945wL2fsQdn0XXtC4uDeYg23fGRnUb/fShs/oJtxy6EtbUwn2L5cMSP1zp4SWT0/aBuCgeHQKZnliGEJixf5Gv38NHqSe4iqGRyTQMnyeTrOl+wLRSFnM06NppIsi3XdlywR4Cx1Y4oSYBPf3M4xqMlplfsu8EXGkQjK1FZW6e0ieM6RolBWCqAxbzMx4CTpIPfNMQyajmZ0ChUb4UsJFeBS25pdcrIZUeJqEJuxpVaS3AXz0AkkDM71wpaolrsclnlXRM7TW3j14lCAflTH3Gwo00yWkM8+ucfsxFYrq7+y3AGZKuOwi/bxJZ291Q0WxTE42uWNdhcR4fJPkxVQCe+8VGvlI52aRl5/wy2dK00w9k2oKcaBz3sZdhUWV3nnvtDhN20V/c338ryYdi77TgQy9wRsfvg00mBEzsAhUfEpxqu+pkaD4wmQ0UkAspgvDo9OEWliD4mK2vnqKaCLMNlR+nbnm22ev6mklJLXqyuM7zbTpJD6GQ1FdZqHndYL4kMD3mjpy1RzI7VbziHIKGK6Cekyqq1QSwK/yAkXWOUDXYQ3RsEdhK50a7PRb1na8qDo5sZ+0EJwsnJLG2dgHP076nURvhxrQtt3pncGr0aR/HE1a8Zr5TDt2Dg/t91MGBuNWpy8SOnlvdWhWb6JdHZ FBCw1521 HtWF3+bIEBUbqQu9bAxqAHNEUqyM0CuoIxz0n52PzRJrJ9Qi0SKW1aaKIm+9IT2SCiqDEYmObUUavtFH6UIwWCh36NyG1EJedtstnX/EyL0CEMTwNdTILzojp4C0CQyIqSljg6oBv4YaQoaA1fuVFUMbkjlO+qxq6Ns0sTfyS+5vt0Ob9TneDcQuB7sBFkCf/As43 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: Make finish_mkwrite_fault() to a static function, and convert wp_page_reuse() and finish_mkwrite_fault() to take a folio in preparation for page_cpupid_xchg_last() to folio conversion. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 1 - mm/memory.c | 37 ++++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index e0bd8abae6c6..3d59455626fa 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1335,7 +1335,6 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio, struct page *page, unsigned int nr, unsigned long addr); vm_fault_t finish_fault(struct vm_fault *vmf); -vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf); #endif /* diff --git a/mm/memory.c b/mm/memory.c index 7566955d88e3..1a1a6a6ccd58 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3018,23 +3018,24 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) * case, all we need to do here is to mark the page as writable and update * any related book-keeping. */ -static inline void wp_page_reuse(struct vm_fault *vmf) +static inline void wp_page_reuse(struct vm_fault *vmf, struct folio *folio) __releases(vmf->ptl) { struct vm_area_struct *vma = vmf->vma; - struct page *page = vmf->page; pte_t entry; VM_BUG_ON(!(vmf->flags & FAULT_FLAG_WRITE)); - VM_BUG_ON(page && PageAnon(page) && !PageAnonExclusive(page)); + if (folio) { + VM_BUG_ON(folio_test_anon(folio) && + !PageAnonExclusive(vmf->page)); - /* - * Clear the pages cpupid information as the existing - * information potentially belongs to a now completely - * unrelated process. - */ - if (page) - page_cpupid_xchg_last(page, (1 << LAST_CPUPID_SHIFT) - 1); + /* + * Clear the pages cpupid information as the existing + * information potentially belongs to a now completely + * unrelated process. + */ + page_cpupid_xchg_last(vmf->page, (1 << LAST_CPUPID_SHIFT) - 1); + } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); entry = pte_mkyoung(vmf->orig_pte); @@ -3261,6 +3262,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * writeable once the page is prepared * * @vmf: structure describing the fault + * @folio: the folio of vmf->page * * This function handles all that is needed to finish a write page fault in a * shared mapping due to PTE being read-only once the mapped page is prepared. @@ -3272,7 +3274,8 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * Return: %0 on success, %VM_FAULT_NOPAGE when PTE got changed before * we acquired PTE lock. */ -vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf) +static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf, + struct folio *folio) { WARN_ON_ONCE(!(vmf->vma->vm_flags & VM_SHARED)); vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, vmf->address, @@ -3288,7 +3291,7 @@ vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return VM_FAULT_NOPAGE; } - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); return 0; } @@ -3312,9 +3315,9 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vmf) ret = vma->vm_ops->pfn_mkwrite(vmf); if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)) return ret; - return finish_mkwrite_fault(vmf); + return finish_mkwrite_fault(vmf, NULL); } - wp_page_reuse(vmf); + wp_page_reuse(vmf, NULL); return 0; } @@ -3342,14 +3345,14 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf, struct folio *folio) folio_put(folio); return tmp; } - tmp = finish_mkwrite_fault(vmf); + tmp = finish_mkwrite_fault(vmf, folio); if (unlikely(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) { folio_unlock(folio); folio_put(folio); return tmp; } } else { - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); folio_lock(folio); } ret |= fault_dirty_shared_page(vmf); @@ -3494,7 +3497,7 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return 0; } - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); return 0; } /* From patchwork Tue Oct 10 06:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414850 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 796C9CD68F6 for ; Tue, 10 Oct 2023 06:47:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FD36B01FA; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D8776B01F9; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219706B01F6; Tue, 10 Oct 2023 02:47:14 -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 041A16B01F6 for ; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C9EACB484B for ; Tue, 10 Oct 2023 06:47:13 +0000 (UTC) X-FDA: 81328619946.12.5BC8B3E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 4B95FA000A for ; Tue, 10 Oct 2023 06:47:10 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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=1696920432; 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=TnqqPukhplCsMkc/rctsfscvk/yq8sOOK7EULXK6MuA=; b=3M4IKpTPL9ZF1pgEonSsM/EvrVB/7NpqoQ3aujYwttWy/fIkoobNDnWcXCO2BPwcpYx+nL TvrFdKSrp97Ljkj8L2FZ1GmGhIsCUMM+I95yEUqzfodr4ePJ9lI5SZpyRx1Aa3b3Pb1Lhh pfiTOe36MViQ+NZiPnIyBnAllqNZZxI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.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=1696920432; a=rsa-sha256; cv=none; b=IgQGUXAKaYjJmwiOtCqnVL+uX8p86mOD/74IayQtlOlCv+DrvvFjQjfK3zghQ4NbUsA1cJ SOHqFcPfS8rvdhp0KGbcvG4eyE4LrYFYPEhgwf127bOu8zU/Y0DJqV91mtjneKkrLkRSui XZsDSlodQPrfnCP1ijG2INYvmAkk9y4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S4RDc5vqYzNnqm; Tue, 10 Oct 2023 14:43:12 +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; Tue, 10 Oct 2023 14:47:08 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 7/7] mm: convert page_cpupid_xchg_last() to folio_cpupid_xchg_last() Date: Tue, 10 Oct 2023 14:45:44 +0800 Message-ID: <20231010064544.4162286-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 4B95FA000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xngxnq1saoyr6q315yaaswycyf1er846 X-HE-Tag: 1696920430-332580 X-HE-Meta: U2FsdGVkX18YgqAt1OjWoJt/OIJtcsS+Hqzr2jNMvqGyLK+k7v/3DS8lJDC5ofMuLPHC5Zpa/0TiURNV9n3/iuq9GQIHtAbi35LTZxVC1OUUyIKHdOrFVt9T3ElifwReopMY1vptcqH4t8T3mpSeSpG1PQSQ22UarOXDhpGwbWxZxs7EMv+adMMVZF0hLhIIUIE0KMY140N14LDUBQ4I7X/6fG9x9RkFEekJFAKuw57kxSSJaQZ6dMjfmgz86kHXK0/iGHBWjuiZcLnOZq36iwseqzQT48M+4QYmYxyfrJczlHhz7JJlrMWXmRMWuOIGH7vWGNQrk+rcz2ncNKFyGqTDxH9uJwxNcKnhsfUoxTNBNjL2iLyCvuB481j/7pf0jIOSM0HInClThRy1VIJiUenf1MuQ7hRoZniPh2MDBA+JBqU2MijlnKrAQ01BB4iTfxH8XKBfQcBxJBa/Kx7FuIRIp+iUm9QrgXGb8rU6NdNH2QKiV5Tvx8p8DlxSrIuqZGJgUFSDxeJuiUpItIygQw+azK2Sn4DrxSHr6reqeFKj0gLwDKyzsUM5C34G8YQjEoAfL3nwFV3UeZFgkiowSN8h+QTxgS+DjZ3XgmHThcOuwNBd1drWbyG2fPaYHV0xkOuPHqw/ellF4yqNomdvJ8UA8nhPC/sGz9EvSahLIjlzYe1kAYsuxw/MZmIvA+bZISPvlvstXDXIjm5WavlfDrkrcSzAFK4H5VMQAwNc0o4+D5ps9MxkaU4QckZ1hftGUr4zWT3PRro1xjN1PdCuocRCQNxXfaZ37yNo7ive3nkEragEwpVkEBZFt50w3atMoaCc3trC9ON/g/9otFEJTzHw3hJttl+BMwCM2RT4cwovAUvgcQUy09WJV+MA7wASFnnmF+tj02JTDAKioEEWKWC2kc1CYnyqzpJPkzXxQl8pXcwHVAVbppxvfX25oEHVLNt29atI+GjmIRHdKuS pXlIQn/S OykWfCFPUylbhsXeHE/Kq9VQaTZY/AAqPKkBa1onQRukQ/lAlaNGwPobSRUkqelOqz6QbGAeh18zU1yEAwkysJc9MWWJGCiuZo/RNGKcPJ+y4i8ZKrdEzjDYyW0O+PRapxo/G6UW92GpaoeqHcT0F6CjOj9MwTIaIZZ+5t2EJKN3km40BD7RHxtpLU9BHnCTbwm9q 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: Make page_cpupid_xchg_last() to take a folio, and rename it to olio_cpupid_xchg_last() since all callers with a folio. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 14 +++++++------- kernel/sched/fair.c | 2 +- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 4 ++-- mm/mmzone.c | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 3d59455626fa..e761642e1c00 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1683,9 +1683,9 @@ static inline bool __cpupid_match_pid(pid_t task_pid, int cpupid) #define cpupid_match_pid(task, cpupid) __cpupid_match_pid(task->pid, cpupid) #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS -static inline int page_cpupid_xchg_last(struct page *page, int cpupid) +static inline int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { - return xchg(&page->_last_cpupid, cpupid & LAST_CPUPID_MASK); + return xchg(&folio->_last_cpupid, cpupid & LAST_CPUPID_MASK); } static inline int folio_cpupid_last(struct folio *folio) @@ -1702,7 +1702,7 @@ static inline int folio_cpupid_last(struct folio *folio) return (folio->flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; } -extern int page_cpupid_xchg_last(struct page *page, int cpupid); +extern int folio_cpupid_xchg_last(struct folio *folio, int cpupid); static inline void page_cpupid_reset_last(struct page *page) { @@ -1714,8 +1714,8 @@ static inline int xchg_folio_access_time(struct folio *folio, int time) { int last_time; - last_time = page_cpupid_xchg_last(&folio->page, - time >> PAGE_ACCESS_TIME_BUCKETS); + last_time = folio_cpupid_xchg_last(folio, + time >> PAGE_ACCESS_TIME_BUCKETS); return last_time << PAGE_ACCESS_TIME_BUCKETS; } @@ -1729,9 +1729,9 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } } #else /* !CONFIG_NUMA_BALANCING */ -static inline int page_cpupid_xchg_last(struct page *page, int cpupid) +static inline int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { - return page_to_nid(page); /* XXX */ + return folio_nid(folio); /* XXX */ } static inline int xchg_folio_access_time(struct folio *folio, int time) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 50b9f63099fb..5d4c7cedc6d1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1818,7 +1818,7 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, } this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid); - last_cpupid = page_cpupid_xchg_last(&folio->page, this_cpupid); + last_cpupid = folio_cpupid_xchg_last(folio, this_cpupid); if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && !node_is_toptier(src_nid) && !cpupid_valid(last_cpupid)) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3b37367eaeff..2163b1d0dad5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2515,7 +2515,7 @@ static void __split_huge_page_tail(struct folio *folio, int tail, if (page_is_idle(head)) set_page_idle(page_tail); - page_cpupid_xchg_last(page_tail, folio_cpupid_last(folio)); + folio_cpupid_xchg_last(new_folio, folio_cpupid_last(folio)); /* * always add to the tail because some iterators expect new diff --git a/mm/memory.c b/mm/memory.c index 1a1a6a6ccd58..9f3b359b46db 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3034,7 +3034,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf, struct folio *folio) * information potentially belongs to a now completely * unrelated process. */ - page_cpupid_xchg_last(vmf->page, (1 << LAST_CPUPID_SHIFT) - 1); + folio_cpupid_xchg_last(folio, (1 << LAST_CPUPID_SHIFT) - 1); } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); diff --git a/mm/migrate.c b/mm/migrate.c index c602bf6dec97..5642e9572d80 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -588,7 +588,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) * Copy NUMA information to the new page, to prevent over-eager * future migrations of this same page. */ - cpupid = page_cpupid_xchg_last(&folio->page, -1); + cpupid = folio_cpupid_xchg_last(folio, -1); /* * For memory tiering mode, when migrate between slow and fast * memory node, reset cpupid, because that is used to record @@ -601,7 +601,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) if (f_toptier != t_toptier) cpupid = -1; } - page_cpupid_xchg_last(&newfolio->page, cpupid); + folio_cpupid_xchg_last(newfolio, cpupid); folio_migrate_ksm(newfolio, folio); /* diff --git a/mm/mmzone.c b/mm/mmzone.c index 68e1511be12d..cd473f82b647 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -93,19 +93,19 @@ void lruvec_init(struct lruvec *lruvec) } #if defined(CONFIG_NUMA_BALANCING) && !defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) -int page_cpupid_xchg_last(struct page *page, int cpupid) +int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { unsigned long old_flags, flags; int last_cpupid; - old_flags = READ_ONCE(page->flags); + old_flags = READ_ONCE(folio->flags); do { flags = old_flags; last_cpupid = (flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; flags &= ~(LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT); flags |= (cpupid & LAST_CPUPID_MASK) << LAST_CPUPID_PGSHIFT; - } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); + } while (unlikely(!try_cmpxchg(&folio->flags, &old_flags, flags))); return last_cpupid; }