From patchwork Thu Sep 21 07:44: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: 13393708 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 31DD9CD5BD5 for ; Thu, 21 Sep 2023 07:46:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9D886B0184; Thu, 21 Sep 2023 03:46:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4E596B0188; Thu, 21 Sep 2023 03:46:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3CCD6B018A; Thu, 21 Sep 2023 03:46:36 -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 A6E246B0184 for ; Thu, 21 Sep 2023 03:46:36 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 71B5116104F for ; Thu, 21 Sep 2023 07:46:36 +0000 (UTC) X-FDA: 81259822392.16.8700870 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id D2D2B12001A for ; Thu, 21 Sep 2023 07:46:33 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; 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; 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=1695282394; 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=3bwHOsF7AvN9Rh08QFZbRWN+H4js2n8PQQGzoYl0bE0=; b=rxPHkODq7U3thI1YmLATb/PdmxqWcL1uh6k2S7EDWIt+aPI5tgn820YlnV1Zi6xX88Yio+ GPIu6mMtYvn+eUR1kJSpTN5txpFabSzpn+dL5ecNaLIf0IGzj/1zOhK/VuOllyzRHL00ts Xlj580L8amuXD97yuoXzYX0BW8kamA8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695282394; a=rsa-sha256; cv=none; b=cJARZRMMMAfDiC5kQMPZDC0aQvb7qU5nBmYAuSfSuHM996YDauPPe1NHw1OYwngvhiuONs o5m44NYANkNn74EgZ0amTt1xiOhvvuqajVsWgHcakuPUVzbn+ymCW1AeuGFxcgRENLAh0p V2HYZEgQXF2RsHLpNe5EJnb99mtrup0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; 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; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RrnQv46tyztSwc; Thu, 21 Sep 2023 15:41:43 +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; Thu, 21 Sep 2023 15:45:58 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 5/6] mm: mempolicy: make mpol_misplaced() to take a folio Date: Thu, 21 Sep 2023 15:44:16 +0800 Message-ID: <20230921074417.24004-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230921074417.24004-1-wangkefeng.wang@huawei.com> References: <20230921074417.24004-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-Stat-Signature: kgpohsa6bu1i5394ea31h6oysgetoa3h X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: D2D2B12001A X-Rspam-User: X-HE-Tag: 1695282393-503916 X-HE-Meta: U2FsdGVkX1+B5Zh39KvocMunApFhEV5f+kb0vybh3eAxLZAbmp7ojVSrdGikaj97gWyJ4qEwvEpKhWqat38GvS9wUPgV1jRydUeEXdUQ7nNdEe/BrJuvyRUwK8t+M+C0wa82mN2btDFJKoN9LbEkQvkAW05lzk+Hw4B8pu6MOqk/aP/pd3fqNAV9zvBmuha+8bFSvuFNhCmMlwD1LAKGfTSZS/CVxx27hOHpKeQcyzDWOK9+KeBRyAZQDXY2R0ZDNtfZFHyD/cTohnVooU2Zdjs8tU0CM7EyzHAzJYlFJr7GU4ZE0pj1dCZJE6+xDxAyB4s4/e0NNKCPM9nlz+Yam1p5laAJXD7Hh1wEOaeEW1uRv8WhsFP+zGiM52TwExgUney9idDb7zZfeZl4sAZ+MuON/nHsGZ8AHmJ0qeyjvRfrgKvEQISTm5pXMkL+c3joMD3SQRStQ5JkP04fJ4sxeUTSJ+WaMzHgYhi8PPKyQXCrosVOsmcLbo78PpT9ipqa97LV7AGLGOE9FByqZcGf2E6Gg0rCF9yZwcC2rIwMtZ53EESRrzlxUeLFtxYCfaSHrQ4UN9sztZfWibcIHbdTbssfXV5bfIky1JA3mEShKK9kbsYDU/iW2y8JJW/YqICI5lHM/4q9OxTWIkOKufVOqsXvws4dD64oPNuIrn06LrGohpjn6GFSp7S2bOr16jHs3SWdoPdGbS7c6KScAAT0UrcTtSDKVRpuJM3fu/pOznS3H9vOsmFMWFC0DK6nHxNkgLkhZq7ELcyiVk3iRlJ22mAzbgIw5r97Tuv5vtMwVXFDk+xWvtPt2Y5a8ydNGG1+QQcuKQNWvRmomgat3tRT5K4ZU7g0yMQpKmtrcu8mF9hkz7UP1UeV8WWd4yehRuHjTGMoFJR8HeoCYKgq3ZrtNdOD1KSt/6QDpUxSVRVTmFQUoRPIUEXFpF8fNYjol656nEtOudS07hXyc5OxSNk B5e+DohR oD1xANHdauEV3WsJUVeQUfB7ACssf4cm1Jo4rNH5clC+2YOApH4wLz1jBqhNavo+raYiEOuS5ngOrzErSu3NTNpqqzBpdWfl8wj2zjhvkc25Lk+mr8XAnUXoz10NY6txQJgmASUaDJb/kMATN5D1t7TdrEd8aOFpQGw8JKIOT0Bw4I75EPwfJwIYyfmmkj6QI4VUY 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 | 5 +++-- mm/memory.c | 2 +- mm/mempolicy.c | 22 ++++++++++++---------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index d232de7cdc56..6c2754d7bfed 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); +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,8 @@ 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 93ce8bcbe9d7..29c5618c91e5 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4741,7 +4741,7 @@ int numa_migrate_prep(struct folio *folio, struct vm_area_struct *vma, *flags |= TNF_FAULT_LOCAL; } - return mpol_misplaced(&folio->page, vma, addr); + return mpol_misplaced(folio, vma, addr); } static vm_fault_t do_numa_page(struct vm_fault *vmf) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 98fae2bfc851..ecf06ce3a5dd 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2572,24 +2572,25 @@ 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); @@ -2645,11 +2646,12 @@ 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, curnid, thiscpu)) + if (!should_numa_migrate_memory(current, &folio->page, curnid, + thiscpu)) goto out; }