[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170419094445.oj5zc624zanv2hfp@hirez.programming.kicks-ass.net>
Date: Wed, 19 Apr 2017 11:44:45 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
John Stultz <john.stultz@...aro.org>,
Eric Dumazet <edumazet@...gle.com>,
Anna-Maria Gleixner <anna-maria@...utronix.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
linux-pm@...r.kernel.org, Arjan van de Ven <arjan@...radead.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Rik van Riel <riel@...hat.com>
Subject: Re: [patch V2 08/10] timer: Implement the hierarchical pull model
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.
Powered by blists - more mailing lists