* [patch] sched: signedness bug in yield_to()
@ 2014-05-23 10:20 Dan Carpenter
2014-05-23 10:46 ` Peter Zijlstra
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2014-05-23 10:20 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Peter Zijlstra, linux-kernel, kernel-janitors
yield_to() is supposed to return -ESRCH if there is no task to
yield to, but because the type is bool that is the same as returning
true.
The only place I see which cares is kvm_vcpu_on_spin().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 9112646..7c72b14 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2173,7 +2173,7 @@ static inline void sched_autogroup_fork(struct signal_struct *sig) { }
static inline void sched_autogroup_exit(struct signal_struct *sig) { }
#endif
-extern bool yield_to(struct task_struct *p, bool preempt);
+extern int yield_to(struct task_struct *p, bool preempt);
extern void set_user_nice(struct task_struct *p, long nice);
extern int task_prio(const struct task_struct *p);
/**
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 927fa33..40f8de4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4209,7 +4209,7 @@ EXPORT_SYMBOL(yield);
* false (0) if we failed to boost the target.
* -ESRCH if there's no task to yield to.
*/
-bool __sched yield_to(struct task_struct *p, bool preempt)
+int __sched yield_to(struct task_struct *p, bool preempt)
{
struct task_struct *curr = current;
struct rq *rq, *p_rq;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 970c681..ec4e3bd 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -586,7 +586,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
void kvm_vcpu_block(struct kvm_vcpu *vcpu);
void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
-bool kvm_vcpu_yield_to(struct kvm_vcpu *target);
+int kvm_vcpu_yield_to(struct kvm_vcpu *target);
void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu);
void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 95b4c2b..9458196 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1713,11 +1713,11 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
EXPORT_SYMBOL_GPL(kvm_vcpu_kick);
#endif /* !CONFIG_S390 */
-bool kvm_vcpu_yield_to(struct kvm_vcpu *target)
+int kvm_vcpu_yield_to(struct kvm_vcpu *target)
{
struct pid *pid;
struct task_struct *task = NULL;
- bool ret = false;
+ int ret = 0;
rcu_read_lock();
pid = rcu_dereference(target->pid);
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [patch] sched: signedness bug in yield_to()
2014-05-23 10:20 [patch] sched: signedness bug in yield_to() Dan Carpenter
@ 2014-05-23 10:46 ` Peter Zijlstra
2014-05-23 13:40 ` Raghavendra KT
2014-06-05 14:34 ` [tip:sched/core] sched: Fix " tip-bot for Dan Carpenter
2 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2014-05-23 10:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Ingo Molnar, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 352 bytes --]
On Fri, May 23, 2014 at 01:20:42PM +0300, Dan Carpenter wrote:
> yield_to() is supposed to return -ESRCH if there is no task to
> yield to, but because the type is bool that is the same as returning
> true.
>
> The only place I see which cares is kvm_vcpu_on_spin().
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks Dan!
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] sched: signedness bug in yield_to()
2014-05-23 10:20 [patch] sched: signedness bug in yield_to() Dan Carpenter
2014-05-23 10:46 ` Peter Zijlstra
@ 2014-05-23 13:40 ` Raghavendra KT
2014-06-05 14:34 ` [tip:sched/core] sched: Fix " tip-bot for Dan Carpenter
2 siblings, 0 replies; 5+ messages in thread
From: Raghavendra KT @ 2014-05-23 13:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ingo Molnar, Peter Zijlstra, Linux Kernel Mailing List,
kernel-janitors
On Fri, May 23, 2014 at 3:50 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> yield_to() is supposed to return -ESRCH if there is no task to
> yield to, but because the type is bool that is the same as returning
> true.
>
> The only place I see which cares is kvm_vcpu_on_spin().
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks, Please feel free to add
Reviewed-by: Raghavendra <raghavendra.kt@linux.vnet.ibm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip:sched/core] sched: Fix signedness bug in yield_to()
2014-05-23 10:20 [patch] sched: signedness bug in yield_to() Dan Carpenter
2014-05-23 10:46 ` Peter Zijlstra
2014-05-23 13:40 ` Raghavendra KT
@ 2014-06-05 14:34 ` tip-bot for Dan Carpenter
2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Dan Carpenter @ 2014-06-05 14:34 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, torvalds, peterz, gleb, raghavendra.kt,
pbonzini, tglx, dan.carpenter
Commit-ID: fa93384f40deeb294fd29f2fdcadbd0ebc2dedf1
Gitweb: http://git.kernel.org/tip/fa93384f40deeb294fd29f2fdcadbd0ebc2dedf1
Author: Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Fri, 23 May 2014 13:20:42 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 5 Jun 2014 11:52:13 +0200
sched: Fix signedness bug in yield_to()
yield_to() is supposed to return -ESRCH if there is no task to
yield to, but because the type is bool that is the same as returning
true.
The only place I see which cares is kvm_vcpu_on_spin().
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Raghavendra <raghavendra.kt@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Link: http://lkml.kernel.org/r/20140523102042.GA7267@mwanda
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/kvm_host.h | 2 +-
include/linux/sched.h | 2 +-
kernel/sched/core.c | 2 +-
virt/kvm/kvm_main.c | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 7d21cf9..3c4bcf1 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -584,7 +584,7 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
void kvm_vcpu_block(struct kvm_vcpu *vcpu);
void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
-bool kvm_vcpu_yield_to(struct kvm_vcpu *target);
+int kvm_vcpu_yield_to(struct kvm_vcpu *target);
void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu);
void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0f91d00..6790c3b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2180,7 +2180,7 @@ static inline void sched_autogroup_fork(struct signal_struct *sig) { }
static inline void sched_autogroup_exit(struct signal_struct *sig) { }
#endif
-extern bool yield_to(struct task_struct *p, bool preempt);
+extern int yield_to(struct task_struct *p, bool preempt);
extern void set_user_nice(struct task_struct *p, long nice);
extern int task_prio(const struct task_struct *p);
/**
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 321d800..afcc842 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4195,7 +4195,7 @@ EXPORT_SYMBOL(yield);
* false (0) if we failed to boost the target.
* -ESRCH if there's no task to yield to.
*/
-bool __sched yield_to(struct task_struct *p, bool preempt)
+int __sched yield_to(struct task_struct *p, bool preempt)
{
struct task_struct *curr = current;
struct rq *rq, *p_rq;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 56baae8..86d1c45 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1708,11 +1708,11 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
EXPORT_SYMBOL_GPL(kvm_vcpu_kick);
#endif /* !CONFIG_S390 */
-bool kvm_vcpu_yield_to(struct kvm_vcpu *target)
+int kvm_vcpu_yield_to(struct kvm_vcpu *target)
{
struct pid *pid;
struct task_struct *task = NULL;
- bool ret = false;
+ int ret = 0;
rcu_read_lock();
pid = rcu_dereference(target->pid);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [patch] sched: signedness bug in yield_to()
@ 2013-02-05 11:37 Dan Carpenter
2013-02-05 15:23 ` [tip:sched/core] sched: Fix " tip-bot for Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-02-05 11:37 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Peter Zijlstra, linux-kernel, kernel-janitors, kbuild
In 7b270f6099 "sched: Bail out of yield_to when source and target
runqueue has one task" we changed this to store -ESRCH so it needs to
be signed.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 3e7b280..7ba7ea5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4384,7 +4384,7 @@ bool __sched yield_to(struct task_struct *p, bool preempt)
struct task_struct *curr = current;
struct rq *rq, *p_rq;
unsigned long flags;
- bool yielded = 0;
+ int yielded = 0;
local_irq_save(flags);
rq = this_rq();
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [tip:sched/core] sched: Fix signedness bug in yield_to()
2013-02-05 11:37 [patch] sched: " Dan Carpenter
@ 2013-02-05 15:23 ` tip-bot for Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Dan Carpenter @ 2013-02-05 15:23 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, efault, peterz, rostedt, tglx,
dan.carpenter
Commit-ID: c3c186403c6abd32e719f005f0af950155a9e54d
Gitweb: http://git.kernel.org/tip/c3c186403c6abd32e719f005f0af950155a9e54d
Author: Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Tue, 5 Feb 2013 14:37:51 +0300
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 5 Feb 2013 12:59:29 +0100
sched: Fix signedness bug in yield_to()
In 7b270f6099 "sched: Bail out of yield_to when source and
target runqueue has one task" we changed this to store -ESRCH so
it needs to be signed.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: kbuild@01.org
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mike Galbraith <efault@gmx.de>
Link: http://lkml.kernel.org/r/20130205113751.GA20521@elgon.mountain
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 26058d0..c5b089d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4371,7 +4371,7 @@ bool __sched yield_to(struct task_struct *p, bool preempt)
struct task_struct *curr = current;
struct rq *rq, *p_rq;
unsigned long flags;
- bool yielded = 0;
+ int yielded = 0;
local_irq_save(flags);
rq = this_rq();
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-05 14:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-23 10:20 [patch] sched: signedness bug in yield_to() Dan Carpenter
2014-05-23 10:46 ` Peter Zijlstra
2014-05-23 13:40 ` Raghavendra KT
2014-06-05 14:34 ` [tip:sched/core] sched: Fix " tip-bot for Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2013-02-05 11:37 [patch] sched: " Dan Carpenter
2013-02-05 15:23 ` [tip:sched/core] sched: Fix " tip-bot for Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox