Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2276947rdb; Thu, 21 Sep 2023 13:48:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfFCrtrLptaxbApNqhLxIz14DY0Qrye//gowCgoCk5500yDGsBDZG6/esDqvaVXCtmDHEo X-Received: by 2002:a17:903:41c5:b0:1b8:6a09:9cf9 with SMTP id u5-20020a17090341c500b001b86a099cf9mr7951851ple.26.1695329293977; Thu, 21 Sep 2023 13:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695329293; cv=none; d=google.com; s=arc-20160816; b=E8YyZI4daxn5+gdmlW+GkCWjGcib7LDusoPWx/qk32T1JNpgUE7XN/c2Ny2E4n40KS dguOK2G8YLx1iL0wi6KxTD1CWxHvVFRBf/QUMtpIS7l3Y5YmPLIkRzSC8ZxXUnpOTv7t mMua/y4i0Q6+m9yrwAyGG0uELZCZBSDxpeBx6UM27/ZqGxJdLIJKyngUpk/3w2Dbkayv OfvQPFdikEQO5QSQ1NiTlWNPb5LI+SBCQWW4ng1m6wL94yxSlLaEcbH7jppD80OHA/Km zcNdgqQaKQGMbW+w0ec9XaJVMmv2ScTYXsIyO0Yx2gJnECQsBcRLvJh976ZagL9pQQPf WYqw== 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=6nA4CXbR7MXdLwEB7Owk9QkLMvz0OmzW1L385S+xh+k=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=OH4R5ts2/5h8i13TpyMGyFS6NxpufpVzd2j/PAcqUXKE3Ktm5SGF+X5pSZifZ95kj3 6mnSlzloam/1CKfiYAejq7geH+JvW6UOCKEQkriwTtpVQW2CoKAFZ4rS2KdJuRNzuu8y aRciPcRKwjVDOrlex5i8IVxSai7irb1yVbap/nPI+v2dPAAPiZxKGO3KBLQO7l3dD5G5 nT0w3mSwaI5GuM9/ZErg73FkRHsIR8V90jleiewc/qlvKtzdkFI76T80uzz8/0G4ZEGz qVNveMHh6WL2/A7JYccdUGtSxvDUDDfh6C0E6fm9trP8Vjgl8rO5uKnHOQYn1LXMX2Lt bUqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id c6-20020a170902d48600b001bf3fe55e78si2208615plg.600.2023.09.21.13.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id BA70680CE7C3; Thu, 21 Sep 2023 13:34:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjIUUeV (ORCPT + 99 others); Thu, 21 Sep 2023 16:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231825AbjIUUd5 (ORCPT ); Thu, 21 Sep 2023 16:33:57 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749CF73ACC for ; Thu, 21 Sep 2023 10:33:56 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RrnSM73xmzVjNt; Thu, 21 Sep 2023 15:42:59 +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 6/6] sched/numa, mm: make numa migrate functions to take a folio Date: Thu, 21 Sep 2023 15:44:17 +0800 Message-ID: <20230921074417.24004-7-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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:34:42 -0700 (PDT) The cpupid(or access time) is stored in the head page for THP, so it is safely to make should_numa_migrate_memory() and numa_hint_fault_latency() to take a folio. This is in preparation for large folio numa balancing. Signed-off-by: Kefeng Wang --- include/linux/sched/numa_balancing.h | 6 +++--- kernel/sched/fair.c | 12 ++++++------ mm/mempolicy.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/sched/numa_balancing.h b/include/linux/sched/numa_balancing.h index 3988762efe15..06a9d35650f0 100644 --- a/include/linux/sched/numa_balancing.h +++ b/include/linux/sched/numa_balancing.h @@ -20,8 +20,8 @@ extern void task_numa_fault(int last_node, int node, int pages, int flags); extern pid_t task_numa_group_id(struct task_struct *p); extern void set_numabalancing_state(bool enabled); extern void task_numa_free(struct task_struct *p, bool final); -extern bool should_numa_migrate_memory(struct task_struct *p, struct page *page, - int src_nid, int dst_cpu); +bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, + int src_nid, int dst_cpu); #else static inline void task_numa_fault(int last_node, int node, int pages, int flags) @@ -38,7 +38,7 @@ static inline void task_numa_free(struct task_struct *p, bool final) { } static inline bool should_numa_migrate_memory(struct task_struct *p, - struct page *page, int src_nid, int dst_cpu) + struct folio *folio, int src_nid, int dst_cpu) { return true; } diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a502e3255392..75c9a58632a4 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1722,12 +1722,12 @@ static bool pgdat_free_space_enough(struct pglist_data *pgdat) * The smaller the hint page fault latency, the higher the possibility * for the page to be hot. */ -static int numa_hint_fault_latency(struct page *page) +static int numa_hint_fault_latency(struct folio *folio) { int last_time, time; time = jiffies_to_msecs(jiffies); - last_time = xchg_page_access_time(page, time); + last_time = xchg_page_access_time(&folio->page, time); return (time - last_time) & PAGE_ACCESS_TIME_MASK; } @@ -1784,7 +1784,7 @@ static void numa_promotion_adjust_threshold(struct pglist_data *pgdat, } } -bool should_numa_migrate_memory(struct task_struct *p, struct page * page, +bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, int src_nid, int dst_cpu) { struct numa_group *ng = deref_curr_numa_group(p); @@ -1814,16 +1814,16 @@ bool should_numa_migrate_memory(struct task_struct *p, struct page * page, numa_promotion_adjust_threshold(pgdat, rate_limit, def_th); th = pgdat->nbp_threshold ? : def_th; - latency = numa_hint_fault_latency(page); + latency = numa_hint_fault_latency(folio); if (latency >= th) return false; return !numa_promotion_rate_limit(pgdat, rate_limit, - thp_nr_pages(page)); + folio_nr_pages(folio)); } this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid); - last_cpupid = page_cpupid_xchg_last(page, this_cpupid); + last_cpupid = page_cpupid_xchg_last(&folio->page, this_cpupid); if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && !node_is_toptier(src_nid) && !cpupid_valid(last_cpupid)) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index ecf06ce3a5dd..f4e76a887db8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2650,7 +2650,7 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, if (pol->flags & MPOL_F_MORON) { polnid = thisnid; - if (!should_numa_migrate_memory(current, &folio->page, curnid, + if (!should_numa_migrate_memory(current, folio, curnid, thiscpu)) goto out; } -- 2.27.0