lkml.org 
[lkml]   [2016]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] introduce for_each_process_thread_{break,continue}() helpers
On Mon, Jul 25, 2016 at 06:23:48PM +0200, Oleg Nesterov wrote:
> +void for_each_process_thread_continue(struct task_struct **p_leader,
> + struct task_struct **p_thread)
> +{
> + struct task_struct *leader = *p_leader, *thread = *p_thread;
> + struct task_struct *prev, *next;
> + u64 start_time;
> +
> + if (pid_alive(thread)) {
> + /* mt exec could change the leader */
> + *p_leader = thread->group_leader;
> + } else if (pid_alive(leader)) {
> + start_time = thread->start_time;
> + prev = leader;
> +
> + for_each_thread(leader, next) {
> + if (next->start_time > start_time)
> + break;
> + prev = next;
> + }

This,

> + *p_thread = prev;
> + } else {
> + start_time = leader->start_time;
> + prev = &init_task;
> +
> + for_each_process(next) {
> + if (next->start_time > start_time)
> + break;
> + prev = next;
> + }

and this, could be 'SPEND_TOO_MUCH_TIME' all by themselves.

Unlikely though, nor do I really have a better suggestion :/

> +
> + *p_leader = prev;
> + /* a new thread can come after that, but this is fine */
> + *p_thread = list_last_entry(&prev->signal->thread_head,
> + struct task_struct,
> + thread_node);
> + }
> +
> + put_task_struct(leader);
> + put_task_struct(thread);
> +}

\
 
 \ /
  Last update: 2016-08-02 18:41    [W:0.099 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site