Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1227631

Re: single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block)

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block)
Date 2015-09-18 10:00 +0200
Message-ID <q9YKm-4Mg-3@gated-at.bofh.it> (permalink)
References <q9Ken-yZ-25@gated-at.bofh.it> <q9KxI-W9-21@gated-at.bofh.it> <q9KR5-1yz-41@gated-at.bofh.it> <q9OhX-6wj-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Sep 17, 2015 at 01:32:55PM -0700, Tim Chen wrote:
> I have no objection to change single_task_running to use
> raw_smp_processor_id.  The worker in mcryptd is bound to
> the cpu so it has no migration/preemption issue.  So it shouldn't care
> which smp_processor_id version is being used.  Yes, please add a comment
> to alert the user of this caveat should you change single_task_running.


We actually have raw_rq() for that, and the whole if thing looks rather
superfluous. So something like the below, except with a suitable comment
on and tested etc.. ;-)

---
 kernel/sched/core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6ab415aa15c4..f39c0498e284 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2666,10 +2666,7 @@ unsigned long nr_running(void)
  */
 bool single_task_running(void)
 {
-	if (cpu_rq(smp_processor_id())->nr_running == 1)
-		return true;
-	else
-		return false;
+	return raw_rq()->nr_running == 1;
 }
 EXPORT_SYMBOL(single_task_running);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] kvm: fix preemption warnings in kvm_vcpu_block Dominik Dingel <dingel@linux.vnet.ibm.com> - 2015-09-17 18:30 +0200
  single_task_running() vs. preemption warnings (was Re: [PATCH] kvm:  fix preemption warnings in kvm_vcpu_block) Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 18:50 +0200
    Re: single_task_running() vs. preemption warnings (was Re: [PATCH]  kvm: fix preemption warnings in kvm_vcpu_block) Dominik Dingel <dingel@linux.vnet.ibm.com> - 2015-09-17 19:10 +0200
      Re: single_task_running() vs. preemption warnings (was Re: [PATCH]  kvm: fix preemption warnings in kvm_vcpu_block) Tim Chen <tim.c.chen@linux.intel.com> - 2015-09-17 22:50 +0200
        Re: single_task_running() vs. preemption warnings (was Re: [PATCH]  kvm: fix preemption warnings in kvm_vcpu_block) Peter Zijlstra <peterz@infradead.org> - 2015-09-18 10:00 +0200

csiph-web