I am writing a loadable kernel module for Linux. And I need to store some data for each task in the Linux kernel (this data will be used in the scheduler callback).
I know that I can modify the struct task_struct and insert my own fields. But since I am ready to write a relatively clean kernel module, I cannot change any code in the source Linux source tree.
It is also possible to save some mapping from struct task_struct to my data in a hash table. But that seems to be too hard.
I read the answer in Enter local data in the Linux kernel module . He mentioned the use of private_data in a struct file . But in order to get a struct file , each thread requires each thread. And there is no way to query data for each task using struct task_struct . (Since I need to use the data in the scheduler callback)
My question is: is there a simple and clean way that allows me to register the data structure for each task in the Linux kernel without changing the struct task_struct ?
Many thanks!
c linux data-structures linux-kernel
Naruil
source share