All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Liang Kan <kan.liang@linux.intel.com>,
	<linux-cxl@vger.kernel.org>, <peterz@infradead.org>,
	<mark.rutland@arm.com>, <will@kernel.org>,
	<dan.j.williams@intel.com>, <mingo@redhat.com>, <acme@kernel.org>,
	<linuxarm@huawei.com>, <linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Davidlohr Bueso <dave@stgolabs.net>,
	"Dave Jiang" <dave.jiang@intel.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v7 4/5] perf: CXL Performance Monitoring Unit driver
Date: Tue, 30 May 2023 14:50:01 +0100	[thread overview]
Message-ID: <20230530145001.00002560@Huawei.com> (raw)
In-Reply-To: <CAM9d7cgYZs4DqLmjPZCYDVrp-KVYoZYDyJHLwB1fOM7ZdzM2Pg@mail.gmail.com>


Hi,

Tidied up the typos. Thanks,

> > +static int cxl_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
> > +{
> > +       struct cxl_pmu_info *info = hlist_entry_safe(node, struct cxl_pmu_info, node);
> > +       unsigned int target;
> > +
> > +       if (info->on_cpu != cpu)
> > +               return 0;
> > +
> > +       info->on_cpu = -1;
> > +       target = cpumask_any_but(cpu_online_mask, cpu);
> > +       if (target >= nr_cpu_ids) {
> > +               dev_err(info->pmu.dev, "Unable to find a suitable CPU\n");
> > +               return 0;
> > +       }
> > +
> > +       perf_pmu_migrate_context(&info->pmu, cpu, target);
> > +       info->on_cpu = target;
> > +       /*
> > +        * CPU HP lock is held so we should be guaranteed that this CPU hasn't yet
> > +        * gone away.
> > +        */
> > +       WARN_ON(irq_set_affinity(info->irq, cpumask_of(target)));
> > +
> > +       return 0;
> > +}  
> 
> IIUC a CXL PMU hardware (say cxl_pmu_mem0.0) is shared across
> all CPUs and it would return the same value when read from any CPU,
> right?

Correct, it will return the same value when used from any CPU.
I'm not sure what issue you are indicating.

My understanding is that, even for such cases, perf uses percpu
variables that mean we still have to ensure that the interrupt
handling occurs on the CPU we have migrated the context to.

There are a lot of similar driver in perf already from a quick
git grep cpumask_any_but\(cpu_online_mask, 

It might be nice to enable perf to operate for these devices without
the percpu context though. I haven't looked into whether that
is worth doing.

Jonathan




> 
> Thanks,
> Namhyung
> 
> 
> > +
> > +static __init int cxl_pmu_init(void)
> > +{
> > +       int rc;
> > +
> > +       rc = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
> > +                                    "AP_PERF_CXL_PMU_ONLINE",
> > +                                    cxl_pmu_online_cpu, cxl_pmu_offline_cpu);
> > +       if (rc < 0)
> > +               return rc;
> > +       cxl_pmu_cpuhp_state_num = rc;
> > +
> > +       rc = cxl_driver_register(&cxl_pmu_driver);
> > +       if (rc)
> > +               cpuhp_remove_multi_state(cxl_pmu_cpuhp_state_num);
> > +
> > +       return rc;
> > +}
> > +
> > +static __exit void cxl_pmu_exit(void)
> > +{
> > +       cxl_driver_unregister(&cxl_pmu_driver);
> > +       cpuhp_remove_multi_state(cxl_pmu_cpuhp_state_num);
> > +}
> > +
> > +MODULE_LICENSE("GPL");
> > +MODULE_IMPORT_NS(CXL);
> > +module_init(cxl_pmu_init);
> > +module_exit(cxl_pmu_exit);
> > +MODULE_ALIAS_CXL(CXL_DEVICE_PMU);
> > --
> > 2.39.2
> >  
> 


  reply	other threads:[~2023-05-30 13:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26  9:58 [PATCH v7 0/5] perf: CXL 3.0 Performance Monitoring Unit support Jonathan Cameron
2023-05-26  9:58 ` [PATCH v7 1/5] perf: Allow a PMU to have a parent Jonathan Cameron
2023-05-26  9:58 ` [PATCH v7 2/5] cxl: Add functions to get an instance of / count regblocks of a given type Jonathan Cameron
2023-05-30 17:10   ` Dave Jiang
2023-05-26  9:58 ` [PATCH v7 3/5] cxl/pci: Find and register CXL PMU devices Jonathan Cameron
2023-05-26  9:58 ` [PATCH v7 4/5] perf: CXL Performance Monitoring Unit driver Jonathan Cameron
2023-05-27  6:26   ` Namhyung Kim
2023-05-30 13:50     ` Jonathan Cameron [this message]
2023-05-30 18:19       ` Dan Williams
2023-05-31  6:07       ` Namhyung Kim
2023-05-26  9:58 ` [PATCH v7 5/5] docs: perf: Minimal introduction the the CXL PMU device and driver Jonathan Cameron

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=20230530145001.00002560@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=acme@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=dave@stgolabs.net \
    --cc=eranian@google.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@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.