Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp471946rdb; Tue, 19 Sep 2023 00:26:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3RNljMps93X/+gyUEgFZCDdF4BzJZ9igeyMqjDStxdBMECiuOIWed4LETybWk1HN2dhNj X-Received: by 2002:a17:90b:18a:b0:26c:f6d2:2694 with SMTP id t10-20020a17090b018a00b0026cf6d22694mr8549535pjs.12.1695108401091; Tue, 19 Sep 2023 00:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695108401; cv=none; d=google.com; s=arc-20160816; b=Xc4GUz+Or0gjTOj1/mAPwzZray4ge2HYaBx3a94vzqix74JBglPn+szf9SQlkanY3x JfeM/jQE6zcswuNO72SvfidsGl2coPm4KvKg6oAIiFSRf5gSMSl5Iw23qwEJtx5BuXIH tT2tDRLFTSxU92djTtE5Lvxriy7yTdFM8aYsao9UQNUS5cs+dfs4rOIbp2PBp1l7RIOv /MedoLsJiHJv54QPmfSlrtxc2UY6Q45zliVOrarHLTfLhC6p0FOO11c9JtYcsg9akeRR Vn+dHAMnX41u4Ek/OEH1fE4aXosPRwdg6hA44Jqu2v622yjgrf/95JxYhmxuTS/elpBT WV5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=ypuIssOWfiop6vzEXIfzD7iONp5EvpX2OOTXxLuWkdw=; fh=5Y9yv03bgp065DML2h0GfCVkXJ4DKFWvgljAwBr/4r8=; b=01Cp31AmEIEz/EaW3/fasTLhVk3+mnjRktaWOoitLp6OdyXbWMs4X5hxxQd+BWs3/F itpLm5R/90sUyiXmc5/NWsdAYScjbHsMUGKnEXRbT0lRFqo1+8gATVvkWiQfR/xgF9BF ZfPx1OKU0lIEo0guIrjS7D/7LolgndKf7eML7+XFg6EiqddbRfhTM1c8rxUcDhiObPE8 izz+2dy6GOlVulmtpVGBRdpwwTLPF7PzKAROoj7uVEaKkFwqtQArnnLKeNfzTe05wdSv V0ZrlXowMGisAP7tym9gAeKyPTPmkaocSZz+lSlx44eDqNjHI7Qjsz8CWCHj1XBytnR2 LxuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="K/XnNrEG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h17-20020a17090aea9100b00274bdd908dasi5454211pjz.97.2023.09.19.00.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 00:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="K/XnNrEG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5E1908127260; Mon, 18 Sep 2023 23:13:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbjISGN1 (ORCPT + 99 others); Tue, 19 Sep 2023 02:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjISGN0 (ORCPT ); Tue, 19 Sep 2023 02:13:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2C6A115 for ; Mon, 18 Sep 2023 23:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695104000; x=1726640000; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=tuzhrLzSWbdbRydP4kaLVjeVbY9OnSWu+GN5+6pY18A=; b=K/XnNrEGFtJQm5kw2evC0kZKJnY56jX+7dEhvhdMXwpcDN6+ujgh3IA+ CNhCER5i+gBDnJWn7PlNdVvnF/DqABNBRrYaEfCCiOYE8upSnZ5E1Mou0 mU+5/narJ3TIUOCr07CwDiaQUR2lGaoUUtei8iyltmlQb+V51EEmA/hHh rWIOkUmmCvJ71TNo2KgTrJVL8ZP9itChWDrMpyda53AkptcuJCa0wiSiu 6Sk3tO69og845QU4v1HQyGgkBIM5HZDZn45j1XdTwKohuTMJxQNiZQabv b+alRNJpyp3In0f/i7FdAcMDSecEwqvXzO5wLjLiyKfoQn7Ip8MP3xar+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="370176610" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="370176610" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 23:13:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="811607597" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="811607597" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 23:13:15 -0700 From: "Huang, Ying" To: Alistair Popple Cc: Andrew Morton , , , Bharata B Rao , "Aneesh Kumar K . V" , Wei Xu , "Dan Williams" , Dave Hansen , Davidlohr Bueso , Johannes Weiner , Jonathan Cameron , Michal Hocko , Yang Shi , Dave Jiang , Rafael J Wysocki Subject: Re: [PATCH -V3 3/4] acpi, hmat: calculate abstract distance with HMAT References: <20230912082101.342002-1-ying.huang@intel.com> <20230912082101.342002-4-ying.huang@intel.com> <8734za6869.fsf@nvdebian.thelocal> Date: Tue, 19 Sep 2023 14:11:11 +0800 In-Reply-To: <8734za6869.fsf@nvdebian.thelocal> (Alistair Popple's message of "Tue, 19 Sep 2023 15:14:10 +1000") Message-ID: <87y1h2wv40.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 23:13:30 -0700 (PDT) Alistair Popple writes: > Thanks for making changes here, looks better to me at least. > > Huang Ying writes: > >> static __init void hmat_free_structures(void) >> { >> struct memory_target *target, *tnext; >> @@ -801,6 +857,7 @@ static __init int hmat_init(void) >> struct acpi_table_header *tbl; >> enum acpi_hmat_type i; >> acpi_status status; >> + int usage; >> >> if (srat_disabled() || hmat_disable) >> return 0; >> @@ -841,7 +898,10 @@ static __init int hmat_init(void) >> hmat_register_targets(); >> >> /* Keep the table and structures if the notifier may use them */ >> - if (!hotplug_memory_notifier(hmat_callback, HMAT_CALLBACK_PRI)) >> + usage = !hotplug_memory_notifier(hmat_callback, HMAT_CALLBACK_PRI); >> + if (!hmat_set_default_dram_perf()) >> + usage += !register_mt_adistance_algorithm(&hmat_adist_nb); >> + if (usage) >> return 0; > > Can we simplify the error handling here? As I understand it > hotplug_memory_notifier() and register_mt_adistance_algorithm() aren't > expected to ever fail because hmat_init() should only be called once and > the notifier register shouldn't fail. So wouldn't the below be > effectively the same thing but clearer? > > if (hotplug_memory_notifier(hmat_callback, HMAT_CALLBACK_PRI)) > goto out_put; > > if (!hmat_set_default_dram_perf()) > register_mt_adistance_algorithm(&hmat_adist_nb); > > return 0; > >> out_put: >> hmat_free_structures(); Looks good to me! Will do that in the next version! > Also as an aside while looking at this patch I noticed a minor bug: > > status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl); > if (ACPI_FAILURE(status)) > goto out_put; > > This will call acpi_put_table(tbl) even though we failed to get the > table. Thanks for pointing this out. This should go through ACPI tree. So will not do this in a separate patch. -- Best Regards, Huang, Ying