How to initialize the new attributes in process control block.
Dear all, I am now working on building my own linux kernel and I want to add a new attribute into the process control block. Then I will feed some data to the new attribute from a user application. Finally I want to use the date to improve the some original kernel algorithm(e.g process schduling). I tried to initialize the new attribute directly in the 'task_struct', obviously, it failed. So I decide to initialize the new attribute at the very beginning, but I do not know how. Besides, I have trouble in finding out which function can help me feed data to the new attribute. Could you please give me some suggestions and help? Thanks a lot. Best regards, Youcun Liu
Hi, It is interesting. I have the same problem. Thank you, On Sat, May 14, 2016 at 11:16 AM, Youcun Liu <liuyoucun1993@gmail.com> wrote:
Dear all,
I am now working on building my own linux kernel and I want to add a new attribute into the process control block. Then I will feed some data to the new attribute from a user application. Finally I want to use the date to improve the some original kernel algorithm(e.g process schduling).
I tried to initialize the new attribute directly in the 'task_struct', obviously, it failed. So I decide to initialize the new attribute at the very beginning, but I do not know how. Besides, I have trouble in finding out which function can help me feed data to the new attribute.
Could you please give me some suggestions and help? Thanks a lot.
Best regards, Youcun Liu
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Sat, May 14, 2016 at 4:16 PM, Youcun Liu <liuyoucun1993@gmail.com> wrote:
Dear all,
I am now working on building my own linux kernel and I want to add a new attribute into the process control block. Then I will feed some data to the new attribute from a user application. Finally I want to use the date to improve the some original kernel algorithm(e.g process schduling).
I tried to initialize the new attribute directly in the 'task_struct', obviously, it failed. So I decide to initialize the new attribute at the very beginning, but I do not know how. Besides, I have trouble in finding out which function can help me feed data to the new attribute.
Could you please give me some suggestions and help? Thanks a lot.
Best regards, Youcun Liu
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi... How did you exactly initialize PCB or task_struct? Could you elaborate? IIRC, sometimes variables under task_struct is accessed using offset, so if you insert new variable in the middle, there is a chance you messed it up. There might be other constraints, though. CMIIW -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Hi. Thanks for your time and last weekend I raised a problem, but it maybe not so detail, So I want to detail my problem. My problem is that I insert a new variable into struct sched_entity <http://lxr.free-electrons.com/source/include/linux/ident?i=sched_entity>, like that struct sched_entity { struct load_weight load; /* for load-balancing */ struct rb_node run_node; struct list_head group_node; unsigned int on_rq; u64 exec_start; u64 sum_exec_runtime; u64 vruntime; u64 prev_sum_exec_runtime; u64 cache_miss_rate; // the new variable I insert u64 nr_migrations; ..... ..... } for the new comming process I want to set the new variable as 1. Then after the process executed, I calculate the cache miss rate and I feed the data into the variable(update the variable), then use the data to modify some other parameter(e.g vruntime and slice) in the kernel. But I do not how to initialize the new variable(or whether I need to initialize the new variable) for the new comming process(I know that the child process would copy PCB from its parent process, but at the very beginning, the init process has to initialize the variable.) Besides, I also have trouble in finding out how to feed data into the new variable from user level application. Thanks a lot. Best Regards. 2016-05-14 11:16 GMT+02:00 Youcun Liu <liuyoucun1993@gmail.com>:
Dear all,
I am now working on building my own linux kernel and I want to add a new attribute into the process control block. Then I will feed some data to the new attribute from a user application. Finally I want to use the date to improve the some original kernel algorithm(e.g process schduling).
I tried to initialize the new attribute directly in the 'task_struct', obviously, it failed. So I decide to initialize the new attribute at the very beginning, but I do not know how. Besides, I have trouble in finding out which function can help me feed data to the new attribute.
Could you please give me some suggestions and help? Thanks a lot.
Best regards, Youcun Liu
On Mon, 16 May 2016 10:44:56 +0200, Youcun Liu said:
u64 cache_miss_rate; // the new variable I insert
Besides, I also have trouble in finding out how to feed data into the new variable from user level application.
Three comments: 1) cache_miss_rate is probably a poor thing to fold into scheduling, because it depends a large part on how much the *previous* thing to run on that core left the cache. If you run, and then a CPU-bound process that only touches 16K of your 8M L2 cache runs, when you reschedule, your cache miss rate will be very low. If however that CPU bound job is walking an array and dirties the entire 8M, your cache miss rate will be astronomical until you've repopulated the cache... 2) Trying to update cache miss rate in real time from *userspace* only makes the problem worse, because your own userspace activity ends up impacting the cache warmth of the process you're trying to track... 2a) Oh, and doing so is inherently full of race conditions.... 3) Even if you get the number in there, what exactly do you propose to do with it? How would you modify the scheduling algorithm? Hint: If you think that the scheduler should be including some new piece of information, you should probably stop and ask yourself "Why, with close to 2 decades of improvement by some very smart people, is it not doing so already?"... There's a *very* good chance it's been considered and discarded (possibly multiple times).
participants (4)
-
masoud hematpour -
Mulyadi Santosa -
Valdis.Kletnieks@vt.edu -
Youcun Liu