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:

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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -