x86/intel_pstate: relocate the driver register/unregister function
PATCH v2 5/9 x86/intel_pstate: relocate the driver register/unregister function
Register/unregister the CPU hotplug notifier when the driver is registered, and move the driver register/unregister function to the cpufreq.c.
--- xen/drivers/cpufreq/cpufreq.c | 27 +++++++++++++++++++++++---- xen/include/acpi/cpufreq/cpufreq.h | 28 ++-------------------------- 2 files changed, 25 insertions(+), 30 deletions(-)
xen/drivers/cpufreq/cpufreq.c +23 -4
@@ -630,12 +630,31 @@ static struct notifier_block cpu_nfb = { .notifier_call = cpu_callback }; -static int __init cpufreq_presmp_init (void ) +int cpufreq_register_driver (struct cpufreq_driver *driver_data) { -void *cpu = (void *)(long )smp_processor_id (); -cpu_callback (&cpu_nfb,CPU_ONLINE , cpu); +if (!driver_data || !driver_data->init + || !driver_data->verify || !driver_data->exit + || (!driver_data->target == !driver_data->setpolicy)) +return -EINVAL ; + +if (cpufreq_driver) +return -EBUSY ; + + cpufreq_driver = driver_data; +register_cpu_notifier (&cpu_nfb); +return 0 ; } -presmp_initcall (cpufreq_presmp_init); +int cpufreq_unregister_driver (struct cpufreq_driver *driver) +{ +if (!cpufreq_driver || (driver != cpufreq_driver)) +return -EINVAL ; + + cpufreq_driver =NULL ; + +unregister_cpu_notifier (&cpu_nfb); + +return 0 ; +}
xen/include/acpi/cpufreq/cpufreq.h +2 -26
@@ -167,32 +167,8 @@ struct cpufreq_driver {extern struct cpufreq_driver *cpufreq_driver; -static __inline__ -int cpufreq_register_driver (struct cpufreq_driver *driver_data) -{ -if (!driver_data || - !driver_data->init || - !driver_data->exit || - !driver_data->verify || - !driver_data->target) -return -EINVAL ; - -if (cpufreq_driver) -return -EBUSY ; - - cpufreq_driver = driver_data; -return 0 ; -} - -static __inline__ -int cpufreq_unregister_driver (struct cpufreq_driver *driver) -{ -if (!cpufreq_driver || (driver != cpufreq_driver)) -return -EINVAL ; - - cpufreq_driver =NULL ; -return 0 ; -} +extern int cpufreq_register_driver (struct cpufreq_driver *driver_data); +extern int cpufreq_unregister_driver (struct cpufreq_driver *driver); static __inline__ void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
Signature · 1 line
1.9.1
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
Register/unregister the CPU hotplug notifier when the driver is registered, and move the driver register/unregister function to the
cpufreq.c.
Without saying why I'm afraid I don't even see much reason to review this in any detail.
xen/drivers/cpufreq/cpufreq.c static struct notifier_block cpu_nfb = { · line 636
Quoted 11 lines
xen/drivers/cpufreq/cpufreq.c +1
-3@@ -630,12 +630,31 @@ static struct notifier_block cpu_nfb = { .notifier_call = cpu_callback }; -static int __init cpufreq_presmp_init (void ) +int cpufreq_register_driver (struct cpufreq_driver *driver_data) { -void *cpu = (void *)(long )smp_processor_id (); -cpu_callback (&cpu_nfb,CPU_ONLINE , cpu);
Why is this being removed without replacement?
Quoted 17 lines
xen/drivers/cpufreq/cpufreq.c +12
-1+if (!driver_data || !driver_data->init + || !driver_data->verify || !driver_data->exit + || (!driver_data->target == !driver_data->setpolicy)) +return -EINVAL ; + +if (cpufreq_driver) +return -EBUSY ; + + cpufreq_driver = driver_data; +register_cpu_notifier (&cpu_nfb); +return 0 ; } -presmp_initcall (cpufreq_presmp_init); +int cpufreq_unregister_driver (struct cpufreq_driver *driver)
xen/drivers/cpufreq/cpufreq.c static struct notifier_block cpu_nfb = { · line 660
Quoted 10 lines
xen/drivers/cpufreq/cpufreq.c +10
-0+{ +if (!cpufreq_driver || (driver != cpufreq_driver)) +return -EINVAL ; + + cpufreq_driver =NULL ; + +unregister_cpu_notifier (&cpu_nfb); + +return 0 ; +}
This function is dead (and perhaps just like unregister_cpu_notifier() not even needed without loadable modules).
Jan
xen/include/acpi/cpufreq/cpufreq.h struct cpufreq_driver { · line 171
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
xen/include/acpi/cpufreq/cpufreq.h +2
-0+extern int cpufreq_register_driver (struct cpufreq_driver *driver_data); +extern int cpufreq_unregister_driver (struct cpufreq_driver *driver);
Oh, btw, please also get rid of "extern" on function declarations, unless in a particular header it is consistently being used.
Jan
On 26/05/2015 21:06, Jan Beulich wrote
Quoted 14 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
Register/unregister the CPU hotplug notifier when the driver is registered, and move the driver register/unregister function to the
cpufreq.c.Without saying why I'm afraid I don't even see much reason to review this in any detail.
Quoted 6 lines
xen/drivers/cpufreq/cpufreq.c +0
-0@@ -630,12 +630,31 @@ static struct notifier_block cpu_nfb = { .notifier_call = cpu_callback };
Quoted 7 lines
xen/drivers/cpufreq/cpufreq.c static struct notifier_block cpu_nfb = { · line 636
Quoted 5 lines
xen/drivers/cpufreq/cpufreq.c +1
-3-static int __init cpufreq_presmp_init (void ) +int cpufreq_register_driver (struct cpufreq_driver *driver_data) { -void *cpu = (void *)(long )smp_processor_id (); -cpu_callback (&cpu_nfb,CPU_ONLINE , cpu);Why is this being removed without replacement?
I think they are redundant here.
If we go and check the hypercall code path (the bottom of set_px_pminfo()), the cpufreq_add_cpu() is called there (inside cpufreq_cpu_init()), too. Why do we need to initialize this CPU twice?
Best,
Wei
Quoted 31 lines
Quoted 16 lines
xen/drivers/cpufreq/cpufreq.c +11
-1+if (!driver_data || !driver_data->init + || !driver_data->verify || !driver_data->exit + || (!driver_data->target == !driver_data->setpolicy)) +return -EINVAL ; + +if (cpufreq_driver) +return -EBUSY ; + + cpufreq_driver = driver_data; +register_cpu_notifier (&cpu_nfb); +return 0 ; } -presmp_initcall (cpufreq_presmp_init);xen/drivers/cpufreq/cpufreq.c static struct notifier_block cpu_nfb = { · line 660
Quoted 10 lines
xen/drivers/cpufreq/cpufreq.c +10
-0+int cpufreq_unregister_driver (struct cpufreq_driver *driver) { +if (!cpufreq_driver || (driver != cpufreq_driver)) +return -EINVAL ; + + cpufreq_driver =NULL ; + +unregister_cpu_notifier (&cpu_nfb); + +return 0 ; +}This function is dead (and perhaps just like
unregister_cpu_notifier()not even needed without loadable modules).Jan
On 26/05/2015 21:17, Jan Beulich wrote
Quoted 7 lines
Review
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
(quoted diff) +3
-0+extern int cpufreq_register_driver(struct cpufreq_driver +*driver_data); extern int cpufreq_unregister_driver(struct +cpufreq_driver *driver);Oh, btw, please also get rid of "extern" on function declarations, unless in a particular header it is consistently being used.
Ok. The cpufreq.h file uses "extern", so I will keep using it.
Best,
Wei
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 29.05.15 at 04:47, <[email protected]> wrote:
On 26/05/2015 21:06, Jan Beulich wrote
Quoted 14 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:50, <[email protected]> wrote:
Register/unregister the CPU hotplug notifier when the driver is registered, and move the driver register/unregister function to the
cpufreq.c.Without saying why I'm afraid I don't even see much reason to review this in any detail.
Quoted 6 lines
xen/drivers/cpufreq/cpufreq.c +0
-0@@ -630,12 +630,31 @@ static struct notifier_block cpu_nfb = { .notifier_call = cpu_callback };Quoted 7 lines
xen/drivers/cpufreq/cpufreq.c static struct notifier_block cpu_nfb = { · line 636
Quoted 5 lines
xen/drivers/cpufreq/cpufreq.c +1
-3-static int __init cpufreq_presmp_init (void ) +int cpufreq_register_driver (struct cpufreq_driver *driver_data) { -void *cpu = (void *)(long )smp_processor_id (); -cpu_callback (&cpu_nfb,CPU_ONLINE , cpu);Why is this being removed without replacement?
Quoted 4 lines
I think they are redundant here.
If we go and check the hypercall code path (the bottom ofset_px_pminfo()), thecpufreq_add_cpu()is called there (insidecpufreq_cpu_init()), too. Why do we need to initialize this CPU twice?
If this is indeed being done twice, removing it is fine. But in a separate patch with a proper description.
Jan