From patchwork Wed Oct 18 14:08: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: 13427130 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 53B7ECDB484 for ; Wed, 18 Oct 2023 14:09:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A07180014; Wed, 18 Oct 2023 10:09:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 402246B01A9; Wed, 18 Oct 2023 10:09:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F0D280014; Wed, 18 Oct 2023 10:09:19 -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 1D6336B01A8 for ; Wed, 18 Oct 2023 10:09:19 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E4D3740D20 for ; Wed, 18 Oct 2023 14:09:18 +0000 (UTC) X-FDA: 81358764396.16.FAD4A23 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf10.hostedemail.com (Postfix) with ESMTP id 53C26C000C for ; Wed, 18 Oct 2023 14:09:14 +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.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=1697638157; 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=z6mhHbia0tgVbcgOllnNbvBMUqnXaQ9x0wWBWtbmQ/I=; b=xsV0ZE7aq8PJya1sXZjn1ggjasIGjJM1qMAJ47bRzMMtvDR0lQE9d9gZbnWaBbZoHJib5m xT0l+DsjBYNoUb4gtG5JYpi/mAupxdZREYbx/s3y0qC3TfX0HfHeFXYV/RbIdRmLrAaR3L hpa5Q5TQMpiaAJtFkIp189WhbdPcn2o= 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.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697638157; a=rsa-sha256; cv=none; b=xO8PjLoGd89uK9UaZWMxlqxqRUk3oBt1V+dmYe9RJL35Pky5wxiADdWQsuxBrtFs/vlOrF XmjiOsAnx3KfL0rR8Xc5TZPCyljd6QOt+r0rxMK+PEwvDuKiw0ExQpPL34JaynnDnvXLef dYjCN25RhvdfQiGc4JvzO2xZkufmCO4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9XhL4X7YzrTQF; Wed, 18 Oct 2023 22:06:26 +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; Wed, 18 Oct 2023 22:09:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH v3 18/19] mm: use folio_xchg_last_cpupid() in wp_page_reuse() Date: Wed, 18 Oct 2023 22:08:05 +0800 Message-ID: <20231018140806.2783514-19-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> References: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: nqref839ir776km1ms7xjixmmmrseyd4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 53C26C000C X-HE-Tag: 1697638154-277723 X-HE-Meta: U2FsdGVkX19473okdeEpnJWMA9ahC9E+Meq6RxhjL5gDCqNtPtiXtIIG6uxgsBbjtbxSKcI3FwHFIclYR503B+Xe5+qbGDTS1z0VnpyM7C3EjzN2XFMVT7VlyC6WvPQRX7yxfZB+O0U8TipQb9MfezYA4VY/H6VeCinFRAs/US7j2UskRmK0ypP1zVCrEKWZmIfzfTElx9gOpb+qCHWO/qJDzCtWaXjrDK4TzW760EA4MiJ4xcdimD8OplbnBVsLyCJnjwVSs1Bg+ryFfb1/0FTB2kCYd1dg7MRtGvd3X5QlIPnKzrloXSSihogwN7CkYg6HU5uPIMO+P8T0W9BNJ/dMT6Xwude4mu6ZbA1xvygyerRYomzy9CDiRrMxx73V9A/Ivy7ZRCol2rE2mqJ7/xfRSAOlPC9TJNClIor5GwmbVsOCiLfa+tNSSAEbRZ+XPi/qJenayEcYL7YZdgkwULY1NWHkgFQLgai1R+eJXYvdXU3L//3N5EiOdZ+wB0FK7Xsk1FRtL/cYq2CY8vJe7vsVosrnzuxXFY7hc7KbihqePxxqQXplzZ9/R+pOwbcfvo6PrEd4pt9X8niEjFanhUk2nIfdzEhfruttLiB1zcO9kOU73GFyx1l34Z9a2qWmY72jiwPZ15btTeYRiYaQax/TBX9esompDFulLyLV49N9U1bBsUOQroO3KhhvA6hlR2YMFOMd7nNTW7Al0vrDJ93nq8UyaHky2f8RZTc2yete72X2w43pbWmu33yzkiFfFBFDFh70k9k7/MmS46LrUJGFl7LvvuX4/cxI1cCmhCcRCHGfQxIW8tLz5chlH4e5qlliJoPPitB8e0IsRadvcf01QhXBhwlubdRVeIzHV2hHQRkef7xxKy6ZwOZH7Pm5uMSHrzYVEFi+OkOgnJ7v6p20JgjRH4bXKNf/LuwxjxEkMqtxxJanWSdowBxS4B0BxxLNmb5tHP9o9XLniK2 HAIMBY2R nndFcKpQhvEz6+wDDNsypdod2e8qGApFCjZ164u9PAmgi9b6FAG+rd9XAWmkFI+zE1tam4MJ/UD5DH7JeTM/Q1gMSCX7JXI3TWWUi6EriaL1CxdJ1wQpeipcuXnjpQYKQ2dJEVHjL958t5rVHbT+nFRr+AGTqLeIunr18p7Yw5LEwKJkpSRFUbw4w9cNJe8HfjQfoZgU9tA5C/DZ/PvX6+oDUCgNFNVrhOjyiPkh1uippnzLvZP7tAL1+lYb88Cwzu5pAAxP41DKJR6/tUo+ADZJdRrslXLJ8Q/gW 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: Convert to use folio_xchg_last_cpupid() in wp_page_reuse(), and remove page variable. Since now only normal and PMD-mapped page is handled by numa balancing, it's enough to only update the entire folio's last cpupid. Signed-off-by: Kefeng Wang --- mm/memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 037da118f1d1..4f0dfbd5e4bf 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3022,19 +3022,20 @@ 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(folio && folio_test_anon(folio) && !PageAnonExclusive(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); + if (folio) { + VM_BUG_ON(folio_test_anon(folio) && + !PageAnonExclusive(vmf->page)); + /* + * Clear the folio's cpupid information as the existing + * information potentially belongs to a now completely + * unrelated process. + */ + folio_xchg_last_cpupid(folio, (1 << LAST_CPUPID_SHIFT) - 1); + } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); entry = pte_mkyoung(vmf->orig_pte);