All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	Len Brown <len.brown@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Aubrey Li <aubrey.li@linux.intel.com>,
	Amit Kucheria <amitk@kernel.org>, Andi Kleen <ak@linux.intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
	Ricardo Neri <ricardo.neri@intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/7] thermal: intel: hfi: Handle CPU hotplug events
Date: Thu, 2 Dec 2021 15:43:07 -0800	[thread overview]
Message-ID: <20211202234307.GA334@ranerica-svr.sc.intel.com> (raw)
In-Reply-To: <CAJZ5v0iXBn1o9ZFzNaYU4ft=JcRfNv7AJ8Sq-9HbBJbp60LpWQ@mail.gmail.com>

On Tue, Nov 30, 2021 at 02:32:42PM +0100, Rafael J. Wysocki wrote:
> On Tue, Nov 30, 2021 at 2:22 PM Ricardo Neri
> <ricardo.neri-calderon@linux.intel.com> wrote:
> >
> > On Wed, Nov 24, 2021 at 03:48:49PM +0100, Rafael J. Wysocki wrote:
> > > On Sat, Nov 6, 2021 at 2:34 AM Ricardo Neri
> > > <ricardo.neri-calderon@linux.intel.com> wrote:
> 
> [cut]
> 
> > > > +/**
> > > > + * intel_hfi_offline() - Disable HFI on @cpu
> > > > + * @cpu:       CPU in which the HFI will be disabled
> > > > + *
> > > > + * Remove @cpu from those covered by its HFI instance.
> > > > + *
> > > > + * On some processors, hardware remembers previous programming settings even
> > > > + * after being reprogrammed. Thus, keep HFI enabled even if all CPUs in the
> > > > + * die/package of @cpu are offline. See note in intel_hfi_online().
> > > > + */
> > > > +void intel_hfi_offline(unsigned int cpu)
> > > > +{
> > > > +       struct cpumask *die_cpumask = topology_core_cpumask(cpu);
> > > > +       struct hfi_cpu_info *info = &per_cpu(hfi_cpu_info, cpu);
> > > > +       struct hfi_instance *hfi_instance;
> > > > +
> > > > +       if (!boot_cpu_has(X86_FEATURE_INTEL_HFI))
> > > > +               return;
> > > > +
> > > > +       hfi_instance = info->hfi_instance;
> > > > +       if (!hfi_instance)
> > > > +               return;
> > > > +
> > > > +       if (!hfi_instance->initialized)
> > > > +               return;
> > > > +
> > > > +       mutex_lock(&hfi_lock);
> > > > +
> > > > +       /*
> > > > +        * We were using the core cpumask of @cpu to track CPUs in the same
> > > > +        * die/package. Now it is going offline and we need to find another
> > > > +        * CPU we can use.
> > > > +        */
> > > > +       if (die_cpumask == hfi_instance->cpus) {
> > > > +               int new_cpu;
> > > > +
> > > > +               new_cpu = cpumask_any_but(hfi_instance->cpus, cpu);
> > > > +               if (new_cpu >= nr_cpu_ids)
> > > > +                       /* All other CPUs in the package are offline. */
> > > > +                       hfi_instance->cpus = NULL;
> > > > +               else
> > > > +                       hfi_instance->cpus = topology_core_cpumask(new_cpu);
> > >
> > > Hmmm.  Is topology_core_cpumask() updated when CPUs go offline and online?
> >
> > Yes. A CPU going offline is cleared from its siblings' cpumask [1] and its own [2]
> > in remove_siblinginfo() via cpu_disable_common(). A CPU going online is set
> > in its siblings' cpumask and its own in set_cpu_sibling_map() [3].
> 
> OK, so it is necessary to ensure that intel_hfi_offline() will always
> run after remove_siblinginfo() so it sees the updated mask.  How do we
> ensure that?

I don't think that is possible. remove_siblinginfo() is called from
CPUHP_TEARDOWN_CPU, which always happens after CPUHP_AP_OFFLINE, if I
understand correctly.

I guess that I will need to use a local cpumask as other drivers do.

Thanks and BR,
Ricardo

  reply	other threads:[~2021-12-02 23:44 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-06  1:33 [PATCH 0/7] Thermal: Introduce the Hardware Feedback Interface for thermal and performance management Ricardo Neri
2021-11-06  1:33 ` [PATCH 1/7] x86/Documentation: Describe the Intel Hardware Feedback Interface Ricardo Neri
2021-11-30  9:24   ` Daniel Lezcano
2021-11-30 10:20     ` Srinivas Pandruvada
2021-11-06  1:33 ` [PATCH 2/7] x86: Add definitions for " Ricardo Neri
2021-11-06 10:30   ` Borislav Petkov
2021-11-06 22:01     ` Ricardo Neri
2021-11-06  1:33 ` [PATCH 3/7] thermal: intel: hfi: Minimally initialize the " Ricardo Neri
2021-11-08  8:47   ` Peter Zijlstra
2021-11-09  2:28     ` Ricardo Neri
2021-11-24 14:09   ` Rafael J. Wysocki
2021-11-30  3:20     ` Ricardo Neri
2021-11-30  3:55       ` Srinivas Pandruvada
2021-11-30 13:45         ` Ricardo Neri
2021-11-06  1:33 ` [PATCH 4/7] thermal: intel: hfi: Handle CPU hotplug events Ricardo Neri
2021-11-24 14:48   ` Rafael J. Wysocki
2021-11-30 13:21     ` Ricardo Neri
2021-11-30 13:32       ` Rafael J. Wysocki
2021-12-02 23:43         ` Ricardo Neri [this message]
2021-11-06  1:33 ` [PATCH 5/7] thermal: intel: hfi: Enable notification interrupt Ricardo Neri
2021-11-08  9:01   ` Peter Zijlstra
2021-11-09 15:00     ` Ricardo Neri
2021-11-08  9:07   ` Peter Zijlstra
2021-11-09  2:26     ` Ricardo Neri
2021-11-09  8:48       ` Peter Zijlstra
2021-11-09 12:54         ` Srinivas Pandruvada
2021-11-06  1:33 ` [PATCH 6/7] thermal: netlink: Add a new event to notify CPU capabilities change Ricardo Neri
2021-11-09 12:39   ` Lukasz Luba
2021-11-09 13:23     ` Srinivas Pandruvada
2021-11-09 13:53       ` Lukasz Luba
2021-11-09 14:15         ` Srinivas Pandruvada
2021-11-09 17:51           ` Lukasz Luba
2021-11-09 21:25             ` Srinivas Pandruvada
2021-11-30  9:29   ` Daniel Lezcano
2021-12-09 16:03     ` Ricardo Neri
2021-12-09 16:57       ` Daniel Lezcano
2021-12-09 17:39         ` Srinivas Pandruvada
2021-11-06  1:33 ` [PATCH 7/7] thermal: intel: hfi: Notify user space for HFI events Ricardo Neri
2021-11-24 15:18   ` Rafael J. Wysocki
2021-11-26  6:23     ` Srinivas Pandruvada

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=20211202234307.GA334@ranerica-svr.sc.intel.com \
    --to=ricardo.neri-calderon@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=amitk@kernel.org \
    --cc=aubrey.li@linux.intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=ravi.v.shankar@intel.com \
    --cc=ricardo.neri@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.