Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1504714

Re: [4.9-rc1+] intel_uncore builtin + CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [4.9-rc1+] intel_uncore builtin + CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic
Date 2016-10-20 11:50 +0200
Message-ID <sui93-5JM-7@gated-at.bofh.it> (permalink)
References (4 earlier) <su0lQ-2yX-47@gated-at.bofh.it> <su4IO-5Ai-39@gated-at.bofh.it> <sueoN-3mL-1@gated-at.bofh.it> <suhmG-5dC-35@gated-at.bofh.it> <suhwm-5w9-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Oct 20, 2016 at 11:04:16AM +0200, Peter Zijlstra wrote:
> 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 */

ah, I thought this part would add the device back.. but it's
already out of the pmu list.. right :-\

thanks,
jirka

> 				/* 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.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[4.9-rc1+] intel_uncore builtin + CONFIG_DEBUG_TEST_DRIVER_REMOVE  kernel panic CAI Qian <caiqian@redhat.com> - 2016-10-19 16:50 +0200
  Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Jiri Olsa <jolsa@redhat.com> - 2016-10-19 21:30 +0200
    Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic CAI Qian <caiqian@redhat.com> - 2016-10-19 22:20 +0200
    Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Peter Zijlstra <peterz@infradead.org> - 2016-10-20 07:50 +0200
      Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Jiri Olsa <jolsa@redhat.com> - 2016-10-20 11:00 +0200
        Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Peter Zijlstra <peterz@infradead.org> - 2016-10-20 11:10 +0200
          Re: [4.9-rc1+] intel_uncore builtin +  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Jiri Olsa <jolsa@redhat.com> - 2016-10-20 11:50 +0200
            [PATCH] perf: Protect pmu device removal with pmu_bus_running check  CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic Jiri Olsa <jolsa@redhat.com> - 2016-10-20 13:20 +0200
              Re: [PATCH] perf: Protect pmu device removal with pmu_bus_running  check CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic CAI Qian <caiqian@redhat.com> - 2016-10-20 16:40 +0200

csiph-web