Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7583818ioo; Fri, 3 Jun 2022 09:18:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP3g090NlGt9NmIjbwCaNfpPaO+bhp7XYDSw4kgmOMotcrBdt9u4Jlat4RVk2/VwVi782h X-Received: by 2002:a63:a23:0:b0:3f5:e1e4:ae3f with SMTP id 35-20020a630a23000000b003f5e1e4ae3fmr9815586pgk.110.1654273082233; Fri, 03 Jun 2022 09:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654273082; cv=none; d=google.com; s=arc-20160816; b=wMPF5QtSMPvZkPFVwFz2r4zoVq+eNJdAI/R0pkqzqMNTMJhRQSsmnkqsgoLfBkcSRQ FRjsQ/IvcW3PyUTNpDxKhVXPEKRZhK7oKwtUxfWzC+iHrbISL0mxw0N6L8wT8B2oRrIW +nshs5I8hs3NkMcj1x53k5eAiGPcaEFP5eJnqzSSWvOpVFU0mDkc/IRMejUo1VPTSkKY /BEhPwtAme8p912bQ22QwGPxIxN1aGwwFgQxNHokqTRowGDEVPOS3PMZKqQUsfrfIpc2 xam9dgf4hPubA4gDWDbSKT0+B0S4QfM/S6bPKoAnEfrwQR0etwsWLI7NmxKQkImQ1/OS Om/w== 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 :dkim-signature; bh=dkro1rlH6gMB3Xr+XLl+CbwUIq9jbXlSu+phhuXyiLc=; b=eTV2QCahfxJSb1jka+wMxIuu1Dwub1sYEuqsz5yrjHhxun8nmE33pWEiTSi4Kcd3f+ rrIMyVrnWiPStTXrc0MAXuh5eJ3EHFXxRTIAVHILobIsa4kUbdX+hT92n6g324ip8Ulh rC+125xU3zoCmt2WMR59vmwV25Q85rdhfXWVRrU3GzYqg/HqkhkeRZeuT49yKdwL6147 PZP7q3KIjUHuc2Q7FSbrS3+/h6XFnC526KDVw/hDEeymfs5+RUJ/RsHPeLczWxRXf6Ie DYq+QVqpDbtRMknhj5bU7/RB4o5j8y8DJM0hW/z4vAdAnRwrFxSsypiO/iWLwLeIr2Vt RxCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=mCDFpIEq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l21-20020a056a0016d500b0050d6182e323si11140743pfc.146.2022.06.03.09.17.47; Fri, 03 Jun 2022 09:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=mCDFpIEq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244232AbiFCNoJ (ORCPT + 99 others); Fri, 3 Jun 2022 09:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244769AbiFCNoF (ORCPT ); Fri, 3 Jun 2022 09:44:05 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 397543A1B8 for ; Fri, 3 Jun 2022 06:44:01 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 253DGraV021315; Fri, 3 Jun 2022 13:43:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=dkro1rlH6gMB3Xr+XLl+CbwUIq9jbXlSu+phhuXyiLc=; b=mCDFpIEqkwpPOApw8gqo24L6mofZWjRpvFYh5v7S8kyBc+4Ac6WHApXZGzqKfL0SpxFW Kav6uSngbNvlwT+mnCgq3HyYqVtEHt5zXP1J8tam0JHI4GPw9o8WC+/xgAlY8QwReuMh 5tTal/URd1E/oW094+D9UG4yXM/s9505vpgrvN3jVwmvp5K3dcXvXgTy1xQVBjA99In1 fZAang3aDo11Mm52LY+v9PtAHIknSNR+j77BC3GqNK6OCdzTeleYMv4WY2hbgTaJauli kYXZlT0Il0DaWXqOLTIsUP2iLEyXCv+1Rh2Ql9rUDU0zoY572c7YsIvfQQanYCmbnUVJ bQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfk1x8ebq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 13:43:44 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 253DSUHJ031862; Fri, 3 Jun 2022 13:43:44 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfk1x8ebf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 13:43:44 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 253Da8SF005529; Fri, 3 Jun 2022 13:43:43 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma01dal.us.ibm.com with ESMTP id 3gcxt62yhd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 13:43:43 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 253Dhfgq29622554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jun 2022 13:43:42 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB61F112067; Fri, 3 Jun 2022 13:43:41 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AABAC112061; Fri, 3 Jun 2022 13:43:33 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.93.173]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 3 Jun 2022 13:43:33 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: Wei Xu , Huang Ying , Greg Thelen , Yang Shi , Davidlohr Bueso , Tim C Chen , Brice Goglin , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Feng Tang , Jagdish Gediya , Baolin Wang , David Rientjes , "Aneesh Kumar K.V" Subject: [PATCH v5 3/9] mm/demotion: Move memory demotion related code Date: Fri, 3 Jun 2022 19:12:31 +0530 Message-Id: <20220603134237.131362-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603134237.131362-1-aneesh.kumar@linux.ibm.com> References: <20220603134237.131362-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: eRc9AmmPVq1txSjdGWhwjIaTHonnXf6D X-Proofpoint-ORIG-GUID: QEXIDvhhB8M8RVlFClW7P3w6W6tuy8s7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-03_04,2022-06-03_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 mlxscore=0 malwarescore=0 adultscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030059 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 This move memory demotion related code to mm/demotion.c. No functional change in this patch. Signed-off-by: Aneesh Kumar K.V --- include/linux/memory-tiers.h | 4 +++ include/linux/migrate.h | 2 -- mm/memory-tiers.c | 60 ++++++++++++++++++++++++++++++++++++ mm/migrate.c | 60 +----------------------------------- mm/vmscan.c | 1 + 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h index 91f071804476..33ef36395a20 100644 --- a/include/linux/memory-tiers.h +++ b/include/linux/memory-tiers.h @@ -15,9 +15,13 @@ #define DEFAULT_MEMORY_TIER MEMORY_TIER_DRAM #define MAX_MEMORY_TIERS 3 +extern bool numa_demotion_enabled; int node_get_memory_tier_id(int node); int node_set_memory_tier(int node, int tier); int node_reset_memory_tier(int node, int tier); +#else +#define numa_demotion_enabled false + #endif /* CONFIG_TIERED_MEMORY */ #endif diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 069a89e847f3..43e737215f33 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -78,7 +78,6 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, #if defined(CONFIG_MIGRATION) && defined(CONFIG_NUMA) extern void set_migration_target_nodes(void); extern void migrate_on_reclaim_init(void); -extern bool numa_demotion_enabled; extern int next_demotion_node(int node); #else static inline void set_migration_target_nodes(void) {} @@ -87,7 +86,6 @@ static inline int next_demotion_node(int node) { return NUMA_NO_NODE; } -#define numa_demotion_enabled false #endif #ifdef CONFIG_COMPACTION diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index 9c78c47ad030..3f382d1f844a 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -307,3 +307,63 @@ static int __init memory_tier_init(void) } subsys_initcall(memory_tier_init); +bool numa_demotion_enabled = false; + +#ifdef CONFIG_SYSFS +static ssize_t numa_demotion_enabled_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%s\n", + numa_demotion_enabled ? "true" : "false"); +} + +static ssize_t numa_demotion_enabled_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + ssize_t ret; + + ret = kstrtobool(buf, &numa_demotion_enabled); + if (ret) + return ret; + + return count; +} + +static struct kobj_attribute numa_demotion_enabled_attr = + __ATTR(demotion_enabled, 0644, numa_demotion_enabled_show, + numa_demotion_enabled_store); + +static struct attribute *numa_attrs[] = { + &numa_demotion_enabled_attr.attr, + NULL, +}; + +static const struct attribute_group numa_attr_group = { + .attrs = numa_attrs, +}; + +static int __init numa_init_sysfs(void) +{ + int err; + struct kobject *numa_kobj; + + numa_kobj = kobject_create_and_add("numa", mm_kobj); + if (!numa_kobj) { + pr_err("failed to create numa kobject\n"); + return -ENOMEM; + } + err = sysfs_create_group(numa_kobj, &numa_attr_group); + if (err) { + pr_err("failed to register numa group\n"); + goto delete_obj; + } + return 0; + +delete_obj: + kobject_put(numa_kobj); + return err; +} +subsys_initcall(numa_init_sysfs); +#endif /* CONFIG_SYSFS */ + diff --git a/mm/migrate.c b/mm/migrate.c index e51588e95f57..29cacc217e38 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2508,64 +2508,6 @@ void __init migrate_on_reclaim_init(void) set_migration_target_nodes(); cpus_read_unlock(); } +#endif /* CONFIG_NUMA */ -bool numa_demotion_enabled = false; - -#ifdef CONFIG_SYSFS -static ssize_t numa_demotion_enabled_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - return sysfs_emit(buf, "%s\n", - numa_demotion_enabled ? "true" : "false"); -} - -static ssize_t numa_demotion_enabled_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - ssize_t ret; - - ret = kstrtobool(buf, &numa_demotion_enabled); - if (ret) - return ret; - - return count; -} - -static struct kobj_attribute numa_demotion_enabled_attr = - __ATTR(demotion_enabled, 0644, numa_demotion_enabled_show, - numa_demotion_enabled_store); - -static struct attribute *numa_attrs[] = { - &numa_demotion_enabled_attr.attr, - NULL, -}; - -static const struct attribute_group numa_attr_group = { - .attrs = numa_attrs, -}; - -static int __init numa_init_sysfs(void) -{ - int err; - struct kobject *numa_kobj; - numa_kobj = kobject_create_and_add("numa", mm_kobj); - if (!numa_kobj) { - pr_err("failed to create numa kobject\n"); - return -ENOMEM; - } - err = sysfs_create_group(numa_kobj, &numa_attr_group); - if (err) { - pr_err("failed to register numa group\n"); - goto delete_obj; - } - return 0; - -delete_obj: - kobject_put(numa_kobj); - return err; -} -subsys_initcall(numa_init_sysfs); -#endif /* CONFIG_SYSFS */ -#endif /* CONFIG_NUMA */ diff --git a/mm/vmscan.c b/mm/vmscan.c index f7d9a683e3a7..3a8f78277f99 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include -- 2.36.1