2021-02-21 13:47:28

by Shuo Liu

[permalink] [raw]
Subject: [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU

From: Shuo Liu <[email protected]>

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 <[email protected]>
Acked-by: Randy Dunlap <[email protected]> # build-tested
Cc: Stephen Rothwell <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Qais Yousef <[email protected]>
---
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


2021-02-23 15:28:06

by Qais Yousef

[permalink] [raw]
Subject: Re: [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU

On 02/21/21 21:43, [email protected] wrote:
> From: Shuo Liu <[email protected]>
>
> 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 <[email protected]>
> Acked-by: Randy Dunlap <[email protected]> # build-tested
> Cc: Stephen Rothwell <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Qais Yousef <[email protected]>
> ---
> 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
>

2021-02-24 06:20:04

by Shuo Liu

[permalink] [raw]
Subject: Re: [PATCH RESEND v2 2/2] virt: acrn: Make remove_cpu sysfs invisible with !CONFIG_HOTPLUG_CPU

Hi,

On Tue 23.Feb'21 at 15:25:30 +0000, Qais Yousef wrote:
>On 02/21/21 21:43, [email protected] wrote:
>> From: Shuo Liu <[email protected]>
>>
>> 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 <[email protected]>
>> Acked-by: Randy Dunlap <[email protected]> # build-tested
>> Cc: Stephen Rothwell <[email protected]>
>> Cc: Thomas Gleixner <[email protected]>
>> Cc: Greg Kroah-Hartman <[email protected]>
>> Cc: Qais Yousef <[email protected]>
>> ---
>> 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/[email protected]/

Thanks
shuo