public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dominik Dingel <dingel@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dominik Dingel <dingel@linux.vnet.ibm.com>
Subject: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block
Date: Thu, 17 Sep 2015 18:27:50 +0200	[thread overview]
Message-ID: <1442507270-67227-1-git-send-email-dingel@linux.vnet.ibm.com> (raw)

Commit f78195129963 ("kvm: add halt_poll_ns module parameter") calls, with
enabled preemption, single_task_running. When CONFIG_DEBUG_PREEMPT is
enabled that will result in a debug_smp_processor_id() call.

Cc:  <stable@vger.kernel.org> # 4.2.x
Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 virt/kvm/kvm_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 54534de..ce67dd6 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1971,6 +1971,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 
 	start = cur = ktime_get();
 	if (vcpu->halt_poll_ns) {
+		bool solo;
 		ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
 
 		do {
@@ -1982,8 +1983,13 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 				++vcpu->stat.halt_successful_poll;
 				goto out;
 			}
+
+			preempt_disable();
+			solo = single_task_running();
+			preempt_enable();
+
 			cur = ktime_get();
-		} while (single_task_running() && ktime_before(cur, stop));
+		} while (solo && ktime_before(cur, stop));
 	}
 
 	for (;;) {
-- 
2.3.8


             reply	other threads:[~2015-09-17 16:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17 16:27 Dominik Dingel [this message]
2015-09-17 16:45 ` single_task_running() vs. preemption warnings (was Re: [PATCH] kvm: fix preemption warnings in kvm_vcpu_block) Paolo Bonzini
2015-09-17 17:07   ` Dominik Dingel
2015-09-17 20:32     ` Tim Chen
2015-09-18  7:52       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442507270-67227-1-git-send-email-dingel@linux.vnet.ibm.com \
    --to=dingel@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox