linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]sched: completion: use bool in try_wait_for_completion
@ 2018-02-21 12:54 gaurav jindal
  2018-02-21 13:28 ` Peter Zijlstra
  2018-03-09  9:06 ` [tip:sched/core] sched/completions: Use bool in try_wait_for_completion() tip-bot for gaurav jindal
  0 siblings, 2 replies; 7+ messages in thread
From: gaurav jindal @ 2018-02-21 12:54 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel

Variable ret in try_wait_for_completion can have only true/false values. Since
the return type of the function is also bool, variable ret should have data
type as bool in place of int.
Moreover, the size of bool in many platforms is 1 byte whereas size of int is
4 bytes(though architecture dependent). Modifying the data type reduces the 
size consumed for the stack.

Signed-off-by: Gaurav Jindal<gauravjindal1104@gmail.com>

---

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 0926aef..3e15e8d 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -283,7 +283,7 @@ int __sched wait_for_completion_killable(struct completion *x)
 bool try_wait_for_completion(struct completion *x)
 {
 	unsigned long flags;
-	int ret = 1;
+	bool ret = true;

 	/*
 	 * Since x->done will need to be locked only
@@ -292,11 +292,11 @@ bool try_wait_for_completion(struct completion *x)
 	 * return early in the blocking case.
 	 */
 	if (!READ_ONCE(x->done))
-		return 0;
+		return false;

 	spin_lock_irqsave(&x->wait.lock, flags);
 	if (!x->done)
-		ret = 0;
+		ret = false;
 	else if (x->done != UINT_MAX)
 		x->done--;
 	spin_unlock_irqrestore(&x->wait.lock, flags);

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH]sched: completion: use bool in try_wait_for_completion
@ 2018-02-14 10:30 gaurav jindal
  2018-02-19 10:44 ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: gaurav jindal @ 2018-02-14 10:30 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel

Use bool in place of int in the function try_wait_for_completion.

Signed-off-by: Gaurav Jindal<gauravjindal1104@gmail.com>

---

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 0926aef..3e15e8d 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -283,7 +283,7 @@ int __sched wait_for_completion_killable(struct completion *x)
 bool try_wait_for_completion(struct completion *x)
 {
        unsigned long flags;
-       int ret = 1;
+       bool ret = true;

        /*
         * Since x->done will need to be locked only
@@ -292,11 +292,11 @@ bool try_wait_for_completion(struct completion *x)
         * return early in the blocking case.
         */
        if (!READ_ONCE(x->done))
-               return 0;
+               return false;

        spin_lock_irqsave(&x->wait.lock, flags);
        if (!x->done)
-               ret = 0;
+               ret = false;
        else if (x->done != UINT_MAX)
                x->done--;
        spin_unlock_irqrestore(&x->wait.lock, flags);

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH]sched: completion: use bool in try_wait_for_completion
@ 2018-01-24  9:57 gaurav jindal
  0 siblings, 0 replies; 7+ messages in thread
From: gaurav jindal @ 2018-01-24  9:57 UTC (permalink / raw)
  To: peterz, mingo; +Cc: linux-kernel

Use bool in place of int in the function try_wait_for_completion.

Signed-off-by: Gaurav Jindal<gauravjindal1104@gmail.com>

---

diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index 0926aef..3e15e8d 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -283,7 +283,7 @@ int __sched wait_for_completion_killable(struct completion *x)
 bool try_wait_for_completion(struct completion *x)
 {
 	unsigned long flags;
-	int ret = 1;
+	bool ret = true;

 	/*
 	 * Since x->done will need to be locked only
@@ -292,11 +292,11 @@ bool try_wait_for_completion(struct completion *x)
 	 * return early in the blocking case.
 	 */
 	if (!READ_ONCE(x->done))
-		return 0;
+		return false;

 	spin_lock_irqsave(&x->wait.lock, flags);
 	if (!x->done)
-		ret = 0;
+		ret = false;
 	else if (x->done != UINT_MAX)
 		x->done--;
 	spin_unlock_irqrestore(&x->wait.lock, flags);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-09  9:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 12:54 [PATCH]sched: completion: use bool in try_wait_for_completion gaurav jindal
2018-02-21 13:28 ` Peter Zijlstra
2018-02-21 13:49   ` gaurav jindal
2018-03-09  9:06 ` [tip:sched/core] sched/completions: Use bool in try_wait_for_completion() tip-bot for gaurav jindal
  -- strict thread matches above, loose matches on Subject: below --
2018-02-14 10:30 [PATCH]sched: completion: use bool in try_wait_for_completion gaurav jindal
2018-02-19 10:44 ` Peter Zijlstra
2018-01-24  9:57 gaurav jindal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).