linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP
@ 2021-02-21 13:43 shuo.a.liu
  2021-02-21 13:43 ` [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU shuo.a.liu
  2021-02-23 15:10 ` [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP Qais Yousef
  0 siblings, 2 replies; 5+ messages in thread
From: shuo.a.liu @ 2021-02-21 13:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, linux-next, Shuo Liu, Randy Dunlap,
	Stephen Rothwell, Thomas Gleixner, Qais Yousef

From: Shuo Liu <shuo.a.liu@intel.com>

279dcf693ac7 ("virt: acrn: Introduce an interface for Service VM to
control vCPU") introduced {add,remove}_cpu() usage and it hit below
error with !CONFIG_SMP:

../drivers/virt/acrn/hsm.c: In function ‘remove_cpu_store’:
../drivers/virt/acrn/hsm.c:389:3: error: implicit declaration of function ‘remove_cpu’; [-Werror=implicit-function-declaration]
   remove_cpu(cpu);

../drivers/virt/acrn/hsm.c:402:2: error: implicit declaration of function ‘add_cpu’; [-Werror=implicit-function-declaration]
   add_cpu(cpu);

Add add_cpu() function prototypes with !CONFIG_SMP and remove_cpu() with
!CONFIG_HOTPLUG_CPU for such usage.

Fixes: 279dcf693ac7 ("virt: acrn: Introduce an interface for Service VM to control vCPU")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Qais Yousef <qais.yousef@arm.com>
---
 include/linux/cpu.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 3aaa0687e8df..94a578a96202 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -108,6 +108,8 @@ static inline void cpu_maps_update_done(void)
 {
 }
 
+static inline int add_cpu(unsigned int cpu) { return 0;}
+
 #endif /* CONFIG_SMP */
 extern struct bus_type cpu_subsys;
 
@@ -137,6 +139,7 @@ static inline int  cpus_read_trylock(void) { return true; }
 static inline void lockdep_assert_cpus_held(void) { }
 static inline void cpu_hotplug_disable(void) { }
 static inline void cpu_hotplug_enable(void) { }
+static inline int remove_cpu(unsigned int cpu) { return -EPERM; }
 static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
 #endif	/* !CONFIG_HOTPLUG_CPU */
 

base-commit: abaf6f60176f1ae9d946d63e4db63164600b7b1a
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU
  2021-02-21 13:43 [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP shuo.a.liu
@ 2021-02-21 13:43 ` shuo.a.liu
  2021-02-23 15:25   ` Qais Yousef
  2021-02-23 15:10 ` [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP Qais Yousef
  1 sibling, 1 reply; 5+ messages in thread
From: shuo.a.liu @ 2021-02-21 13:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, linux-next, Shuo Liu, Randy Dunlap,
	Stephen Rothwell, Thomas Gleixner, Qais Yousef

From: Shuo Liu <shuo.a.liu@intel.com>

Without cpu hotplug support, vCPU cannot be removed from a Service VM.
Don't expose remove_cpu sysfs when CONFIG_HOTPLUG_CPU disabled.

Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Qais Yousef <qais.yousef@arm.com>
---
 drivers/virt/acrn/hsm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
index 1f6b7c54a1a4..6996ea6219e5 100644
--- a/drivers/virt/acrn/hsm.c
+++ b/drivers/virt/acrn/hsm.c
@@ -404,6 +404,14 @@ static ssize_t remove_cpu_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(remove_cpu);
 
+static umode_t acrn_attr_visible(struct kobject *kobj, struct attribute *a, int n)
+{
+       if (a == &dev_attr_remove_cpu.attr)
+               return IS_ENABLED(CONFIG_HOTPLUG_CPU) ? a->mode : 0;
+
+       return a->mode;
+}
+
 static struct attribute *acrn_attrs[] = {
 	&dev_attr_remove_cpu.attr,
 	NULL
@@ -411,6 +419,7 @@ static struct attribute *acrn_attrs[] = {
 
 static struct attribute_group acrn_attr_group = {
 	.attrs = acrn_attrs,
+	.is_visible = acrn_attr_visible,
 };
 
 static const struct attribute_group *acrn_attr_groups[] = {
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP
  2021-02-21 13:43 [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP shuo.a.liu
  2021-02-21 13:43 ` [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU shuo.a.liu
@ 2021-02-23 15:10 ` Qais Yousef
  1 sibling, 0 replies; 5+ messages in thread
From: Qais Yousef @ 2021-02-23 15:10 UTC (permalink / raw)
  To: shuo.a.liu
  Cc: Greg Kroah-Hartman, linux-kernel, linux-next, Randy Dunlap,
	Stephen Rothwell, Thomas Gleixner

On 02/21/21 21:43, shuo.a.liu@intel.com wrote:
> From: Shuo Liu <shuo.a.liu@intel.com>
> 
> 279dcf693ac7 ("virt: acrn: Introduce an interface for Service VM to
> control vCPU") introduced {add,remove}_cpu() usage and it hit below
> error with !CONFIG_SMP:
> 
> ../drivers/virt/acrn/hsm.c: In function ‘remove_cpu_store’:
> ../drivers/virt/acrn/hsm.c:389:3: error: implicit declaration of function ‘remove_cpu’; [-Werror=implicit-function-declaration]
>    remove_cpu(cpu);
> 
> ../drivers/virt/acrn/hsm.c:402:2: error: implicit declaration of function ‘add_cpu’; [-Werror=implicit-function-declaration]
>    add_cpu(cpu);
> 
> Add add_cpu() function prototypes with !CONFIG_SMP and remove_cpu() with
> !CONFIG_HOTPLUG_CPU for such usage.
> 
> Fixes: 279dcf693ac7 ("virt: acrn: Introduce an interface for Service VM to control vCPU")
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---

Reviewed-by: Qais Yousef <qais.yousef@arm.com>

Thanks!

--
Qais Yousef

>  include/linux/cpu.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/cpu.h b/include/linux/cpu.h
> index 3aaa0687e8df..94a578a96202 100644
> --- a/include/linux/cpu.h
> +++ b/include/linux/cpu.h
> @@ -108,6 +108,8 @@ static inline void cpu_maps_update_done(void)
>  {
>  }
>  
> +static inline int add_cpu(unsigned int cpu) { return 0;}
> +
>  #endif /* CONFIG_SMP */
>  extern struct bus_type cpu_subsys;
>  
> @@ -137,6 +139,7 @@ static inline int  cpus_read_trylock(void) { return true; }
>  static inline void lockdep_assert_cpus_held(void) { }
>  static inline void cpu_hotplug_disable(void) { }
>  static inline void cpu_hotplug_enable(void) { }
> +static inline int remove_cpu(unsigned int cpu) { return -EPERM; }
>  static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
>  #endif	/* !CONFIG_HOTPLUG_CPU */
>  
> 
> base-commit: abaf6f60176f1ae9d946d63e4db63164600b7b1a
> -- 
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU
  2021-02-21 13:43 ` [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU shuo.a.liu
@ 2021-02-23 15:25   ` Qais Yousef
  2021-02-24  1:11     ` Shuo A Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Qais Yousef @ 2021-02-23 15:25 UTC (permalink / raw)
  To: shuo.a.liu
  Cc: Greg Kroah-Hartman, linux-kernel, linux-next, Randy Dunlap,
	Stephen Rothwell, Thomas Gleixner

On 02/21/21 21:43, shuo.a.liu@intel.com wrote:
> From: Shuo Liu <shuo.a.liu@intel.com>
> 
> Without cpu hotplug support, vCPU cannot be removed from a Service VM.
> Don't expose remove_cpu sysfs when CONFIG_HOTPLUG_CPU disabled.
> 
> Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Qais Yousef <qais.yousef@arm.com>
> ---
>  drivers/virt/acrn/hsm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
> index 1f6b7c54a1a4..6996ea6219e5 100644
> --- a/drivers/virt/acrn/hsm.c
> +++ b/drivers/virt/acrn/hsm.c
> @@ -404,6 +404,14 @@ static ssize_t remove_cpu_store(struct device *dev,
>  }
>  static DEVICE_ATTR_WO(remove_cpu);
>  
> +static umode_t acrn_attr_visible(struct kobject *kobj, struct attribute *a, int n)
> +{
> +       if (a == &dev_attr_remove_cpu.attr)
> +               return IS_ENABLED(CONFIG_HOTPLUG_CPU) ? a->mode : 0;
> +
> +       return a->mode;
> +}
> +

I can't find this code in Linus' master. But this looks fine from my narrow
PoV. Protecting the attribute with ifdef CONFIG_HOTPLUG_CPU is easier to read
for me, but this doesn't mean this approach is not fine.

Thanks

--
Qais Yousef

>  static struct attribute *acrn_attrs[] = {
>  	&dev_attr_remove_cpu.attr,
>  	NULL
> @@ -411,6 +419,7 @@ static struct attribute *acrn_attrs[] = {
>  
>  static struct attribute_group acrn_attr_group = {
>  	.attrs = acrn_attrs,
> +	.is_visible = acrn_attr_visible,
>  };
>  
>  static const struct attribute_group *acrn_attr_groups[] = {
> -- 
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU
  2021-02-23 15:25   ` Qais Yousef
@ 2021-02-24  1:11     ` Shuo A Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Shuo A Liu @ 2021-02-24  1:11 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Greg Kroah-Hartman, linux-kernel, linux-next, Randy Dunlap,
	Stephen Rothwell, Thomas Gleixner

Hi,

On Tue 23.Feb'21 at 15:25:30 +0000, Qais Yousef wrote:
>On 02/21/21 21:43, shuo.a.liu@intel.com wrote:
>> From: Shuo Liu <shuo.a.liu@intel.com>
>>
>> Without cpu hotplug support, vCPU cannot be removed from a Service VM.
>> Don't expose remove_cpu sysfs when CONFIG_HOTPLUG_CPU disabled.
>>
>> Signed-off-by: Shuo Liu <shuo.a.liu@intel.com>
>> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
>> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Qais Yousef <qais.yousef@arm.com>
>> ---
>>  drivers/virt/acrn/hsm.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/virt/acrn/hsm.c b/drivers/virt/acrn/hsm.c
>> index 1f6b7c54a1a4..6996ea6219e5 100644
>> --- a/drivers/virt/acrn/hsm.c
>> +++ b/drivers/virt/acrn/hsm.c
>> @@ -404,6 +404,14 @@ static ssize_t remove_cpu_store(struct device *dev,
>>  }
>>  static DEVICE_ATTR_WO(remove_cpu);
>>
>> +static umode_t acrn_attr_visible(struct kobject *kobj, struct attribute *a, int n)
>> +{
>> +       if (a == &dev_attr_remove_cpu.attr)
>> +               return IS_ENABLED(CONFIG_HOTPLUG_CPU) ? a->mode : 0;
>> +
>> +       return a->mode;
>> +}
>> +
>
>I can't find this code in Linus' master. But this looks fine from my narrow

Now, the code is still in linux-next tree only.

>PoV. Protecting the attribute with ifdef CONFIG_HOTPLUG_CPU is easier to read
>for me, but this doesn't mean this approach is not fine.

Just FYI, Greg prefers this solution.
https://lore.kernel.org/lkml/20210212045724.77846-1-shuo.a.liu@intel.com/

Thanks
shuo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-24  1:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-21 13:43 [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP shuo.a.liu
2021-02-21 13:43 ` [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU shuo.a.liu
2021-02-23 15:25   ` Qais Yousef
2021-02-24  1:11     ` Shuo A Liu
2021-02-23 15:10 ` [PATCH RESEND v2 1/2] cpu/hotplug: Fix build error of using {add,remove}_cpu() with !CONFIG_SMP Qais Yousef

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).