All of lore.kernel.org
 help / color / mirror / Atom feed
* How to initialize the new attributes in process control block.
@ 2016-05-14  9:16 Youcun Liu
  2016-05-15 17:38 ` masoud hematpour
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Youcun Liu @ 2016-05-14  9:16 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160514/41f06d89/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* How to initialize the new attributes in process control block.
  2016-05-14  9:16 How to initialize the new attributes in process control block Youcun Liu
@ 2016-05-15 17:38 ` masoud hematpour
  2016-05-15 17:40 ` Mulyadi Santosa
  2016-05-16  8:44 ` Youcun Liu
  2 siblings, 0 replies; 5+ messages in thread
From: masoud hematpour @ 2016-05-15 17:38 UTC (permalink / raw)
  To: kernelnewbies

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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160515/31836487/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* How to initialize the new attributes in process control block.
  2016-05-14  9:16 How to initialize the new attributes in process control block Youcun Liu
  2016-05-15 17:38 ` masoud hematpour
@ 2016-05-15 17:40 ` Mulyadi Santosa
  2016-05-16  8:44 ` Youcun Liu
  2 siblings, 0 replies; 5+ messages in thread
From: Mulyadi Santosa @ 2016-05-15 17:40 UTC (permalink / raw)
  To: 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160516/cf48c12b/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* How to initialize the new attributes in process control block.
  2016-05-14  9:16 How to initialize the new attributes in process control block Youcun Liu
  2016-05-15 17:38 ` masoud hematpour
  2016-05-15 17:40 ` Mulyadi Santosa
@ 2016-05-16  8:44 ` Youcun Liu
  2016-05-16 17:04   ` Valdis.Kletnieks at vt.edu
  2 siblings, 1 reply; 5+ messages in thread
From: Youcun Liu @ 2016-05-16  8:44 UTC (permalink / raw)
  To: kernelnewbies

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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160516/f7cedde0/attachment.html 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* How to initialize the new attributes in process control block.
  2016-05-16  8:44 ` Youcun Liu
@ 2016-05-16 17:04   ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 5+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2016-05-16 17:04 UTC (permalink / raw)
  To: kernelnewbies

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).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160516/e7a1a577/attachment.bin 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-05-16 17:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-14  9:16 How to initialize the new attributes in process control block Youcun Liu
2016-05-15 17:38 ` masoud hematpour
2016-05-15 17:40 ` Mulyadi Santosa
2016-05-16  8:44 ` Youcun Liu
2016-05-16 17:04   ` Valdis.Kletnieks at vt.edu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.