public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "kirill@shutemov.name" <kirill@shutemov.name>
Cc: "Piper, Chris D" <chris.d.piper@intel.com>,
	"rafael@kernel.org" <rafael@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Williams, Dan J" <dan.j.williams@intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
	"liushixin2@huawei.com" <liushixin2@huawei.com>
Subject: Re: [PATCH 2/2] ACPI: HMAT: Fix initiator registration for single-initiator systems
Date: Wed, 16 Nov 2022 18:02:32 +0000	[thread overview]
Message-ID: <b29163f4e39d28c3656b468a52a63b34073cb933.camel@intel.com> (raw)
In-Reply-To: <20221116124634.nlvnsirdnlafdfeh@box.shutemov.name>

On Wed, 2022-11-16 at 15:46 +0300, Kirill A. Shutemov wrote:
> On Wed, Nov 16, 2022 at 12:57:36AM -0700, Vishal Verma wrote:
> > In a system with a single initiator node, and one or more memory-only
> > 'target' nodes, the memory-only node(s) would fail to register their
> > initiator node correctly. i.e. in sysfs:
> > 
> >   # ls /sys/devices/system/node/node0/access0/targets/
> >   node0
> > 
> > Where as the correct behavior should be:
> > 
> >   # ls /sys/devices/system/node/node0/access0/targets/
> >   node0 node1
> > 
> > This happened because hmat_register_target_initiators() uses list_sort()
> > to sort the initiator list, but the sort comparision function
> > (initiator_cmp()) is overloaded to also set the node mask's bits.
> > 
> > In a system with a single initiator, the list is singular, and list_sort
> > elides the comparision helper call. Thus the node mask never gets set,
> > and the subsequent search for the best initiator comes up empty.
> > 
> > Add a new helper to sort the initiator list, and handle the singular
> > list corner case by setting the node mask for that explicitly.
> > 
> > Reported-by: Chris Piper <chris.d.piper@intel.com>
> > Cc: <stable@vger.kernel.org>
> > Cc: Rafael J. Wysocki <rafael@kernel.org>
> > Cc: Liu Shixin <liushixin2@huawei.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> > ---
> >  drivers/acpi/numa/hmat.c | 32 ++++++++++++++++++++++++++++++--
> >  1 file changed, 30 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
> > index 144a84f429ed..cd20b0e9cdfa 100644
> > --- a/drivers/acpi/numa/hmat.c
> > +++ b/drivers/acpi/numa/hmat.c
> > @@ -573,6 +573,30 @@ static int initiator_cmp(void *priv, const struct list_head *a,
> >         return ia->processor_pxm - ib->processor_pxm;
> >  }
> >  
> > +static int initiators_to_nodemask(unsigned long *p_nodes)
> > +{
> > +       /*
> > +        * list_sort doesn't call @cmp (initiator_cmp) for 0 or 1 sized lists.
> > +        * For a single-initiator system with other memory-only nodes, this
> > +        * means an empty p_nodes mask, since that is set by initiator_cmp().
> > +        * Special case the singular list, and make sure the node mask gets set
> > +        * appropriately.
> > +        */
> > +       if (list_empty(&initiators))
> > +               return -ENXIO;
> > +
> > +       if (list_is_singular(&initiators)) {
> > +               struct memory_initiator *initiator = list_first_entry(
> > +                       &initiators, struct memory_initiator, node);
> > +
> > +               set_bit(initiator->processor_pxm, p_nodes);
> > +               return 0;
> > +       }
> > +
> > +       list_sort(p_nodes, &initiators, initiator_cmp);
> > +       return 0;
> > +}
> > +
> 
> Hm. I think it indicates that these set_bit()s do not belong to
> initiator_cmp().
> 
> Maybe remove both set_bit() from the compare helper and walk the list
> separately to initialize the node mask? I think it will be easier to
> follow.


Yes - I thuoght about this, but went with the seemingly less intrusive
change. I can send a v2 which separates out the set_bit()s. I agree
that's cleaner and easier to follow than overloading initiator_cmp().

  reply	other threads:[~2022-11-16 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  7:57 [PATCH 0/2] ACPI: HMAT: fix single-initiator target registrations Vishal Verma
2022-11-16  7:57 ` [PATCH 1/2] ACPI: HMAT: remove unnecessary variable initialization Vishal Verma
2022-11-16 12:41   ` Kirill A. Shutemov
2022-11-16  7:57 ` [PATCH 2/2] ACPI: HMAT: Fix initiator registration for single-initiator systems Vishal Verma
2022-11-16 12:46   ` Kirill A. Shutemov
2022-11-16 18:02     ` Verma, Vishal L [this message]
2022-11-16 20:44       ` kirill
2022-11-16 12:04 ` [PATCH 0/2] ACPI: HMAT: fix single-initiator target registrations Rafael J. Wysocki

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=b29163f4e39d28c3656b468a52a63b34073cb933.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=chris.d.piper@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liushixin2@huawei.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    /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