Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1454878 > unrolled thread
| Started by | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| First post | 2016-08-02 18:10 +0200 |
| Last post | 2016-08-08 14:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 1/3] introduce for_each_process_thread_{break,continue}() helpers Peter Zijlstra <peterz@infradead.org> - 2016-08-02 18:10 +0200
Re: [PATCH 1/3] introduce for_each_process_thread_{break,continue}() helpers Oleg Nesterov <oleg@redhat.com> - 2016-08-03 22:40 +0200
Re: [PATCH 1/3] introduce for_each_process_thread_{break,continue}() helpers Peter Zijlstra <peterz@infradead.org> - 2016-08-08 14:30 +0200
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-08-02 18:10 +0200 |
| Subject | Re: [PATCH 1/3] introduce for_each_process_thread_{break,continue}() helpers |
| Message-ID | <s1Kqu-6Lp-51@gated-at.bofh.it> |
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);
> +}
[toc] | [next] | [standalone]
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Date | 2016-08-03 22:40 +0200 |
| Message-ID | <s2b7k-7uo-5@gated-at.bofh.it> |
| In reply to | #1454878 |
Thanks for review and sorry for delay, I am travelling till the end of this week.
On 08/02, Peter Zijlstra wrote:
>
> 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 :/
Yeees, I don't think this can actually hurt "in practice", but I agree, compared
to rcu_lock_break() this is only bounded by PID_MAX_DEFAULT in theory.
Will you agree if I just add the "int max_scan" argument and make it return a boolean
for the start? The caller will need to abort the for_each_process_thread() loop if
_continue() fails.
Probably this is not what we actually want for show_filter_state(), we can make it
better later. We can "embed" the rcu_lock_break() logic into _continue(), or change
break/continue to record the state (leader_start_time, thread_start_time) so that
a "false" return from _continue() means that the caller needs another schedule(),
struct state state;
rcu_read_lock();
for_each_process_thread(p, t) {
do_something_slow(p, t);
if (SPENT_TOO_MANY_TIME) {
for_each_process_thread_break(p, t, &state);
another_break:
rcu_read_unlock();
schedule();
rcu_read_lock();
if (!for_each_process_thread_continue(&p, &t, LIMIT, &state))
goto another_break;
}
}
rcu_read_unlock();
Not sure. I'd like to do something simple for the start. We need to make
show_state_filter() "preemptible" in any case. And even killable, I think.
Not only it can trivially trigger the soft-lockups (at least), it can simply
never finish.
Oleg.
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-08-08 14:30 +0200 |
| Message-ID | <s3RQR-1ls-15@gated-at.bofh.it> |
| In reply to | #1456019 |
On Wed, Aug 03, 2016 at 10:26:09PM +0200, Oleg Nesterov wrote: > Not sure. I'd like to do something simple for the start. We need to make > show_state_filter() "preemptible" in any case. And even killable, I think. > Not only it can trivially trigger the soft-lockups (at least), it can simply > never finish. Yeah, no objection raelly. Just make sure to put a comment explaining the limitation/issues with whatever you descide to go for.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web