linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: Huang Ying <ying.huang@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Bharata B Rao <bharata@amd.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Wei Xu <weixugc@google.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Michal Hocko <mhocko@kernel.org>, Yang Shi <shy828301@gmail.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Rafael J Wysocki <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH -V3 3/4] acpi, hmat: calculate abstract distance with HMAT
Date: Tue, 19 Sep 2023 15:14:10 +1000	[thread overview]
Message-ID: <8734za6869.fsf@nvdebian.thelocal> (raw)
In-Reply-To: <20230912082101.342002-4-ying.huang@intel.com>


Thanks for making changes here, looks better to me at least.

Huang Ying <ying.huang@intel.com> 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();

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.


  parent reply	other threads:[~2023-09-19  5:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  8:20 [PATCH -V3 0/4] memory tiering: calculate abstract distance based on ACPI HMAT Huang Ying
2023-09-12  8:20 ` [PATCH -V3 1/4] memory tiering: add abstract distance calculation algorithms management Huang Ying
2023-09-14 17:29   ` Dave Jiang
2023-09-19  5:13   ` Alistair Popple
2023-09-12  8:20 ` [PATCH -V3 2/4] acpi, hmat: refactor hmat_register_target_initiators() Huang Ying
2023-09-14 17:30   ` Dave Jiang
2023-09-12  8:21 ` [PATCH -V3 3/4] acpi, hmat: calculate abstract distance with HMAT Huang Ying
2023-09-14 17:31   ` Dave Jiang
2023-09-19  5:14   ` Alistair Popple [this message]
2023-09-19  6:11     ` Huang, Ying
2023-09-12  8:21 ` [PATCH -V3 4/4] dax, kmem: calculate abstract distance with general interface Huang Ying
2023-09-14 17:31   ` Dave Jiang
2023-09-19  5:31   ` Alistair Popple
2023-09-19  5:56     ` Huang, Ying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734za6869.fsf@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=bharata@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=shy828301@gmail.com \
    --cc=weixugc@google.com \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox