Hi Mathieu and Suzuki,
I'm working a patch set to support building coresight drivers as
loadable modules. The main gap is handling dynamicly unload module when
there's some enabled coresight path.
I tried to disable all the enabled coresight paths when device driver
calls coresight_unregister() and free that path. In this case, there
will be no access to the structures that have been freed after removing
the device.
This works fine with sysfs use case. I use one script to unload/load
coresight module continuously and another script to enable/disable
coresight sink/source continuously. There're no Kernel panic.
I'm not really familiar with perf side since most of my work is on sysfs
side. I'd like to know your opinion whether we can do similar thing on
perf use case.Base on my limit understanding on perf etm module, I have
some basic ideas.
1.Record the new perf event to a global list.
2.Record enabled perf event to per_cpu variable since there's only one
enabled event on one CPU.
3.Make a call from coresight_unregister() to perf_etm to clean up.
4.Go through enabled perf events and disable them when device on their
path is removed.
5.Go through global events list and remove all the events with removed
device on their path.
I'm seeking for the correct way to disable perf event and remove them
from etm_perf driver.I'm also thinking about the correct lock to avoid
racing.
Thanks,
Tingwei