Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp49205iob; Mon, 2 May 2022 12:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeXq1Ss0WtHS8ZjOxUp9ApmMZRZ9NJDc+VDxw93U1bvUQgAShM2Q9LuQDhE5MBXzs7WZtB X-Received: by 2002:aa7:8104:0:b0:50d:374b:4568 with SMTP id b4-20020aa78104000000b0050d374b4568mr12752000pfi.45.1651520677877; Mon, 02 May 2022 12:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651520677; cv=none; d=google.com; s=arc-20160816; b=WbVfcDukGaZt2UgUiHRR1cBRdeJeQrp86qawkq1NNs4V8a7x5nvbhr25c7QDXLiDVF Ywsw5+Ia0B1ys1T8TNidUK+Qpmw48wGWUr/xaNQaz+ZJHlXQgKPa9/4k/7IYwzdHzLNt OPhCePByMmO2seTTCwHEOnM2xFRmCYL9/0UEYFyRBaM46GukmD2Vr2oV/M6KE298NrLD 4NrlB/1xrNgDnN1Id8yr681GcMpbBWUxox6Yit8MnXcFbjlRewcf2bfgM8ESpzcQ8Yok PBy1+3mmHLqQLpzESQnzS726se0Ek49rCnrDBubnmmeVr4qGO+jhDwjBm/JOOEZdoiHN e+vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fU7Z+q92leOT4vuuZNlugAe89BeML8kiQw/jyBkx1XI=; b=wBbPX3KwH2/V6UiAhahJJBDfiexQubPPJbQpABT5v/rh1Ev8zh8WEw4/LPyci+q1P7 +L8Rh7pIhtW3oFTKBBA2eiWqrJusBNkbUByKuBimYJvMD0tw/tEnwibG22mW2DcVzeE2 dFw5geT31wyyl0YZWbNOddnfC6EPCj1SIHjzoMPgh7o7pHBVxaiRdUMrwdKOqyM/GAiv g7J+Jgk9rG9ZFNBc3EQcS7A+O1Tihr9WbkfjO4JsfFknfA4c05j3XC0Q6eNT68R6mpwG 6hzkKZ6tPIdxea68YqQiAa7OBl/a071GX+hSIA2HVdl2R35Cz6AqbA/ntLPjS4tnW9ho FsGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RZtyDv4j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a17090ad48f00b001bf35bf24d7si153947pju.63.2022.05.02.12.44.22; Mon, 02 May 2022 12:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RZtyDv4j; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232101AbiD3IPZ (ORCPT + 99 others); Sat, 30 Apr 2022 04:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiD3IPW (ORCPT ); Sat, 30 Apr 2022 04:15:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7119C5E777 for ; Sat, 30 Apr 2022 01:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651306320; 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=fU7Z+q92leOT4vuuZNlugAe89BeML8kiQw/jyBkx1XI=; b=RZtyDv4jKEtG5KATdbTpSeVCUx86pFtcOf3nVpanmvIp3c6xgeSGJQukulG2oGMKKyIu/k dpN7RQA0oU6AsSAvVl8ue0lw9XL0pGfPxeMC2Sl7ysogtvo+XNYyEur6db0upXZTY+Gz2Q Fe/IrJPtBA47dRpaNdi1Y3IfoUu13iQ= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-HvdlGZasOsuJlDNzGVlXTQ-1; Sat, 30 Apr 2022 04:11:59 -0400 X-MC-Unique: HvdlGZasOsuJlDNzGVlXTQ-1 Received: by mail-ej1-f69.google.com with SMTP id l20-20020a170906795400b006f3f30daf18so1973303ejo.22 for ; Sat, 30 Apr 2022 01:11:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=fU7Z+q92leOT4vuuZNlugAe89BeML8kiQw/jyBkx1XI=; b=uSk9doCRu5m1E1+vZYmAAcxC0Bu+aRazGX1bKEFqEgoN3XywZap3Wj+imnPzK4YvT5 ncm9CMT7IMLBw6dSoZMRoPkDi1/EoZmXGjKSsHaO0FAnOJ6KBaMJ65iBI4lFkgjuraHe 2S4FwO6ZjBisfCdwZIKDtquQAus27fewUcVJ/HDZaZgKRoV09L1AuKCGaTfbxNxTrwWR QjLMlcfJ/PkY2at5J+WQ+SmYVP17y9riGmhLebPJOkK96SYti1OK0yjDBuZpocIQ+2ZQ OXXWV+dMvO05IaxEvLpxSe48xBLiVc9wK3aTYyKuMGyIewyZOajakqwaXR712kxo1DHD jqtA== X-Gm-Message-State: AOAM530xLqLgJKQmXXChuVrK6LuHiOA0Sun9rII00zjqWfYWTKsfP45u oU1pcYl7h85Sb+aLDzkIW5F66SvNggESU+Uc9ahcHWrt1sE3MFTJZ0ztUAZjbW6Lb7Z03jl2Ct5 aD2n63fmvmkvAFX1AQ8s/l/p5 X-Received: by 2002:a05:6402:1e92:b0:426:258:cf51 with SMTP id f18-20020a0564021e9200b004260258cf51mr3511807edf.124.1651306317889; Sat, 30 Apr 2022 01:11:57 -0700 (PDT) X-Received: by 2002:a05:6402:1e92:b0:426:258:cf51 with SMTP id f18-20020a0564021e9200b004260258cf51mr3511795edf.124.1651306317712; Sat, 30 Apr 2022 01:11:57 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.googlemail.com with ESMTPSA id g14-20020a056402180e00b0042617ba6389sm3804614edy.19.2022.04.30.01.11.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Apr 2022 01:11:57 -0700 (PDT) Message-ID: <0b18fbcb-97d6-fb82-25b4-1f288a65b78f@redhat.com> Date: Sat, 30 Apr 2022 10:11:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v3] KVM: SEV: Mark nested locking of vcpu->lock Content-Language: en-US To: Hillf Danton Cc: Peter Gonda , Sean Christopherson , LKML References: <20220407195908.633003-1-pgonda@google.com> <62e9ece1-5d71-f803-3f65-2755160cf1d1@redhat.com> <4c0edc90-36a1-4f4c-1923-4b20e7bdbb4c@redhat.com> <20220429010312.4013-1-hdanton@sina.com> <20220429114012.4127-1-hdanton@sina.com> <20220430015008.4257-1-hdanton@sina.com> From: Paolo Bonzini In-Reply-To: <20220430015008.4257-1-hdanton@sina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/30/22 03:50, Hillf Danton wrote: > lock for migration > === > kvm_for_each_vcpu(i, vcpu, kvm) { > if (mutex_lock_killable(&vcpu->mutex)) > goto out_unlock; > lockdep_copy_map(&vcpu->v_dep_map, &vcpu->mutex.dep_map); > mutex_release(&vcpu->mutex.dep_map, ip); > } > > > unlock for migration > === > kvm_for_each_vcpu(i, vcpu, kvm) { > lockdep_copy_map(&vcpu->mutex.dep_map, &vcpu->v_dep_map); > /* > * Or directly acquire without v_dep_map added > * > mutex_acquire(&vcpu->mutex.dep_map, 0, 1,_RET_IP_); > */ > mutex_unlock(&vcpu->mutex); > } Yes this is exactly what Peter is doing, except that we're trying to keep one lock taken. Thanks for pointing to lock_sock_nested(). Paolo