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: 141359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2573817vqi; Mon, 18 Sep 2023 04:14:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWxbnQygN4+WsBFbpKr+wBRrWzb/EzY4FoBAWp1vsHoZ3N1ecOIUGqIT9xxIC4aqZX8cd/ X-Received: by 2002:a17:90a:6e09:b0:268:13c4:b800 with SMTP id b9-20020a17090a6e0900b0026813c4b800mr7932086pjk.21.1695035642183; Mon, 18 Sep 2023 04:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695035642; cv=none; d=google.com; s=arc-20160816; b=TfaVCInuDXKjqiNbz4j36eqGDkMs+jCN4U0TMxrFcjZnpMf4bRhIfvYQIfcr6KK8zW dpmlw1Ee2quui9LLa4viADXQlOA/O5B8ZnAGPqMg6UdGJAdpFn4FIlSPvbLEQd0yyurq iA00EAnF8F+LPwy2Vyj4Ww6TKKNCnAxm4+LcSJv6azEJDe6m3N45WYHngp/q0r7KlWtY rrc+X0n8qK6eCK1XWnEyvIBFt747t4Ex7rXFyKUFNhtnXR+9h2f17oWoz0X/c26XAcvV pQiQ6wn/ItWGuPXilD2CfLQk5pZ7LBAWXhsndjHbpIRbP3FWzsloSYbsJFzi9QQCuNME c9Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q0j2iplv8tIoDxFaHxiXvS50HobKD+ChXL38zg2Jy/Q=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=OjvO3U/OmQV3TIMCHknDASBGooixeIITKJo+xFmTfZP5wlgbde5P63qnqgHLwwh2pa XZz3ERlUnItH1+AqWWKBnIP7lTATZSF3GLKMgRQsIOaZH5RmuzwoI/0eYJxkz2U0RS9G eklhGVgxl1y9WAfSH9GKsnLwKI0fcNm7wvBrYPIVRI1XOEJ8eGgKoh2LZkNMBzWMOIfR jxuaKcF9zHXkoYac2Tcgo2El5Tw6QTo2vuu6G1Vzd7y2pGi7DET1kxzjRaezr70U6WY9 OEOLI+s+m4ySjQwsXJZcFBdqVaTGru58ZUA/Rzu6ba7eAAc+9X+VdbgduhzCv3xVBpqg 7U8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id d3-20020a17090ac24300b0027474b117f7si7217851pjx.21.2023.09.18.04.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 209D6802D3D7; Mon, 18 Sep 2023 03:34:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241311AbjIRKdi (ORCPT + 27 others); Mon, 18 Sep 2023 06:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241330AbjIRKdN (ORCPT ); Mon, 18 Sep 2023 06:33:13 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE8E123 for ; Mon, 18 Sep 2023 03:32:49 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 03:34:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777373693408342937 X-GMAIL-MSGID: 1777373693408342937 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; }