lkml.org 
[lkml]   [2017]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch V2 08/10] timer: Implement the hierarchical pull model
On Wed, Apr 19, 2017 at 11:44:45AM +0200, Peter Zijlstra wrote:
> On Wed, Apr 19, 2017 at 11:09:14AM +0200, Peter Zijlstra wrote:
>
> > Would it be very onerous to rewrite that into regular loops? That avoids
> > us having to think (and worry) about blowing our stack.
>
> void walk_groups(bool (*up)(void *), void (*down)(void *), void *data)
> {
> struct tmigr_cpu *tmc = this_cpu_ptr(&tmigr_cpu);
> struct group *stack[tmigr_hierarchy_levels];
> struct group *group = tmc->group;
> int i = 0;
>
> raw_spin_lock(&tmc->lock);
>
> do {
> stack[i++] = group;
>
> if (up(data))
> break;
>
> } while ((group = group->parent));
>
> do {
> group = stack[--i];
>
> down(data);
>
> } while (group != tmc->group);
>
> raw_spin_unlock(&tmc->lock);
> }
>
> Something like so, iterates the hierarchy for the current CPU and calls
> @up and @down at each level in the proper order. And has obvious stack
> usage.

I should, of course, have added @group as an argument to @up,@down.
Otherwise its a bit hard for them to know what to do.

\
 
 \ /
  Last update: 2017-04-19 11:54    [W:0.043 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site