From patchwork Mon Sep 18 10:32: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: 13389374 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 9344FC46CA1 for ; Mon, 18 Sep 2023 10:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80FE46B02D2; Mon, 18 Sep 2023 06:32:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 797216B02D3; Mon, 18 Sep 2023 06:32:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A1106B02D4; Mon, 18 Sep 2023 06:32: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 413536B02D3 for ; Mon, 18 Sep 2023 06:32:54 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 165E21A01F5 for ; Mon, 18 Sep 2023 10:32:54 +0000 (UTC) X-FDA: 81249355068.18.69604B8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 3CB2D4000B for ; Mon, 18 Sep 2023 10:32:50 +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.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=1695033172; 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=Q0j2iplv8tIoDxFaHxiXvS50HobKD+ChXL38zg2Jy/Q=; b=rc2VtbweBU1ckGu4jKDKP6S8VHpgACst5W87t+0gy1KITsJz+esfqujkwg7viDniAK97JQ OOrs/wq3nzak3MsSQDvFRfYyYKUxvi1qulhyOxK0YJX+nHFzG7+HfuMsTLe7TdTs/r/a8g 5ogogw8ZHxCa1s8wBAX7zGfzX82sBMY= 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.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695033172; a=rsa-sha256; cv=none; b=vS8wOP4ZW6cHundnbtupBdbxSw4ihXSHrHheXWBZpFNFV4PYwAfZL0bsqLOSDFOE8DT5hq uKwRoTrcIToVyxahmwdvg0E1xYTjUWxiIpcH8kK9bwYTGWyjAKAF533GkIyPiBGwH+A86Q L4wHyq4v+QGAAaiTyW0N45MVAy2ptQY= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rq1JJ308ZzVky6; Mon, 18 Sep 2023 18:29:52 +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; Mon, 18 Sep 2023 18:32:47 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH 2/6] mm: mempolicy: make mpol_misplaced() to take a folio Date: Mon, 18 Sep 2023 18:32:09 +0800 Message-ID: <20230918103213.4166210-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230918103213.4166210-1-wangkefeng.wang@huawei.com> References: <20230918103213.4166210-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: 3CB2D4000B X-Stat-Signature: 8ym6hw83mewz9fptof6ier6iuq8wzk8y X-HE-Tag: 1695033170-814029 X-HE-Meta: U2FsdGVkX189+L4RcPhr1t8T9tHsS0j/QOAih7ol9m8xBT/IKsXi/B0PPTuvEYM3UigHOMjM+ySTvvfLOFDgJVBvwQhAvNtHjhEcFRqrNEVYvcHh+FSzlvFYF8stxWP3+Hu/e145UlkTjTOZIXSwINlRQh54RjONk8+3OZL92RMVc3ndpCPHQN6U1+MLVNzd+2G3LvPYtWjn4mvzBZI8SDPmuhzcF07ZPf6gny89POZzgreQYW2bQvIAU6MMBhUrkWpRl+ZmxFkYMxEm+Qqd5Ym/xNokavfCS4wvTAJ6Awh1cDF5ASXycRHmBYiDqKYG0RprSXP7WmC3fNSGd3rkqhHWq4awDDqTBstwch9LP8rbiARJjI/Bl9qrM4DVv5wMj4PY2+9Dn4/9yWQ0KMuXodtZUA3PDgilBJT3IlTGOxgO9wsS67gRF1kK18NSulRUwMIoUllxG92gWfMOFB+cGYNBiB5yMpo4F8MJ51tkyVFzCco6QBhBODgrx+7xyzCLC++h2g2uAfW+Zi3p4cdOlcRXDsD1eAHEdHvwK7lZwgQp1noNlXIafxUeVU/X95KaP6PgQhcbB6Qp3pruzTZqsFk7xLopfOeJz+7i1aBCN2z/FS7XmvJ5V6eBWNbwXRlN1PzNPnGJInpbPLatNbzGfEw+nVxGt+99TbOoo/4i11jjSxs0xwCr3YGTddJYIN1xLyc0YLBQxKKjbmEGrHytElcQPHxWZH04OLUWITxxTZMUxpAcnFgpNClm6y7q/M+fY3qchO4aP6tbJTsMkU132e6RTRIqN95P5RkbagfHYrgMTWOqfyVt9ssetP24T5+q0s0qlak5GMILZUbydFVEDQVP1YRXzEYwHrRES45rYzUgW9lIUZJ4neG0TMAiwm99mSVkXwNqtoqkLeaUAfXDWX6vsA62xPWDCJcaU+0PQoc5aSDSSbDmfteFKo9bNALbtLMAT2TNki/sXpAiVZJ OV21qtiv Gr3nMPdsFUkmkSE87URBSBTFAwDagMkgq12juRyyWaQTuBSaB0uq542JgWZBUham7ytS78kmLTdqtuRHQbA/nv6ncBYZBeRkD6vzMRFe+TduQHTHsGDn4Xshv32eA7MVeo9WVEVTmUSwpbCnYEJgB0NlW2bRTGDTKWEBWhkbNXjkdukRlUBJQqRJ0TlfONmHZnll5 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: In preparation for large folio numa balancing, make mpol_misplaced() to take a folio, no functional change intended. Signed-off-by: Kefeng Wang --- include/linux/mempolicy.h | 4 ++-- mm/memory.c | 2 +- mm/mempolicy.c | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index d232de7cdc56..4a82eee20073 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -174,7 +174,7 @@ extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol); /* Check if a vma is migratable */ extern bool vma_migratable(struct vm_area_struct *vma); -extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long); +extern int mpol_misplaced(struct folio *, struct vm_area_struct *, unsigned long); extern void mpol_put_task_policy(struct task_struct *); static inline bool mpol_is_preferred_many(struct mempolicy *pol) @@ -278,7 +278,7 @@ static inline int mpol_parse_str(char *str, struct mempolicy **mpol) } #endif -static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma, +static inline int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, unsigned long address) { return -1; /* no node preference */ diff --git a/mm/memory.c b/mm/memory.c index 983a40f8ee62..a04c90604c73 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4731,7 +4731,7 @@ int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, *flags |= TNF_FAULT_LOCAL; } - return mpol_misplaced(page, vma, addr); + return mpol_misplaced(page_folio(page), vma, addr); } static vm_fault_t do_numa_page(struct vm_fault *vmf) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 39584dc25c84..14a223b68180 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2565,24 +2565,24 @@ static void sp_free(struct sp_node *n) } /** - * mpol_misplaced - check whether current page node is valid in policy + * mpol_misplaced - check whether current folio node is valid in policy * - * @page: page to be checked - * @vma: vm area where page mapped - * @addr: virtual address where page mapped + * @folio: folio to be checked + * @vma: vm area where folio mapped + * @addr: virtual address in @vma for shared policy lookup and interleave policy * - * Lookup current policy node id for vma,addr and "compare to" page's + * Lookup current policy node id for vma,addr and "compare to" folio's * node id. Policy determination "mimics" alloc_page_vma(). * Called from fault path where we know the vma and faulting address. * * Return: NUMA_NO_NODE if the page is in a node that is valid for this - * policy, or a suitable node ID to allocate a replacement page from. + * policy, or a suitable node ID to allocate a replacement folio from. */ -int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long addr) +int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, unsigned long addr) { struct mempolicy *pol; struct zoneref *z; - int curnid = page_to_nid(page); + int curnid = folio_nid(folio); unsigned long pgoff; int thiscpu = raw_smp_processor_id(); int thisnid = cpu_to_node(thiscpu); @@ -2638,12 +2638,11 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long BUG(); } - /* Migrate the page towards the node whose CPU is referencing it */ + /* Migrate the folio towards the node whose CPU is referencing it */ if (pol->flags & MPOL_F_MORON) { polnid = thisnid; - if (!should_numa_migrate_memory(current, page_folio(page), - curnid, thiscpu)) + if (!should_numa_migrate_memory(current, folio, curnid, thiscpu)) goto out; }