Re: [tip:perf/urgent] perf/x86: Set pmu->module in Intel PMU modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 5, 2017 at 7:52 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> The first time I saw this I thought about doing something like the
> below, but never got around to testing if that works and subsequently
> forgot about things again.
>
> Does this make sense and or work?

I'd argue against it.

It will "work", but it's fragile. In particular, if something ever
ends up using perf_pmu_register() through some indirect helper
function, it will do the wrong thing, because

> +#define perf_pmu_register(_pmu, _name, _type)                  \
> +({                                                             \
> +       (_pmu)->module = THIS_MODULE;                           \
> +       __perf_pmu_register((_pmu), (_name), (_type));          \
> +})

.. at that point "THIS_MODULE" could be the module that contains the
helper function that may not actually be the actual end-point module.

Looking at the situation right now, that never happens and all the
users seem to be "leaf" modules. But it would worry me a bit.

                Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux