From mboxrd@z Thu Jan 1 00:00:00 1970 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 CCCE3C3271F for ; Thu, 4 Jul 2024 17:09:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 406FB6B009B; Thu, 4 Jul 2024 13:09:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B7716B009C; Thu, 4 Jul 2024 13:09:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27FCA6B009D; Thu, 4 Jul 2024 13:09:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0B0726B009B for ; Thu, 4 Jul 2024 13:09:57 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A47041C08AE for ; Thu, 4 Jul 2024 17:09:56 +0000 (UTC) X-FDA: 82302707592.24.8519939 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf17.hostedemail.com (Postfix) with ESMTP id 9D9B04000F for ; Thu, 4 Jul 2024 17:09:54 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@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=1720112969; 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=p4oB1h1O4+z2P9S/qvhjkRsXDOPWY6gylZjUg7HI+ts=; b=T0NaDMAGVLcmAjk5AutEb13Tor2qCfZYpeue1VQSHtGD0zmZ/hGD3kAlh6iYxOPtiZo45D xuwPCzU/hPt2brXrGOwSGAPUXVZe9OPP97retLi595zj36lD1v6SLDEuz/E5oE+FjKFQc4 J4H93dC4Ebl5vxfZVEsBovNvn25WwSc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720112969; a=rsa-sha256; cv=none; b=oEGkw70h8gFkg3mjg1lHqGaB4EREm3nz2Y3GH4JikJg71rX522f+X2BYvcpqpVMtEDpV4B 0DlO4WIUAYrvaWMKWr5zr14rOSQrX4VEkQxZP7oFZeTqDWioiv2MNfW8p1n6k3tlcBZS3y QyMs1rR8rcgmJ9pWkMriv6OnZ7qeVMg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WFNPp2RmKz6K9Kr; Fri, 5 Jul 2024 01:07:58 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id C0523140C72; Fri, 5 Jul 2024 01:09:52 +0800 (CST) Received: from localhost (10.203.174.77) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 4 Jul 2024 18:09:52 +0100 Date: Thu, 4 Jul 2024 18:09:51 +0100 From: Jonathan Cameron To: "Huang, Ying" CC: "Ho-Ren (Jack) Chuang" , Gregory Price , , , , , Eishan Mirakhur , Vinicius Tavares Petrucci , Ravis OpenSrc , Alistair Popple , Srinivasulu Thanneeru , SeongJae Park , "Rafael J. Wysocki" , Len Brown , Andrew Morton , Dave Jiang , Dan Williams , , , , "Ho-Ren (Jack) Chuang" , "Ho-Ren (Jack) Chuang" , "Ho-Ren (Jack) Chuang" , , Subject: Re: [PATCH v2 1/1] memory tier: consolidate the initialization of memory tiers Message-ID: <20240704180951.00005ca6@Huawei.com> In-Reply-To: <87a5iykgdf.fsf@yhuang6-desk2.ccr.corp.intel.com> References: <20240628060925.303309-1-horen.chuang@linux.dev> <20240628060925.303309-2-horen.chuang@linux.dev> <20240702142535.00003dc0@Huawei.com> <87a5iykgdf.fsf@yhuang6-desk2.ccr.corp.intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.174.77] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To lhrpeml500005.china.huawei.com (7.191.163.240) X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9D9B04000F X-Stat-Signature: bm3w6u53ytcb9z71srjwk6u4fpmeawtc X-HE-Tag: 1720112994-289628 X-HE-Meta: U2FsdGVkX18JZ6ABcehbc1P8aj8JwBSbrHK3WxH40qRfiJ4FPwvlt4uN/bj99mQPKQtLYO5KYHKI+GwI0wrseTKGIDO1boDakozXjPqlqIs7X9dOQ+2HwurRtbvovqmUb8KxITRQIlFmAAEgoI27y7v0rTTxyy5yOA2JGYnmeKE4pxNIP1eGz0sjLGzZtt478YTpWx2WUBA43EwrkHVuqqHCwt/9BDhKQU1ipYr/nWU8lB9Bswk/0ENXu7Mt6HkzBP0udNU2qng5z2sf1/G7l/WTitdi8KI0UyfxRAQDgsVsJjfr4aBsJXpJ2dEeZMrESKYJUc55FENywtJP8eatZ+8mr1YFtIaXNvEuBoCtL6bR1bjb+FdUxkB4LshGfVPaFBdqkDxJcYJTyMK2812IBz+cbQxKEaHL8MLINqjrKAVYKteIelmXAaBUP8KfkmQ4F4TfpL/1MsBRmWmS2KoeD0wn6FollIYeFY+oNXnaYJjxSiycPYc5WgNXkAcb8Ra54am4c4orNtAWGSaPIyPd2THBTl3kTrxJjkEgwWBnsrBX7bMEeVJumCuMxzyoocQp+b/yXKStL8nek5vFgDCHQH9Twn2Qrn7bx66Em2EG33CqN9L8cKyZX2YYiviXEWGsjh9vRYcRcZOeIR0RsRB9Vg/iwL23wAYqrH2uUiz7H8k6UGh1Yz+PWyf7/AdYqM6NXVsWqaQg4ChWfOQST6X5yd6Xlrtj9qvARHRO5nkYfCGTpenTKfvGgEigzSagUaB3ck2vqDN0l566mvv7y6h24AibpC8Cy7pMafqCEQaAdfk8xHCvB7CC32Iw4tZLM6gwIP48Ori6gFn/oL1GTt1kKvETJxPj/qa32XayhAMgoYObGDsP2niyX7JgiP7gIDZS8G4YpLdqwSWveQ0MS79PC3FypZwbetBUGpflNcv+3t66DGORU6txXgVY6nuEfDqp0GtwvuqF9IOwq/LpZN7 Aj3zJqAL kIa5yYujkeMs+lTQiJovwPLNMnuHV29vm8igd/YHAmbSH8AERCvU3OUSoUhysCVcraKSIPPGAqANf79nMzTfTxFz35axRssPdAbjNls3XQS8ayzo2ePqiIcRtZzP2JV66P0yhg/yo8Q0xhvK0lq77y/dADwDG1EGa6w39HJLena4izei3il8nk/K8HHixUo9wFIyDViusNQRn9M2gP0WAhHI/j+pQbWUIaqVkXI01J5gMp3vSI1dg3nN2uMzwluUo2UtGJ8l13maOzy4d2zMGj6VNx/I623gXItsMfxENEQjAVxVwt6trFzaAYpmn2eM9FtTJ 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: List-Subscribe: List-Unsubscribe: On Wed, 03 Jul 2024 16:51:40 +0800 "Huang, Ying" wrote: > Jonathan Cameron writes: > > > On Fri, 28 Jun 2024 06:09:23 +0000 > > "Ho-Ren (Jack) Chuang" wrote: > > [snip] > > >> @@ -875,8 +886,7 @@ static int __meminit memtier_hotplug_callback(struct notifier_block *self, > >> > >> static int __init memory_tier_init(void) > >> { > >> - int ret, node; > >> - struct memory_tier *memtier; > >> + int ret; > >> > >> ret = subsys_virtual_register(&memory_tier_subsys, NULL); > >> if (ret) > >> @@ -887,7 +897,8 @@ static int __init memory_tier_init(void) > >> GFP_KERNEL); > >> WARN_ON(!node_demotion); > >> #endif > >> - mutex_lock(&memory_tier_lock); > >> + > >> + guard(mutex)(&memory_tier_lock); > > > > If this was safe to do without the rest of the change (I think so) > > then better to pull that out as a trivial precursor so less noise > > in here. > > > >> /* > >> * For now we can have 4 faster memory tiers with smaller adistance > >> * than default DRAM tier. > >> @@ -897,29 +908,9 @@ static int __init memory_tier_init(void) > >> if (IS_ERR(default_dram_type)) > >> panic("%s() failed to allocate default DRAM tier\n", __func__); > >> > >> - /* > >> - * Look at all the existing N_MEMORY nodes and add them to > >> - * default memory tier or to a tier if we already have memory > >> - * types assigned. > >> - */ > >> - for_each_node_state(node, N_MEMORY) { > >> - if (!node_state(node, N_CPU)) > >> - /* > >> - * Defer memory tier initialization on > >> - * CPUless numa nodes. These will be initialized > >> - * after firmware and devices are initialized. > >> - */ > >> - continue; > >> - > >> - memtier = set_node_memory_tier(node); > >> - if (IS_ERR(memtier)) > >> - /* > >> - * Continue with memtiers we are able to setup > >> - */ > >> - break; > >> - } > >> - establish_demotion_targets(); > >> - mutex_unlock(&memory_tier_lock); > >> + /* Record nodes with memory and CPU to set default DRAM performance. */ > >> + nodes_and(default_dram_nodes, node_states[N_MEMORY], > >> + node_states[N_CPU]); > > > > There are systems where (for various esoteric reasons, such as describing an > > association with some other memory that isn't DRAM where the granularity > > doesn't match) the CPU nodes contain no DRAM but rather it's one node away. > > Handling that can be a job for another day though. > > > > Why does this need to be computed here? Why not do it in > > hmat_set_default_dram_perf? Doesn't seem to be used anywhere else. > > IMO, which node is default dram node is a general concept instead of > HMAT specific. So, I think that it's better to decide that in the > general code (memory-tiers.c). That makes sense given I'd imagine this will spread to other firmware types in time. Thanks, Jonathan > > >> > >> hotplug_memory_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI); > >> return 0; > > -- > Best Regards, > Huang, Ying >