From patchwork Tue Nov 5 07:42:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 288399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D79872C025E for ; Tue, 5 Nov 2013 18:42:13 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753009Ab3KEHmN (ORCPT ); Tue, 5 Nov 2013 02:42:13 -0500 Received: from mail-oa0-f42.google.com ([209.85.219.42]:46488 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752990Ab3KEHmM (ORCPT ); Tue, 5 Nov 2013 02:42:12 -0500 Received: by mail-oa0-f42.google.com with SMTP id l6so196560oag.15 for ; Mon, 04 Nov 2013 23:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=28U1kdypH0D+5akGcu3IBAHFQSzUvZE0WYcWXPyTz5c=; b=NOUKmxq6TAltuehEmL3TnqInlN41RaO06EwoCSxhHL76hU82edlrEkA9lMJ3RAwgtx bAl0F9Ih0o+O+l4lK1vwoHVb5a4zzZEm8qTMNZc1Hi9J9i9/Au7Cg9QYBHc0i7KXMcRb GIDwwUQGKbgHJInXWduIdl/Fx2whaifFmWyQCnwl5LOy7jGxC7fEH6Sryz2+jiPrTBws ltPcFKzPD5XOxOtlaZAnS9ZMIFoQb8iCWGjiuFRCf7VQqOva9jB2ytpU+/838AWadIWU wPwSsbceWmRjYhMN5BQf4/cmlkFg75+A4Sox6NEeV73exl3Md+zVwJq56HBiRPC3Ufu7 EONg== X-Received: by 10.182.60.41 with SMTP id e9mr17825547obr.8.1383637332058; Mon, 04 Nov 2013 23:42:12 -0800 (PST) Received: from localhost ([202.108.130.138]) by mx.google.com with ESMTPSA id ee7sm45716397oeb.5.2013.11.04.23.42.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Nov 2013 23:42:11 -0800 (PST) From: Liu Ping Fan To: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Alexander Graf Subject: [PATCH 1/3] powerpc/kvm: simplify the entering logic for secondary thread Date: Tue, 5 Nov 2013 15:42:42 +0800 Message-Id: <1383637364-14691-1-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org After the primary vcpu changes vcore_state to VCORE_RUNNING, there is very little chance to schedule to secondary vcpu. So if we change the code sequence around set vcore_state to VCORE_RUNNING and disable preemption, we lost little. But we simplify the entering logi, based on the fact that if primary vcpu runs, the secondary vcpu can not be scheduled. Signed-off-by: Liu Ping Fan --- arch/powerpc/kvm/book3s_hv.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 62a2b5a..38b1fc0 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1222,8 +1222,8 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) kvmppc_create_dtl_entry(vcpu, vc); } - vc->vcore_state = VCORE_RUNNING; preempt_disable(); + vc->vcore_state = VCORE_RUNNING; spin_unlock(&vc->lock); kvm_guest_enter(); @@ -1351,12 +1351,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) * this thread straight away and have it join in. */ if (!signal_pending(current)) { - if (vc->vcore_state == VCORE_RUNNING && - VCORE_EXIT_COUNT(vc) == 0) { - vcpu->arch.ptid = vc->n_runnable - 1; - kvmppc_create_dtl_entry(vcpu, vc); - kvmppc_start_thread(vcpu); - } else if (vc->vcore_state == VCORE_SLEEPING) { + if (vc->vcore_state == VCORE_SLEEPING) { wake_up(&vc->wq); }