linux - Implementing a system call for CPU hotplug on RPI3/ModelB -
my goal implement system call in linux kernel enables/disables cpu core.
first, implemented system call disbales cpu3 in 4-core system.
the system call code follows:
#include <linux/kernel.h> #include <linux/slab.h> #include <asm/uaccess.h> #include <asm/unistd.h> #include <linux/cpumask.h> asmlinkage long sys_new_syscall(void) { unsigned int cpu3 = 3; set_cpu_online (cpu3, false) ; /* clears cpu in cpumask */ printk ("cpu%u offline\n", cpu3); return 0; }
the system call registered correctly in kernel , enabled 'cpu hotplug' feature during kernel configuration ( see picture )
kernel configuration:
the kernel build . when check system call using test.c :
#include <stdio.h> #include <linux/kernel.h> #include <sys/syscall.h> #include <unistd.h> long new_syscall(void) { return syscall(394); } int main(int argc, char *argv[]) { long int = new_syscall(); printf("system call returned %ld\n", a); return 0; }
the os frezzes ! doing wrong ?
why want implement dedicated syscall? standard way of offlining cpus through writes sysfs. in extremely unlikely case there valid reason create dedicated syscall have check how offlining works under hood , repeat that.
set_cpu_online (cpu3, false) ; /* clears cpu in cpumask */
your own comment suggests simplistic. instance if thread executing running on said cpu? threads queued on it?
and on
Comments
Post a Comment