[PATCH] hrtimers: Use consistent variable names for timerqueue_node iterations

From: Ingo Molnar
Date: Thu Apr 09 2015 - 03:10:25 EST


We iterate over the timerqueue_node list of base->active.next
frequently, but the iterator variables are a colorful and inconsistent
mix: 'next', 'next_timer' (!), 'node' and 'node_next'.

For the 5 iterations we've invented 4 separate names for the same
thing ... sigh.

So standardize the naming to 'node_next': this both tells us that it's
an rbtree node, and that it's also a next element in a list.

No code changed:

text data bss dec hex filename
7754 427 0 8181 1ff5 hrtimer.o.before
7754 427 0 8181 1ff5 hrtimer.o.after

md5:
de9af3b01d50c72af2d8b026ed22704a hrtimer.o.before.asm
de9af3b01d50c72af2d8b026ed22704a hrtimer.o.after.asm

Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
kernel/time/hrtimer.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

Index: tip/kernel/time/hrtimer.c
===================================================================
--- tip.orig/kernel/time/hrtimer.c
+++ tip/kernel/time/hrtimer.c
@@ -448,14 +448,14 @@ static ktime_t __hrtimer_get_next_event(
int i;

for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) {
- struct timerqueue_node *next;
+ struct timerqueue_node *node_next;
struct hrtimer *timer;

- next = base->active.next;
- if (!next)
+ node_next = base->active.next;
+ if (!node_next)
continue;

- timer = container_of(next, struct hrtimer, node);
+ timer = container_of(node_next, struct hrtimer, node);
expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
if (expires.tv64 < expires_next.tv64)
expires_next = expires;
@@ -872,13 +872,13 @@ static void __remove_hrtimer(struct hrti
struct hrtimer_clock_base *base,
unsigned long newstate, int reprogram)
{
- struct timerqueue_node *next_timer;
+ struct timerqueue_node *node_next;
if (!(timer->state & HRTIMER_STATE_ENQUEUED))
goto out;

- next_timer = base->active.next;
+ node_next = base->active.next;
timerqueue_del(&base->active, &timer->node);
- if (&timer->node == next_timer) {
+ if (&timer->node == node_next) {
#ifdef CONFIG_HIGH_RES_TIMERS
/* Reprogram the clock event device. if enabled */
if (reprogram && hrtimer_hres_active()) {
@@ -1262,7 +1262,7 @@ retry:

for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
struct hrtimer_clock_base *base;
- struct timerqueue_node *node;
+ struct timerqueue_node *node_next;
ktime_t basenow;

base = cpu_base->clock_base + i;
@@ -1271,10 +1271,10 @@ retry:

basenow = ktime_add(now, base->offset);

- while ((node = base->active.next)) {
+ while ((node_next = base->active.next)) {
struct hrtimer *timer;

- timer = container_of(node, struct hrtimer, node);
+ timer = container_of(node_next, struct hrtimer, node);

/*
* The immediate goal for using the softexpires is
@@ -1428,7 +1428,7 @@ void hrtimer_run_pending(void)
*/
void hrtimer_run_queues(void)
{
- struct timerqueue_node *node;
+ struct timerqueue_node *node_next;
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
struct hrtimer_clock_base *base;
int index, gettime = 1;
@@ -1448,10 +1448,10 @@ void hrtimer_run_queues(void)

raw_spin_lock(&cpu_base->lock);

- while ((node = base->active.next)) {
+ while ((node_next = base->active.next)) {
struct hrtimer *timer;

- timer = container_of(node, struct hrtimer, node);
+ timer = container_of(node_next, struct hrtimer, node);
if (base->softirq_time.tv64 <=
hrtimer_get_expires_tv64(timer))
break;
@@ -1629,10 +1629,10 @@ static void migrate_hrtimer_list(struct
struct hrtimer_clock_base *new_base)
{
struct hrtimer *timer;
- struct timerqueue_node *node;
+ struct timerqueue_node *node_next;

- while ((node = old_base->active.next)) {
- timer = container_of(node, struct hrtimer, node);
+ while ((node_next = old_base->active.next)) {
+ timer = container_of(node_next, struct hrtimer, node);
BUG_ON(hrtimer_callback_running(timer));
debug_deactivate(timer);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/