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 B2AE7C001DB for ; Mon, 7 Aug 2023 16:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA0276B0072; Mon, 7 Aug 2023 12:55:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E50AA6B0074; Mon, 7 Aug 2023 12:55:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D17EB6B0075; Mon, 7 Aug 2023 12:55:56 -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 C2F426B0072 for ; Mon, 7 Aug 2023 12:55:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 39EB68066F for ; Mon, 7 Aug 2023 16:55:56 +0000 (UTC) X-FDA: 81097910712.16.19A3B8F Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf09.hostedemail.com (Postfix) with ESMTP id 9E22E140024 for ; Mon, 7 Aug 2023 16:55:52 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.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=1691427353; 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=EHfsZx4GW5UfiMTWER9g6ztrKnyGR+Isxs2CG3wGg6Q=; b=DnIrkYqGjputJDvESmHB7ysHlZZlhs8e7JN4hk0d5/bCMCniiswo9CAP26gd2npUtYG5qr HswPrkm9W2+o+4WapjaaQC5p/NplfUg62ESf3FAklzsheuIxpU4rOYwgBUYGBw9a6shPLA dZ6KB5R3+/p1KUL+8jEru/4V9EsySoE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691427353; a=rsa-sha256; cv=none; b=HXQbHMSZywPrueIG+UzoYEaRsj0hvgNoHgZPRyUlC5ttDrBRSI0k9XkXnG8zKC+Iw7EqZq P9PF/d7NHHoznloTUAyeSHyr6AlpSeJyJAg95Vok5YJNSOUZqHZEnDUkLx0EMX8+RmCwVc 8EFmbG3y846BdGciF1dPEqNIO2vtzlI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.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 lhrpeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4RKMlH5c02z6HJf6; Tue, 8 Aug 2023 00:50:51 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 7 Aug 2023 17:55:47 +0100 Date: Mon, 7 Aug 2023 17:55:46 +0100 From: Jonathan Cameron To: Huang Ying CC: Andrew Morton , , , , , , "Aneesh Kumar K . V" , Wei Xu , Alistair Popple , Dan Williams , Dave Hansen , Davidlohr Bueso , "Johannes Weiner" , Michal Hocko , Yang Shi , Rafael J Wysocki Subject: Re: [PATCH RESEND 2/4] acpi, hmat: refactor hmat_register_target_initiators() Message-ID: <20230807175546.00001566@Huawei.com> In-Reply-To: <20230721012932.190742-3-ying.huang@intel.com> References: <20230721012932.190742-1-ying.huang@intel.com> <20230721012932.190742-3-ying.huang@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.202.227.76] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 9E22E140024 X-Rspam-User: X-Stat-Signature: ikcriyk5ihjuqx5cqp8zs94jogi597j3 X-Rspamd-Server: rspam03 X-HE-Tag: 1691427352-789146 X-HE-Meta: U2FsdGVkX1+7XJgs6amLgbTn+YECb1QckSmAAS67mQlFB/6dSh9THAuew0IWIqhMEaN4Roxp5Eo22xAtSy4Py9I3WIszXj3jRdZtJnRVAqvXJH/5UCJ0o9WNlyl5plMAlwn7M8Z6ytbenOO8eKD9kQjrK3D2InWppKku8Bxp4DVgpDEBPfDj6eFBoyEX4PIzovKQHXBvEnrOPhtZHIGsT8PSC6vVUsKYBewBKjsVQv9OQHUJza2dIVA1Gt4XgGvyGpllHuScUOZA0CbTC9iiABDMr4huYAxNC+vIiZh6u6TYTv4U2BFvs2gQ5ZylGgO0VPk4gHsjGS7A8/TNS3z9kUPalr+z/RgcMeh63Zl/0NEM9UQy3U3/af+mzxVctOXlXDV2w8lY/kYlMoiq8+T15/1YfxZzMLMbF+Yhi8dBTjdNE47aU41Kk49adAyEjmVF4v9eGKSc5A2JKk5SljUWCcrkjRSjAj+n8R0e1kp99VnUI8enL+oExnco7GoFBbxhL+GQ3FUt2kGe8wa/uctrDpGFq8y24+qKq0MhpbeVxN9JRUAx6JnvXwkCvcGjN6ZURReahPLo/1UuMs5g/ryvfZP0uxrcCxAElNms92Rzw7FfH1Z5HoJc9KKRbf8xWgnoA0NlL13gZHnLX+O143Q/ChdoOo56sHltg22d7HxbUr/eL7ffeqtQtRZ8nBZTdh1a1bsEN/4dsXMbokG7rnCxWOXimr779kSgpCFuda5wL93hfGAEqYfzORTRJFnVyC/oZvSawJz5/tUd/CJ8Olwk8FnG4V1WOlcMQ+X3DssauW7m0mSY4Z0TrsjgVRGmYXZwREAWo8OQgH+OaoGUCeEAf7lCD5C6eL1TFC9kJPI1ER+79B4+zy6iz1MM8B/ihzg9U7PT+CBRs0kymh/+dKaY43vhdFShqd5QcVDY8DpffEwc87zDoh2VkkY/q1nJA6IXlcp0OtCrfunpG2T1jfm dXNoJQr6 cMG70kgRDSpv8y081a+70IK2kGGbrRtKvtWewjIMry+s/HNT5lIbKbfZyeBlMNKbZ22msBe2MYDl0JvNWLpDoxhfwkrkQhO7rOYOmOmOwH/0mQehm2WZLRn0ocp23WMCs2IKTNdCHOua2TwRV129EBG3nD4A25/U8E1L6DAYOLdNWLzh8avu6p7YRTcQ8Mn/ClIBaPvNlAsGF9R0Ajd+77wgiVxQFvdWFBVwNxLgHVmL7PjWR7Za6RbyeWBOJPNPD0QHtv65EZyX5cKw7wjSIL+dVF94ThH2ua/cUK7DJMJNMFNaiWuYEhPDOEf6FBar+lLHpTTBhRmsW3Rv8NFAh6wqgPa0TGL8+ojRQoIazSw5Q0bC4pFahx4b7rveMSOzlJF6Aul0cvGMkHJwlQqPekX/5CK5teJEFJRlGIKGW+VLAcCQBnBMM4u6pG+5ZDzcWUuRXkJ4zmZlnc1jo3STeYmPHjBRyK4Mxk9dWBOS+mvT8MOE2zdzJUo6NpSPy1ucXNffN+CJYtp4S9SPB24i8Xkz5xpbfClZ+y34ms83RynUiBPbTISaqj+FDwbJOqIC9zrR9 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: On Fri, 21 Jul 2023 09:29:30 +0800 Huang Ying wrote: > Previously, in hmat_register_target_initiators(), the performance > attributes are calculated and the corresponding sysfs links and files > are created too. Which is called during memory onlining. > > But now, to calculate the abstract distance of a memory target before > memory onlining, we need to calculate the performance attributes for > a memory target without creating sysfs links and files. > > To do that, hmat_register_target_initiators() is refactored to make it > possible to calculate performance attributes separately. > > Signed-off-by: "Huang, Ying" > Cc: Aneesh Kumar K.V > Cc: Wei Xu > Cc: Alistair Popple > Cc: Dan Williams > Cc: Dave Hansen > Cc: Davidlohr Bueso > Cc: Johannes Weiner > Cc: Jonathan Cameron > Cc: Michal Hocko > Cc: Yang Shi > Cc: Rafael J Wysocki Unfortunately I don't think I still have the tables I used to test the generic initiator and won't get time to generate them all again in next few weeks. So just a superficial review for now. I 'think' the cleanup looks good but the original code was rather fiddly so I'm not 100% sure nothing is missed. One comment inline on the fact the list is now sorted twice. > --- > drivers/acpi/numa/hmat.c | 81 +++++++++++++++------------------------- > 1 file changed, 30 insertions(+), 51 deletions(-) > > diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c > index bba268ecd802..2dee0098f1a9 100644 > --- a/drivers/acpi/numa/hmat.c > +++ b/drivers/acpi/numa/hmat.c > @@ -582,28 +582,25 @@ static int initiators_to_nodemask(unsigned long *p_nodes) > return 0; > } > > -static void hmat_register_target_initiators(struct memory_target *target) > +static void hmat_update_target_attrs(struct memory_target *target, > + unsigned long *p_nodes, int access) > { > - static DECLARE_BITMAP(p_nodes, MAX_NUMNODES); > struct memory_initiator *initiator; > - unsigned int mem_nid, cpu_nid; > + unsigned int cpu_nid; > struct memory_locality *loc = NULL; > u32 best = 0; > - bool access0done = false; > int i; > > - mem_nid = pxm_to_node(target->memory_pxm); > + bitmap_zero(p_nodes, MAX_NUMNODES); > /* > - * If the Address Range Structure provides a local processor pxm, link > + * If the Address Range Structure provides a local processor pxm, set > * only that one. Otherwise, find the best performance attributes and > - * register all initiators that match. > + * collect all initiators that match. > */ > if (target->processor_pxm != PXM_INVAL) { > cpu_nid = pxm_to_node(target->processor_pxm); > - register_memory_node_under_compute_node(mem_nid, cpu_nid, 0); > - access0done = true; > - if (node_state(cpu_nid, N_CPU)) { > - register_memory_node_under_compute_node(mem_nid, cpu_nid, 1); > + if (access == 0 || node_state(cpu_nid, N_CPU)) { > + set_bit(target->processor_pxm, p_nodes); > return; > } > } > @@ -617,47 +614,10 @@ static void hmat_register_target_initiators(struct memory_target *target) > * We'll also use the sorting to prime the candidate nodes with known > * initiators. > */ > - bitmap_zero(p_nodes, MAX_NUMNODES); > list_sort(NULL, &initiators, initiator_cmp); > if (initiators_to_nodemask(p_nodes) < 0) > return; One result of this refactor is that a few things run twice, that previously only ran once like this list_sort() Not necessarily a problem though as probably fairly cheap. > > - if (!access0done) { > - for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) { > - loc = localities_types[i]; > - if (!loc) > - continue; > - > - best = 0; > - list_for_each_entry(initiator, &initiators, node) { > - u32 value; > - > - if (!test_bit(initiator->processor_pxm, p_nodes)) > - continue; > - > - value = hmat_initiator_perf(target, initiator, > - loc->hmat_loc); > - if (hmat_update_best(loc->hmat_loc->data_type, value, &best)) > - bitmap_clear(p_nodes, 0, initiator->processor_pxm); > - if (value != best) > - clear_bit(initiator->processor_pxm, p_nodes); > - } > - if (best) > - hmat_update_target_access(target, loc->hmat_loc->data_type, > - best, 0); > - } > - > - for_each_set_bit(i, p_nodes, MAX_NUMNODES) { > - cpu_nid = pxm_to_node(i); > - register_memory_node_under_compute_node(mem_nid, cpu_nid, 0); > - } > - } > - > - /* Access 1 ignores Generic Initiators */ > - bitmap_zero(p_nodes, MAX_NUMNODES); > - if (initiators_to_nodemask(p_nodes) < 0) > - return; > - > for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) { > loc = localities_types[i]; > if (!loc) > @@ -667,7 +627,7 @@ static void hmat_register_target_initiators(struct memory_target *target) > list_for_each_entry(initiator, &initiators, node) { > u32 value; > > - if (!initiator->has_cpu) { > + if (access == 1 && !initiator->has_cpu) { > clear_bit(initiator->processor_pxm, p_nodes); > continue; > } > @@ -681,14 +641,33 @@ static void hmat_register_target_initiators(struct memory_target *target) > clear_bit(initiator->processor_pxm, p_nodes); > } > if (best) > - hmat_update_target_access(target, loc->hmat_loc->data_type, best, 1); > + hmat_update_target_access(target, loc->hmat_loc->data_type, best, access); > } > +} > + > +static void __hmat_register_target_initiators(struct memory_target *target, > + unsigned long *p_nodes, > + int access) > +{ > + unsigned int mem_nid, cpu_nid; > + int i; > + > + mem_nid = pxm_to_node(target->memory_pxm); > + hmat_update_target_attrs(target, p_nodes, access); > for_each_set_bit(i, p_nodes, MAX_NUMNODES) { > cpu_nid = pxm_to_node(i); > - register_memory_node_under_compute_node(mem_nid, cpu_nid, 1); > + register_memory_node_under_compute_node(mem_nid, cpu_nid, access); > } > } > > +static void hmat_register_target_initiators(struct memory_target *target) > +{ > + static DECLARE_BITMAP(p_nodes, MAX_NUMNODES); > + > + __hmat_register_target_initiators(target, p_nodes, 0); > + __hmat_register_target_initiators(target, p_nodes, 1); > +} > + > static void hmat_register_target_cache(struct memory_target *target) > { > unsigned mem_nid = pxm_to_node(target->memory_pxm);