All of lore.kernel.org
 help / color / mirror / Atom feed
* /sys/devices/system/cpu/possible can be changed during runtime?
@ 2021-03-15  5:35 Junyeong Jeong
  2021-03-17  8:31 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Junyeong Jeong @ 2021-03-15  5:35 UTC (permalink / raw)
  To: kernel-janitors

Hello everyone :D

I wonder that possible-CPU-mask(/sys/devices/system/cpu/possible) can be
changed during runtime. I read that it is fixed at boot time, but I am
not sure that it is really immutable even if some cgroup or
virtualization magic is used.

I am referring to /sys/devices/system/cpu/possible file to get to know
the number of per-cpu areas. In userspace, I call `bpf_lookup_elem()` to
get values at index from BPF array map of which type is
BPF_MAP_TYPE_PERCPU_ARRAY.  And the length of the gained values is the
same with the number of per-cpu areas and in turn it is the same with
the number of possible CPUs.

I am anxious that this varies from time to time under some
circumstances. So I checked some cgroup and virtualization use-cases
which did not affect the possible-CPU-mask.

$ docker run --cpuset-cpus=0-3 -it ubuntu:20.10 bash  # cgroup cpuset
$ virsh setvcpus --current ubuntu20.10 5  # hotplug cpu while guest os is running..

But while conducting this I realized that it's not possible to prove the
immutability of possible-CPU-mask using inductive method.

Can anyone explain that it will not happen that possible-CPU-mask
changes after boot-time even with cgroup magic or some tricks from
outside of hypervisors?

Thanks,

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

* Re: /sys/devices/system/cpu/possible can be changed during runtime?
  2021-03-15  5:35 /sys/devices/system/cpu/possible can be changed during runtime? Junyeong Jeong
@ 2021-03-17  8:31 ` Dan Carpenter
  2021-03-17 13:02   ` Junyeong Jeong
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-03-17  8:31 UTC (permalink / raw)
  To: Junyeong Jeong; +Cc: kernel-janitors

On Mon, Mar 15, 2021 at 02:35:06PM +0900, Junyeong Jeong wrote:
> Hello everyone :D
> 
> I wonder that possible-CPU-mask(/sys/devices/system/cpu/possible) can be
> changed during runtime. I read that it is fixed at boot time, but I am
> not sure that it is really immutable even if some cgroup or
> virtualization magic is used.
> 
> I am referring to /sys/devices/system/cpu/possible file to get to know
> the number of per-cpu areas. In userspace, I call `bpf_lookup_elem()` to
> get values at index from BPF array map of which type is
> BPF_MAP_TYPE_PERCPU_ARRAY.  And the length of the gained values is the
> same with the number of per-cpu areas and in turn it is the same with
> the number of possible CPUs.
> 
> I am anxious that this varies from time to time under some
> circumstances. So I checked some cgroup and virtualization use-cases
> which did not affect the possible-CPU-mask.
> 
> $ docker run --cpuset-cpus=0-3 -it ubuntu:20.10 bash  # cgroup cpuset
> $ virsh setvcpus --current ubuntu20.10 5  # hotplug cpu while guest os is running..
> 
> But while conducting this I realized that it's not possible to prove the
> immutability of possible-CPU-mask using inductive method.
> 
> Can anyone explain that it will not happen that possible-CPU-mask
> changes after boot-time even with cgroup magic or some tricks from
> outside of hypervisors?
> 
> Thanks,

Kernel janitors is mostly about fixing and updating kernel API, not
discussing how the kernel works.

You can't write to that sysfs file.
-r--r--r-- 1 root root 4096 Mar 17 11:28 /sys/devices/system/cpu/possible
But we do allow people to add and remove CPUs while the system is
running (CPU hotplug).  The number of CPUs is not necessarily fixed at
boot time.  It's not immutable.

I'm not sure if this helps?

regards,
dan carpenter

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

* Re: /sys/devices/system/cpu/possible can be changed during runtime?
  2021-03-17  8:31 ` Dan Carpenter
@ 2021-03-17 13:02   ` Junyeong Jeong
  0 siblings, 0 replies; 3+ messages in thread
From: Junyeong Jeong @ 2021-03-17 13:02 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kernel-janitors


Thank you Carpenter for answering my question.

Oops.. I did not know that kernel-janitors is not right place for asking
general kernel related esoteric topics. Then, what is proper mailing
list? Can you recommend me some places to ask this question?

You mentioned CPU hotplugging. That's a good point. But When I tested
hotplugging CPU using QMEU/KVM, I only observed that
/sys/devices/system/cpu/{online,offline} changed, while
/sys/devices/system/cpu/possible did not change.

regards,
    Junyeong Jeong

Dan Carpenter <dan.carpenter@oracle.com> writes:

> On Mon, Mar 15, 2021 at 02:35:06PM +0900, Junyeong Jeong wrote:
>> Hello everyone :D
>> 
>> I wonder that possible-CPU-mask(/sys/devices/system/cpu/possible) can be
>> changed during runtime. I read that it is fixed at boot time, but I am
>> not sure that it is really immutable even if some cgroup or
>> virtualization magic is used.
>> 
>> I am referring to /sys/devices/system/cpu/possible file to get to know
>> the number of per-cpu areas. In userspace, I call `bpf_lookup_elem()` to
>> get values at index from BPF array map of which type is
>> BPF_MAP_TYPE_PERCPU_ARRAY.  And the length of the gained values is the
>> same with the number of per-cpu areas and in turn it is the same with
>> the number of possible CPUs.
>> 
>> I am anxious that this varies from time to time under some
>> circumstances. So I checked some cgroup and virtualization use-cases
>> which did not affect the possible-CPU-mask.
>> 
>> $ docker run --cpuset-cpus=0-3 -it ubuntu:20.10 bash  # cgroup cpuset
>> $ virsh setvcpus --current ubuntu20.10 5  # hotplug cpu while guest os is running..
>> 
>> But while conducting this I realized that it's not possible to prove the
>> immutability of possible-CPU-mask using inductive method.
>> 
>> Can anyone explain that it will not happen that possible-CPU-mask
>> changes after boot-time even with cgroup magic or some tricks from
>> outside of hypervisors?
>> 
>> Thanks,
>
> Kernel janitors is mostly about fixing and updating kernel API, not
> discussing how the kernel works.
>
> You can't write to that sysfs file.
> -r--r--r-- 1 root root 4096 Mar 17 11:28 /sys/devices/system/cpu/possible
> But we do allow people to add and remove CPUs while the system is
> running (CPU hotplug).  The number of CPUs is not necessarily fixed at
> boot time.  It's not immutable.
>
> I'm not sure if this helps?
>
> regards,
> dan carpenter


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

end of thread, other threads:[~2021-03-17 13:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15  5:35 /sys/devices/system/cpu/possible can be changed during runtime? Junyeong Jeong
2021-03-17  8:31 ` Dan Carpenter
2021-03-17 13:02   ` Junyeong Jeong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.