From patchwork Thu Sep 21 07:44:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13393711 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 50A80CD5BD7 for ; Thu, 21 Sep 2023 07:46:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E99446B018A; Thu, 21 Sep 2023 03:46:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E49DD6B0192; Thu, 21 Sep 2023 03:46:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3A456B0198; Thu, 21 Sep 2023 03:46:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C55C36B018A for ; Thu, 21 Sep 2023 03:46:51 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A4C2C1A10CA for ; Thu, 21 Sep 2023 07:46:51 +0000 (UTC) X-FDA: 81259823022.19.D423E68 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id B222A40013 for ; Thu, 21 Sep 2023 07:46:48 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1695282410; 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=6nA4CXbR7MXdLwEB7Owk9QkLMvz0OmzW1L385S+xh+k=; b=4IiD+ba9jfLeJP8GUqVEDgEEqiZSBOyvgYXXVrx4VmzeAIVCElC9rPQHGK9rlyJ7GDOOUr yWpMsrCKTCgnBADH8BD0dRWcAEu26y3tZfYKKiDqwu8tl7nLsy3dkBFwUkrt9AdY9GCg/a Gy3DZS+V9kyEZwObt+fFLbzdU0DA+mU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695282410; a=rsa-sha256; cv=none; b=eSYuJzyc1GE0oOur3cenC+x2LgjMcmS1gBIuaKG4ykGIAyzhrkTOccMxBVNBtfMM0L2K42 roF5PQqXABXCVi+LHYqMqwrROf5A1hSUtMb4NihZd2OIcu5189vCkzc07OCQLiJMwa2CVK Qlxvz7ewNSR4G/V5fyG/Xpm7hGGLw3g= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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.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 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-Rspamd-Queue-Id: B222A40013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: u9j9baxsa7oy4masqybnyyhwpcbrcx1b X-HE-Tag: 1695282408-20647 X-HE-Meta: U2FsdGVkX19sV1n/RuoVkG8hUP+geH1+QwiQahZJoYEjSSX1SwToyMbcggXJ6ps+Yv+ViHB5M6YBDwNzotv/wIw2cKyDr8zj6acZmQhKMc4DPevK7vTGzCU2vuFf/nPaojnyLmi5/h9cjSH2b/r+faBwBqiZMERdRx8eEjollzImL80K5KeRLj9kjrGM/xdf+rJ8sUpGq/4v1+9n1C+CzVqARNtFetNxp+O03pjd/EtSNE4roswynB0XSbBbI9ERmZeus8jE05UgQyW37UQ0yr8MaLRts34ny2yntGBU8zmfk2J2YiRnDW78dCPYIaWBfl3HWNW3dpCfL0NPQo3nLfNwq7u59hzujqgEuP9ZHWa/dT/RizlcuXTHGnodezqcH5MkCOboPr/NiIOyQSSLYCmqUdBtQSC3LPedzkYecGUce8tbeiU7FRekaKdqrG8hJowElVKY6JAxWXyUbR8DHUH6ksaToL4Gbt3K6Y8XEVfVBaXzqNKZqgd4sWpGRoc84YXxnnm6FK7D3tTu9RkC9xXvT/VGYbrpZz6CmAms5QFAhbt6SKRby6BCQEN4EzJoidhVt5hhtLTm3E847PZXyhk3YudeVRbHzazvpfX1veZ2FV/9glaTAUOT7LxeIfpJZoQUEoNuazP26bHenkihelGQnwFSa7nIY3usLNPZeFc9i5E8n53Qhx5ETgge7eXpI7PeXIcduAOOuKEzVYNq7Ps09PH5uECPyTe0Gj6ffDkYQwoAWgSGK23PYLk1YFO22xYEVqeYX0IkzUGGncktrvXcMkJJXCldyHPa9bSmO9lxxaetxbUPD/m/9cKuH1iQWN2SoZltAt3XlkULmqS2TJGeEFSf9ToqtKB59dijEJ7EXogR4Kn+4vSUhlzjsdoawf1putdy2d/sQwKt3iQQSLPT7wesOQ8GAwgZBMs0NJMJuGEoP7qbpRjwkyXgWAQ3mvYkeTBPB5iteeDUaVZ rO4pFPOv PF7hWwxsuwarOaHLDZRGCfvbDQ4+RVpEUvdqIbM1oIEkKXHTS7w3d/ujFPJQuFFBchfoFDtFTX7mObazw8BDyNqW0wcl5WNb5anqKN2KJgv79J1XIlv7LO5gCdcFsr/nyDCQdn3VSyqPgZTrS3+vyouVrWQ== 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: 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; }