1

I am working on an embedded Linux system, which is using kernel-5.10.24.
As the system resource is limited, so I want to minimize the CPU/memory/storage usage.
From ps -ax I found 2 kernel threads as follows,

   14 root      0:00 [cpuhp/0]
   15 root      0:00 [cpuhp/1]

I think they are used for CPU hotpluging, and there is NO CPU hotpluging use case in this system, so I want to disable the feature and not create these 2 kernel threads.
I tried to disable this configuration by force (Removing select SYS_SUPPORTS_HOTPLUG_CPU from the arch/ARM/Kconfig and others).

But after deployed the new kernel, these 2 kernel threads are still there.
By checking the codes, it seemed that these 2 threads are created regardless of CONFIG_HOTPLUG_CPU and CONFIG_SYS_SUPPORTS_HOTPLUG_CPU, which means when SMP is configured, these 2 threads are ALWAYS there!

So I am not sure if there is a way to disable creation of these 2 kernel threads. If no, I have to live with them, assuming they will NOT take too much CPU and memory for running.

Updated with kernel menuconfig based on dhanushka's comment

                                                                                                                                         
   Symbol: HOTPLUG_CPU [=y]                                                                                                                

   Type  : bool                                                                                                                            

   Defined at arch/mips/Kconfig:2942                                                                                                       
     Prompt: Support for hot-pluggable CPUs                                                                                                
     Depends on: SMP [=y] && SYS_SUPPORTS_HOTPLUG_CPU [=y]                                                                                 
     Location:                                                                                                                             
       -> Kernel type                                                                                                                      
   (2)   -> Multi-Processing support (SMP [=y])                                                                                            
   Selected by [y]:                                                                                                                        
     - PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]

The same as dhanushka's comment.
I will try to disable it and update this question.
And as I said, the cpuhp0/1 seemed not be able to be disabled.

1 Answer 1

1

Not really an answer, but wanted to add something. You must have tried these already, but see below just in case you missed.

If you have top(1), you can check their resource usage. Or you can use /proc/[pid]/status etc. to check them. Either way, you'd see they aren't resource hungry, and mostly in sleeping (S) state.

You'd also see from kernel documentation and configurations that it is related to power management (SMP suspend/resume), so consider your power management requirements and how disabling CPU hotplug can affect them.

Kernel configuration:

Kernel Documentation says CONFIG_HOTPLUG_CPU needs to be enabled for CPU hotplug to work.

  • Did you do the disabling from menuconfig?
  • If not, did you check menuconfig to see if it has been disabled after your changes?

If you try disabling it from menuconfig, you'll first have to disable a series of other configs, and be able to build the kernel successfully after disabling them. For example, this is what menuconfig shows on my platform:

  CONFIG_HOTPLUG_CPU:
  
  Say Y here to experiment with turning CPUs off and on.  CPUs
  can be controlled through /sys/devices/system/cpu.
  
  Symbol: HOTPLUG_CPU [=y]
  Type  : bool
  Defined at arch/arm64/Kconfig:985
    Prompt: Support for hot-pluggable CPUs
    Location:
      -> Kernel Features
  Selects: GENERIC_IRQ_MIGRATION [=y]
  Selected by [y]:
    - PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]

So, I simply cannot disable it from menuconfig unless I address the

  Selected by [y]:
    - PM_SLEEP_SMP [=y] && SMP [=y] && (ARCH_SUSPEND_POSSIBLE [=y] || ARCH_HIBERNATION_POSSIBLE [=y]) && PM_SLEEP [=y]

that enables it.

You'll have similar constraints. You can try addressing them and finally disable CONFIG_HOTPLUG_CPU, but I doubt you'll be able to build the kernel after that because some drivers don't handle the dependencies well (but things worked for you it seems).

1
  • You are right on disabling CONFIG_CPU_HOTPLUG. I re-configured the kernel by disabling PM feature, then I can disable CONFIG_CPU_HOTPLUG. I will vote for your answer as correct. Now it is also true that per-cpu kernel thread cpuhp cannot be disabled by disabling CONFIG_CPU_HOTPLUG, they are always there, I have to live with them.
    – wangt13
    Apr 30, 2023 at 2:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .