Skip to contentSkip to conversation

semaphore: Resolve some shadow warnings

PATCH Superseded Jeff Kirsher 3 participants 5 messages Aug 28, 2014 – Sep 3, 2014 Locking primitives

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 semaphore: Resolve some shadow warnings

From: Mark Rustad <[email protected]>

Resolve some shadow warnings resulting from using the name jiffies, which is a well-known global. This is not a problem of course, but it could be a trap for someone copying and pasting code, and it just makes W=2 a little cleaner.

---
 kernel/locking/semaphore.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/locking/semaphore.c +6 -6
index 6815171..7782dbc 100644
@@ -36,7 +36,7 @@
 static noinline void __down(struct semaphore *sem);
 static noinline int __down_interruptible(struct semaphore *sem);
 static noinline int __down_killable(struct semaphore *sem);
-static noinline int __down_timeout(struct semaphore *sem, long jiffies);
+static noinline int __down_timeout(struct semaphore *sem, long njiffies);
 static noinline void __up(struct semaphore *sem);
 
 /**
@@ -145,14 +145,14 @@ EXPORT_SYMBOL(down_trylock);
 /**
  * down_timeout - acquire the semaphore within a specified time
  * @sem: the semaphore to be acquired
- * @jiffies: how long to wait before failing
+ * @njiffies: how long to wait before failing
  *
  * Attempts to acquire the semaphore.  If no more tasks are allowed to
  * acquire the semaphore, calling this function will put the task to sleep.
  * If the semaphore is not released within the specified number of jiffies,
  * this function returns -ETIME.  It returns 0 if the semaphore was acquired.
  */
-int down_timeout(struct semaphore *sem, long jiffies)
+int down_timeout(struct semaphore *sem, long njiffies)
 {
 	unsigned long flags;
 	int result = 0;
@@ -161,7 +161,7 @@ int down_timeout(struct semaphore *sem, long jiffies)
 	if (likely(sem->count > 0))
 		sem->count--;
 	else
-		result = __down_timeout(sem, jiffies);
+		result = __down_timeout(sem, njiffies);
 	raw_spin_unlock_irqrestore(&sem->lock, flags);
 
 	return result;
@@ -248,9 +248,9 @@ static noinline int __sched __down_killable(struct semaphore *sem)
 	return __down_common(sem, TASK_KILLABLE, MAX_SCHEDULE_TIMEOUT);
 }
 
-static noinline int __sched __down_timeout(struct semaphore *sem, long jiffies)
+static noinline int __sched __down_timeout(struct semaphore *sem, long njiffies)
 {
-	return __down_common(sem, TASK_UNINTERRUPTIBLE, jiffies);
+	return __down_common(sem, TASK_UNINTERRUPTIBLE, njiffies);
 }
 
 static noinline void __sched __up(struct semaphore *sem)
Signature · 1 line
1.9.3
maintainer
#1 lore raw
Quoted 9 lines · Jeff Kirsher

From: Mark Rustad <[email protected]>

Resolve some shadow warnings resulting from using the name jiffies, which is a well-known global. This is not a problem of course, but it could be a trap for someone copying and pasting code, and it just makes W=2 a little cleaner.

Why isn't Mark sending this email?

Quoted 9 lines
---
 kernel/locking/semaphore.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/locking/semaphore.c +0 -0
index 6815171..7782dbc 100644

kernel/locking/semaphore.c line 40

Quoted 6 lines
kernel/locking/semaphore.c +1 -1
@@ -36,7 +36,7 @@
 static noinline void __down(struct semaphore *sem);
 static noinline int __down_interruptible(struct semaphore *sem);
 static noinline int __down_killable(struct semaphore *sem);
-static noinline int __down_timeout(struct semaphore *sem, long jiffies);
+static noinline int __down_timeout(struct semaphore *sem, long njiffies);
 static noinline void __up(struct semaphore *sem);

So what's wrong with calling it "timeout" instead? That's what most other sites do.

#2 lore raw
Quoted 8 lines · Peter Zijlstra
Quoted 7 lines · Jeff Kirsher

From: Mark Rustad <[email protected]>

Resolve some shadow warnings resulting from using the name jiffies, which is a well-known global. This is not a problem of course, but it could be a trap for someone copying and pasting code, and it just makes W=2 a little cleaner.

Quoted 4 lines
Quoted 2 lines

Why isn't Mark sending this email?

Mark sent me several patches like this, for me to push upstream. So, I am making sure the appropriate owner is the receives the patch versus blindly sending to LKML.

Quoted 5 lines
Quoted 5 lines
---
 kernel/locking/semaphore.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 14 lines

kernel/locking/semaphore.c line 40

Quoted 11 lines
kernel/locking/semaphore.c +1 -1
index 6815171..7782dbc 100644
@@ -36,7 +36,7 @@
 static noinline void __down(struct semaphore *sem);
 static noinline int __down_interruptible(struct semaphore *sem);
 static noinline int __down_killable(struct semaphore *sem);
-static noinline int __down_timeout(struct semaphore *sem, long jiffies);
+static noinline int __down_timeout(struct semaphore *sem, long njiffies);
 static noinline void __up(struct semaphore *sem);

So what's wrong with calling it "timeout" instead? That's what most other sites do.

Timeout would work as well to resolve the shadow warnings.

#3 lore raw
Quoted 38 lines · Jeff Kirsher
Quoted 8 lines · Peter Zijlstra
Quoted 7 lines · Jeff Kirsher

From: Mark Rustad <[email protected]>

Resolve some shadow warnings resulting from using the name jiffies, which is a well-known global. This is not a problem of course, but it could be a trap for someone copying and pasting code, and it just makes W=2 a little cleaner.

Quoted 4 lines
Quoted 2 lines

Why isn't Mark sending this email?

Mark sent me several patches like this, for me to push upstream. So, I am making sure the appropriate owner is the receives the patch versus blindly sending to LKML.

Quoted 5 lines
Quoted 5 lines

---
kernel/locking/semaphore.c | 12 ++++++------

1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 14 lines

kernel/locking/semaphore.c line 40

Quoted 11 lines
kernel/locking/semaphore.c +1 -1
index 6815171..7782dbc 100644
@@ -36,7 +36,7 @@
 static noinline void __down(struct semaphore *sem);
 static noinline int __down_interruptible(struct semaphore *sem);
 static noinline int __down_killable(struct semaphore *sem);
-static noinline int __down_timeout(struct semaphore *sem, long jiffies);
+static noinline int __down_timeout(struct semaphore *sem, long njiffies);
 static noinline void __up(struct semaphore *sem);

So what's wrong with calling it "timeout" instead? That's what most other sites do.

Quoted 1 line

Timeout would work as well to resolve the shadow warnings.

It would, but then it would be unclear as to what units the timeout was in. I have no other objection to timeout, I was just trying to preserve the meaning in the existing overloaded name. The "n" to me suggests a number and, if anything, number of jiffies conveys a more precise meaning than simply jiffies did.

Signature · 1 line
Mark Rustad, Networking Division, Intel Corporation
maintainer
#4 lore raw
Quoted 6 lines · Mark D

It would, but then it would be unclear as to what units the timeout was in. I have no other objection to timeout, I was just trying to preserve the meaning in the existing overloaded name. The "n" to me suggests a number and, if anything, number of jiffies conveys a more precise meaning than simply jiffies did.

Use a comment for the unit. If you look you'll find tons of 'timeout' variables that measure in jiffies (and others of course).