Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6550356ybc; Thu, 28 Nov 2019 01:10:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzQksjCFgt1z5Aoa4OqlXbdXaucI7BkyA/FPEdOPrGh+KKgFyL8XPZ9gGzeK3hzVBHWpEAS X-Received: by 2002:a05:6402:19ae:: with SMTP id o14mr37857462edz.241.1574932212153; Thu, 28 Nov 2019 01:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574932212; cv=none; d=google.com; s=arc-20160816; b=ZzmluKMoqKiBV0FgR2u8wbif2x7VMITrZ+4Nrqr9wDPJK5VbkxRbWknWfQPghM6ioI HG9YhkHLGuBry8GKP/Pwff31Z+M+rPdoOBFbX5EuLoJ0GP85UZ7CojivX/ilVXuv4Bst jiTMuUaVDhOB1Ktlw5ErYjdn8IvDdI9yMjEC/l6AgB7hOr6yRrOCi4WWL7ZK0fXzfgHg k5MRTPsCHhzdi/rqdbVRoswrcazhuGyv87qBoh26t1hXaI+4icuoWgf3T5Dg872pTkwS GvbuxGgbGSTcKP3z5tN0FnEYSbneoF/mESoM6v104wacQ+zYKJfbdJ2qet8ugCcbE/U2 BDHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=LQyMIOq1brhBX2bUMaM6TFXqa3RnBbkv7h2aLB1dU5Q=; b=ZLD2TWZCvEgn4BJSH7m4+3EeLdKIuUijXHVsrcszdSqRzMAmol0wJitoW9d42uL+n2 cmxNU5IlvC6JYZFWqD0pnc9wOBUY/aZCnC8vatzUM8ki75ZBcvoIRinVa/BRAIWB6fod m6ZYARe4/vqYunvHGjNQdlvUNUSzJwpyJdSsuCSZwJT8qN0tYYCQNYCQmeqOMTGuH+H6 cCoruT3vXbjt8bR69D40hQfwlSXb6S8BT/M07xro/J31UXHRSlc3zZlRwDEqSWu1b081 1iR9EK3VGnX9/YEVaDNm7QBoWy50DiwDBslqb5AMm/sxX7h6gtwNET395eGlY8u2ayYX f6Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ld4ueGqn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy25si11157609ejb.291.2019.11.28.01.09.47; Thu, 28 Nov 2019 01:10:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ld4ueGqn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727139AbfK1JIG (ORCPT + 99 others); Thu, 28 Nov 2019 04:08:06 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55972 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725789AbfK1JIG (ORCPT ); Thu, 28 Nov 2019 04:08:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574932085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LQyMIOq1brhBX2bUMaM6TFXqa3RnBbkv7h2aLB1dU5Q=; b=Ld4ueGqnZKPx4dNjtYdjIb739E2lG5QLQUHrajg5oxhafViAuBP+DL0WEuiU2WaT49T/Gu RrJwsf/4FfejqfyW5eP8MYfBQhvxvZ0P7ZnNd5MA7KvAQD23JX/ngJQqNzEA4GgS51tmRh Q7N0P9j9KwS5CqPW21Fv+PGYckFwzpU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-0ZLVFI1nP2WETMSLr2dzlg-1; Thu, 28 Nov 2019 04:08:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B577980183C; Thu, 28 Nov 2019 09:08:00 +0000 (UTC) Received: from [10.36.116.37] (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 552426084E; Thu, 28 Nov 2019 09:07:54 +0000 (UTC) Subject: Re: [PATCH] KVM: vgic: Use warpper function to lock/unlock all vcpus in kvm_vgic_create() To: linmiaohe , maz@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, christoffer.dall@arm.com, catalin.marinas@arm.com, gregkh@linuxfoundation.org, will@kernel.org, andre.przywara@arm.com, tglx@linutronix.de Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <1574910551-14351-1-git-send-email-linmiaohe@huawei.com> From: Auger Eric Message-ID: Date: Thu, 28 Nov 2019 10:07:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1574910551-14351-1-git-send-email-linmiaohe@huawei.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 0ZLVFI1nP2WETMSLr2dzlg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11/28/19 4:09 AM, linmiaohe wrote: > From: Miaohe Lin > > Use warpper function lock_all_vcpus()/unlock_all_vcpus() s/warpper/wrapper and also in the title. > in kvm_vgic_create() to remove duplicated code dealing > with locking and unlocking all vcpus in a vm. > > Signed-off-by: Miaohe Lin > --- > virt/kvm/arm/vgic/vgic-init.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c > index b3c5de48064c..53e3969dfb52 100644 > --- a/virt/kvm/arm/vgic/vgic-init.c > +++ b/virt/kvm/arm/vgic/vgic-init.c > @@ -70,7 +70,7 @@ void kvm_vgic_early_init(struct kvm *kvm) > */ > int kvm_vgic_create(struct kvm *kvm, u32 type) > { > - int i, vcpu_lock_idx = -1, ret; > + int i, ret; > struct kvm_vcpu *vcpu; > > if (irqchip_in_kernel(kvm)) > @@ -92,11 +92,8 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) > * that no other VCPUs are run while we create the vgic. > */ > ret = -EBUSY; > - kvm_for_each_vcpu(i, vcpu, kvm) { > - if (!mutex_trylock(&vcpu->mutex)) > - goto out_unlock; > - vcpu_lock_idx = i; > - } > + if (!lock_all_vcpus(kvm)) > + return ret; > > kvm_for_each_vcpu(i, vcpu, kvm) { > if (vcpu->arch.has_run_once) > @@ -125,10 +122,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) > INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions); > > out_unlock: > - for (; vcpu_lock_idx >= 0; vcpu_lock_idx--) { > - vcpu = kvm_get_vcpu(kvm, vcpu_lock_idx); > - mutex_unlock(&vcpu->mutex); > - } > + unlock_all_vcpus(kvm); > return ret; > } > > Besides, looks good to me Reviewed-by: Eric Auger Thanks Eric