From patchwork Fri Jun 30 12:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13298111 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 3329DEB64D7 for ; Fri, 30 Jun 2023 12:13:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 931E08D0001; Fri, 30 Jun 2023 08:13:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8928A8E000F; Fri, 30 Jun 2023 08:13:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6964A8D0012; Fri, 30 Jun 2023 08:13:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 50E9F8D0001 for ; Fri, 30 Jun 2023 08:13:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1696EAFB5E for ; Fri, 30 Jun 2023 12:13:32 +0000 (UTC) X-FDA: 80959304664.06.C4C0CA9 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf06.hostedemail.com (Postfix) with ESMTP id AC3E3180003 for ; Fri, 30 Jun 2023 12:13:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688127210; 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=MBZ7vvpVYusarV6ekdjHXkir2egpRNeipnLA+F+ZSxI=; b=UkeKBURr+Dzze97My2qBjv0xC8CwOtg5k5y3OPhtoaDZHUFrz0WVfWyVfPpifXK53AcwvV ngUzO2cr5G/28WKn+sF+o2UkJpLTN3uDUzJLaYDWQUdy8J139+geoH6bQqNSU5kabAEYlg iM5a9ljfeAmE28WZvM1tHWZWuP6nLCw= 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 zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688127210; a=rsa-sha256; cv=none; b=OznPpJYs2yMujLzGnDbm6V0vtvufdKiCVSbHzgIU7dtLTMpM8giUZxkVsSVJdeGqiarcvW +/aCYzc1aUEFJSDvSuBULtorsJynzOC19prN36IMOFuFiboWBLwsB7QK/pq4LvG8E3GKe1 v73+XRd6+owmnNGWzLx1pgbGsJmzdHc= Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QsvMZ5K4JzTldR; Fri, 30 Jun 2023 20:12:26 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 20:13:21 +0800 From: Peng Zhang To: , CC: , , , , , ZhangPeng Subject: [PATCH 1/2] mm: remove page_rmapping() Date: Fri, 30 Jun 2023 20:13:09 +0800 Message-ID: <20230630121310.165700-2-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630121310.165700-1-zhangpeng362@huawei.com> References: <20230630121310.165700-1-zhangpeng362@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AC3E3180003 X-Stat-Signature: ot8fh8pj8qi8dmj1ppx483hxjpdfxnxs X-Rspam-User: X-HE-Tag: 1688127209-495281 X-HE-Meta: U2FsdGVkX18We7/lpGMZeRqslNXeS58TAIW85OzN7Ink/IqaCBithRHvrivrk3BM77Est0zD04cdyEoHS1Wd5vUNE4znDBB9c4VaM/9yWUjRXq1dehNaC3PUaAuK2Mgw4RJyfU404jTv6fcatrwBDZlAOeh83shM7MPKk0FRkUHd41U1AtiT6VpgAd/R1bE8fQoPCWpEeM8pzMNaQm5SQnif/mOu3gHRwTj3djwFyPmrKsqlcfRfaGYmv2Wfkk6ZJ6M6RlDwXFJbjeAwEimJ1hd6X4lFdJuGiNTgzlK19E3NBM1K6pueyg2MGSKYVfaWMP3tA/hqubqY8P5g1fkPIjqoDgDDnTuOYF6LWGf/z19HOV5HqrANT5Vu/rGoD4R252uwzvHAcf/99vFIkUL06Mo2X8m/UUKBN3mAdPPQ5oRpRLLJOU5BkhkUVpQsQYC4z7kV+inEq8s0Y0uuOussk22+zcWHocWfqGRW/52JYvQCUaZ9RLJEU59AOeyefziMjU/gN0HfUQlMgh56yglwJG7UrcnRa1tmsnSwG6FawOUQbh1uUcOWTMxqNLkm3bClKDxqfXalBW7yjab6whgzJi4gPjdcArf09xSq6JpnqTOVR9SXi5Vs0JhGPMbv88frOqzxK5P1CAk+NeM/8yb2FIxNBZxQdkWrWxmG/sRLwipV37G251j9owaKQ9wyLpr1zDuHMhw11qO9Uz21dPxSdxJzSIhNeYBGhh3p5K2Np2BTffQlsrvJAbQ5Tupj2WlTiCfhYsTovxrB6onDrfRj9fzO5KqAb0JkTzHcRMwBTZM52bd4r/kqajzA2iRgpIaeogUo/bVqA4aCZLHTL0mheZ+YjfRNOn0ulrScLdU8QV9pXAvKqSKxr1Zo/ERZMp3q4qH1zNRtpiV48V6kpN/3Le6H7rVmH/h+BwQbwyIrQm9eLKA+wGpEyHUfslYEZ5SMRDbxTnL/yB8u3MRkYW+ 7TaX6FLa 3URQ0XvOxZlEzHYCcMVs5H/sQQNuqZU673YIoErJKK2JKoMWWZ/oWl3wNj80+07Rh8O7us+uKP9ivoTCU2qi7YakwZWe6AoJnBae/hyynrKXgKh0UlWqu7Nc6yEgJ30k6odWyXt/Q3Hmx28ENESo86+GCQkEi+a8f3kdPzuNj+gj5FNi9lNXSXpuCnuCvp94lV2NX 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: From: ZhangPeng After converting the last user to folio_raw_mapping(), we can safely remove the function. Signed-off-by: ZhangPeng Reviewed-by: Sidhartha Kumar --- include/linux/mm.h | 1 - mm/memory.c | 2 +- mm/util.c | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 9ecb8b9c07f6..8c7eba7370b2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2129,7 +2129,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern void *page_rmapping(struct page *page); extern pgoff_t __page_file_index(struct page *page); /* diff --git a/mm/memory.c b/mm/memory.c index 21fab2727209..6921df44a99f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2979,7 +2979,7 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) * pinned by vma->vm_file's reference. We rely on unlock_page()'s * release semantics to prevent the compiler from undoing this copying. */ - mapping = page_rmapping(page); + mapping = folio_raw_mapping(page_folio(page)); unlock_page(page); if (!page_mkwrite) diff --git a/mm/util.c b/mm/util.c index dd12b9531ac4..5e9305189c3f 100644 --- a/mm/util.c +++ b/mm/util.c @@ -734,12 +734,6 @@ void *vcalloc(size_t n, size_t size) } EXPORT_SYMBOL(vcalloc); -/* Neutral page->mapping pointer to address_space or anon_vma or other */ -void *page_rmapping(struct page *page) -{ - return folio_raw_mapping(page_folio(page)); -} - struct anon_vma *folio_anon_vma(struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping; From patchwork Fri Jun 30 12:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13298109 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 C7D23EB64DA for ; Fri, 30 Jun 2023 12:13:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E7C98E0010; Fri, 30 Jun 2023 08:13:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3621D8E000F; Fri, 30 Jun 2023 08:13:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 202478D0011; Fri, 30 Jun 2023 08:13:31 -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 0BB9C8D0001 for ; Fri, 30 Jun 2023 08:13:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CD6C6C0A1C for ; Fri, 30 Jun 2023 12:13:30 +0000 (UTC) X-FDA: 80959304580.21.EE2BE19 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id D126C40023 for ; Fri, 30 Jun 2023 12:13:25 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688127208; 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=v4G7xZ1P7BBK5tKU1+W2DUw6GoPY63Bhg9it6ICKAhw=; b=xDe0F8sQXPtOj9WKfbSfxwb+1NkmI3GMyPqfBmKkUlMMICDByh6M3bPLqAnOlf6V6i5fXE GTkzJxd6vxvrqQuHz8OiMP65hbnqYeiRGpFsIOIt0CTYC4KYJufA+ceNZi6y56rmBpigHU /Mzulef907bmjSGNBhPrRTASsdy9230= 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 zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688127208; a=rsa-sha256; cv=none; b=UOe5+Unniz0+7Fy9XV4DVx0joyEDqhY/c1seruyseoO0+POW8VJ5nPF5yK2OEvFE1jYOdV RRBStSy/eS+C1Swdz1dyq2TWbPiXrkhoumCtcSziPH4G8ALZypOwngsLqsplLpmJjbyvvw OMaRO3ufWzmPtrdJZqmaM2ur5ZRCJuc= Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QsvMb2rGwzTlft; Fri, 30 Jun 2023 20:12:27 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 30 Jun 2023 20:13:21 +0800 From: Peng Zhang To: , CC: , , , , , ZhangPeng Subject: [PATCH 2/2] mm: use a folio in fault_dirty_shared_page() Date: Fri, 30 Jun 2023 20:13:10 +0800 Message-ID: <20230630121310.165700-3-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230630121310.165700-1-zhangpeng362@huawei.com> References: <20230630121310.165700-1-zhangpeng362@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D126C40023 X-Stat-Signature: g8776fpufnspen43r7qwkq6g7yutt4cc X-Rspam-User: X-HE-Tag: 1688127205-17817 X-HE-Meta: U2FsdGVkX19MONGL109KMIjJTkCtgUpgu5tfXwkIj6lfjWHfMUiBu9sBiy/6IbQMB3ARAJl5HxpQMi3fHQ7/n8X6+OEgvdfHMVdSbCRdrIepyEZm3tSjp1lB8aRz2auGw50pO+oQHXyUZrpVw5xU5p890o6n1iXkM+8jQgD1mHdJA1AFWtedJtYMWUdpokOn/0t3x/VZeOMbalYBDB2zNmwot4Klj9K5n+RZotlvoWXOiyaHdzZe/urkwNVOrty2fTv+lTAy4E8D0mIg+kQiM6awdsfLp9zOBzGSe9nJM8gOerGsWq1pZqaatGgAkhLw324RveeDYGU7RPHYsQleNaPm1S34HiYRT2us3jxrgwodX2T/5napQz8j08vycugP20/DMbmp2wnuHxHrUZhGI/3BpmaGY3ZHBsO5QEPRjJr9OyBwofE3fbQGZcWtLGdL5a/Rqfcim2eK2QrlCkVOvSWQdWt4L+iks1zeZVVEWue0fB/KTy7AHpdgq6oAWWLJkoGEfaGVtccNNPYPaII1CJWt7gRHldo1klj4KkW2/o+B/hluH4xiQKIAyoRU7krOY3aTYeEBHMUc91F1tJojCFp4RO7P+W+j/Ra79HNFDIcNiP99WkFIw6YOqOFqf4sn0rp9Jle3ryDDmZW9eegkNhu43EIVGbqYUJ298OXtwhoRqh1v661uSj95JUlMzMZsBmIb06jIgbJJVHXTg+jCepEuQ/LH5o2joJpkVdBAbxjV4GtDUx1VB5PkJ0k/S4g7MTnSGy86VmHeJw3gudhHCxcGnrG2AZJcxBnrHvlqcF+6F3aEBwPuFX/V08JOvkaDt+wOL2JovVdF99e7+Du1Qx79N6RyfXRv0hSP6PRw9xiZSBleZaRmNn3urHiZGOtdB/CCRgwgBYqOhUfHt+ixWXOQW1xjAkUe4cEP3GEcph+BO6SXchP7UQ4OHA+rSGWXA8YWEZ1Pa6fGXTkRkHa 2Shp0Svu lfDBN9kZyte/2MdSjggCtixFDKuVKzQnlWLep3Pgas1Bqov5V6F6QArG3/G+iekFcN+N3QMV42vF/qcRYmLYYbOUKK1ZklYoY35KKUh/niGsMoVZK1hUjl3rd/k0RSR0DmYN9gCpcx7ZDwbQfJGnpbvC9WcAunU/A30RXFwFoVxzfB0Z+ld6PC5veFeTkGQVmqban 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: From: ZhangPeng We can replace four implicit calls to compound_head() with one by using folio. Signed-off-by: ZhangPeng Reviewed-by: Sidhartha Kumar --- mm/memory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 6921df44a99f..73b03706451c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2967,20 +2967,20 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct address_space *mapping; - struct page *page = vmf->page; + struct folio *folio = page_folio(vmf->page); bool dirtied; bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite; - dirtied = set_page_dirty(page); - VM_BUG_ON_PAGE(PageAnon(page), page); + dirtied = folio_mark_dirty(folio); + VM_BUG_ON_FOLIO(folio_test_anon(folio), folio); /* * Take a local copy of the address_space - page.mapping may be zeroed * by truncate after unlock_page(). The address_space itself remains * pinned by vma->vm_file's reference. We rely on unlock_page()'s * release semantics to prevent the compiler from undoing this copying. */ - mapping = folio_raw_mapping(page_folio(page)); - unlock_page(page); + mapping = folio_raw_mapping(folio); + folio_unlock(folio); if (!page_mkwrite) file_update_time(vma->vm_file);