[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161020090416.GS3102@twins.programming.kicks-ass.net>
Date: Thu, 20 Oct 2016 11:04:16 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jiri Olsa <jolsa@...hat.com>
Cc: CAI Qian <caiqian@...hat.com>, Rob Herring <robh@...nel.org>,
Kan Liang <kan.liang@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [4.9-rc1+] intel_uncore builtin +
CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic
On Thu, Oct 20, 2016 at 10:58:03AM +0200, Jiri Olsa wrote:
> @@ -8869,11 +8869,15 @@ void perf_pmu_unregister(struct pmu *pmu)
> free_percpu(pmu->pmu_disable_count);
> if (pmu->type >= PERF_TYPE_MAX)
> idr_remove(&pmu_idr, pmu->type);
> - if (pmu->nr_addr_filters)
> - device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
> - device_del(pmu->dev);
> - put_device(pmu->dev);
> + mutex_lock(&pmus_lock);
> + if (pmu_bus_running) {
> + if (pmu->nr_addr_filters)
> + device_remove_file(pmu->dev, &dev_attr_nr_addr_filters);
> + device_del(pmu->dev);
> + put_device(pmu->dev);
> + }
> free_pmu_context(pmu);
> + mutex_unlock(&pmus_lock);
> }
> EXPORT_SYMBOL_GPL(perf_pmu_unregister);
I think that is still racy..
unregister: sysfs_init:
mutex_lock(&pmus_lock);
list_del_rcu(&pmu->entry);
mutex_unlock(&pmus_lock);
synchronize_*rcu();
mutex_lock(&pmus_lock);
list_for_each_entry(pmu, &pmus, entry) {
/* add device muck */
/* will _NOT_ see our PMU */
}
pmus_bus_running = 1;
mutex_unlock(&pmus_lock);
mutex_lock(&pmus_lock);
if (pmu_bus_running) {
device_del() /* OOPS */
What you want is to read pmu_bus_running in the same pmus_lock section
as we do the list_del, and then use that local copy later.
Powered by blists - more mailing lists