From patchwork Thu Jul 28 19:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 12931690 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 9BFEFC04A68 for ; Thu, 28 Jul 2022 19:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38A096B0071; Thu, 28 Jul 2022 15:06:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 339726B0072; Thu, 28 Jul 2022 15:06:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DA7E8E0001; Thu, 28 Jul 2022 15:06:18 -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 0BFF46B0071 for ; Thu, 28 Jul 2022 15:06:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E5BF9A0CE2 for ; Thu, 28 Jul 2022 19:06:17 +0000 (UTC) X-FDA: 79737439194.17.3B1DBC4 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf08.hostedemail.com (Postfix) with ESMTP id 3DC081600A4 for ; Thu, 28 Jul 2022 19:06:17 +0000 (UTC) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26SIlmNv018629; Thu, 28 Jul 2022 19:06:07 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=donn9f9OyDlvKkxd3kbeRn/TBljkOOfnH5TovPnfwlU=; b=Biz6XjWRMlzVT+5hy1MPkRbbmmK0LpR2iqgRHB6PE1aVse1xoAjMgQlBAQwRGnUCbm8u lgIzQf5oMLBduONPfDm2Ek0QeDYwd2qi7MufTmV6L90DMAAgi3VYFfqt7mNHwedTgfem Hd1kqa7ByUFMF40Kyr8RVU1ZR/5zCddhxHH5Pcv3zHhOeHq6BX9jkJ4QZ7BTcoUmytKl aaVbC4g0E77esld1DAsfVcysqa8hRe6i7aIEX20fnnrLEl8bLGef3WVmGowK8rHx3Dsk zqOB2VYk75C8jQd7CWMJ88yDTe3Qc1pFGIRDwK8QIrDH7UJYJz3Ce1Q/UPKAJAkeOOFX VA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hm0238suv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 19:06:06 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26SIpDKe029798; Thu, 28 Jul 2022 19:05:34 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 3hm0238s15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 19:05:34 +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 26SJ5HZd003793; Thu, 28 Jul 2022 19:05:21 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma01dal.us.ibm.com with ESMTP id 3hg98shehf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jul 2022 19:05:20 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26SJ5JQV34931180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Jul 2022 19:05:19 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3C8F6A047; Thu, 28 Jul 2022 19:05:19 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D53B6A04D; Thu, 28 Jul 2022 19:05:14 +0000 (GMT) Received: from skywalker.ibmuc.com (unknown [9.43.25.218]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 28 Jul 2022 19:05:13 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: Wei Xu , Huang Ying , Yang Shi , Davidlohr Bueso , Tim C Chen , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Johannes Weiner , jvgediya.oss@gmail.com, "Aneesh Kumar K.V" Subject: [PATCH v11 4/8] mm/demotion/dax/kmem: Set node's abstract distance to MEMTIER_ADISTANCE_PMEM Date: Fri, 29 Jul 2022 00:34:32 +0530 Message-Id: <20220728190436.858458-5-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728190436.858458-1-aneesh.kumar@linux.ibm.com> References: <20220728190436.858458-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bfrT-tiO2ZblNXq2-UMQiu6skOp8YqYG X-Proofpoint-ORIG-GUID: Ypt4IbU8PiVovesu1XT-nRNVpzAaJ7hM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 adultscore=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207280086 ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Biz6XjWR; spf=pass (imf08.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659035177; a=rsa-sha256; cv=none; b=gku5VFENkw/1nX1+z1q92KurhHJlct/hWh1/dL/YrU3gWT7c9mwQOMCqujjahPPQoowvau CVELRrfgAkfzqx6tgfG6wxKpds7Lijsa/QYhxUi7vA97owv6sUyMBtkIPamJuipb6mg8NJ qx5SekqLWtTTpf8yvKbQJNXtuGH/t0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659035177; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=donn9f9OyDlvKkxd3kbeRn/TBljkOOfnH5TovPnfwlU=; b=dbp5XVqxwjjfPsE+NYugZDSjh7l1GXGKxLuOhR98yUbp6rnb3HJXlFQEz/5Fo5SFM0dY5R 3rJyQzKaOVR3sVJ6ekOnhPPLv6S3C8nzbtQtbhUNxMYfDUmQSs1su4/b87jiZrxAOCtdvL kCqvmqsIA1KCdjA3LAMaiSdjp5pAWmc= X-Stat-Signature: uju86bzbyi8sjocw6ems9yrbbuob7fw7 X-Rspamd-Queue-Id: 3DC081600A4 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Biz6XjWR; spf=pass (imf08.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspamd-Server: rspam02 X-HE-Tag: 1659035177-807167 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: By default, all nodes are assigned to the default memory tier which is the memory tier designated for nodes with DRAM Set dax kmem device node's tier to slower memory tier by assigning abstract distance to MEMTIER_ADISTANCE_PMEM. PMEM tier appears below the default memory tier in demotion order. Signed-off-by: Aneesh Kumar K.V --- drivers/dax/kmem.c | 9 +++++++++ include/linux/memory-tiers.h | 19 ++++++++++++++++++- mm/memory-tiers.c | 28 ++++++++++++++++------------ 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index a37622060fff..6b0d5de9a3e9 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "dax-private.h" #include "bus.h" @@ -41,6 +42,12 @@ struct dax_kmem_data { struct resource *res[]; }; +static struct memory_dev_type default_pmem_type = { + .adistance = MEMTIER_ADISTANCE_PMEM, + .tier_sibiling = LIST_HEAD_INIT(default_pmem_type.tier_sibiling), + .nodes = NODE_MASK_NONE, +}; + static int dev_dax_kmem_probe(struct dev_dax *dev_dax) { struct device *dev = &dev_dax->dev; @@ -62,6 +69,8 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax) return -EINVAL; } + init_node_memory_type(numa_node, &default_pmem_type); + for (i = 0; i < dev_dax->nr_range; i++) { struct range range; diff --git a/include/linux/memory-tiers.h b/include/linux/memory-tiers.h index 976f43a5e3be..4f4baf0bf430 100644 --- a/include/linux/memory-tiers.h +++ b/include/linux/memory-tiers.h @@ -2,6 +2,8 @@ #ifndef _LINUX_MEMORY_TIERS_H #define _LINUX_MEMORY_TIERS_H +#include +#include /* * Each tier cover a abstrace distance chunk size of 128 */ @@ -15,12 +17,27 @@ #define MEMTIER_ADISTANCE_PMEM (1 << MEMTIER_CHUNK_BITS) #define MEMTIER_HOTPLUG_PRIO 100 +struct memory_tier; +struct memory_dev_type { + /* list of memory types that are are part of same tier as this type */ + struct list_head tier_sibiling; + /* abstract distance for this specific memory type */ + int adistance; + /* Nodes of same abstract distance */ + nodemask_t nodes; + struct memory_tier *memtier; +}; + #ifdef CONFIG_NUMA -#include extern bool numa_demotion_enabled; +struct memory_dev_type *init_node_memory_type(int node, struct memory_dev_type *default_type); #else #define numa_demotion_enabled false +static inline struct memory_dev_type *init_node_memory_type(int node, struct memory_dev_type *default_type) +{ + return ERR_PTR(-EINVAL); +} #endif /* CONFIG_NUMA */ #endif /* _LINUX_MEMORY_TIERS_H */ diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c index c9854a394d9b..109be75fa554 100644 --- a/mm/memory-tiers.c +++ b/mm/memory-tiers.c @@ -1,6 +1,4 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include #include #include #include @@ -19,16 +17,6 @@ struct memory_tier { int adistance_start; }; -struct memory_dev_type { - /* list of memory types that are are part of same tier as this type */ - struct list_head tier_sibiling; - /* abstract distance for this specific memory type */ - int adistance; - /* Nodes of same abstract distance */ - nodemask_t nodes; - struct memory_tier *memtier; -}; - static DEFINE_MUTEX(memory_tier_lock); static LIST_HEAD(memory_tiers); struct memory_dev_type *node_memory_types[MAX_NUMNODES]; @@ -141,6 +129,22 @@ static void clear_node_memory_tier(int node) mutex_unlock(&memory_tier_lock); } +struct memory_dev_type *init_node_memory_type(int node, struct memory_dev_type *default_type) +{ + struct memory_dev_type *mem_type; + + mutex_lock(&memory_tier_lock); + if (node_memory_types[node]) { + mem_type = node_memory_types[node]; + } else { + node_memory_types[node] = default_type; + node_set(node, default_type->nodes); + mem_type = default_type; + } + mutex_unlock(&memory_tier_lock); + return mem_type; +} + static int __meminit memtier_hotplug_callback(struct notifier_block *self, unsigned long action, void *_arg) {