Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2397542iob; Sat, 30 Apr 2022 07:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx83UPkpDmXEMxXrYtivrlOzuJ/4LSfYg7wMszDRXQzm+0dnQpZ+hgWeQHbCnBrxH4nmQoH X-Received: by 2002:a19:8c4b:0:b0:44a:b6a4:4873 with SMTP id i11-20020a198c4b000000b0044ab6a44873mr3193943lfj.549.1651329098659; Sat, 30 Apr 2022 07:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651329098; cv=none; d=google.com; s=arc-20160816; b=LNiLthdnTcl5sYctikwM659huaCXwtosUbC1X+dDEWsGiQTI+MoIRVJLIMBlm04Xx3 HmYrga2m8EtOLgtCGapvOXWVB2aPPb5UXvdv10GopQZdUYuGrJK19z3DUNMDcKcGeHv7 H5B4NxmNVEpRu/KWKrNI2oUKMKbxuSg/cmdBevyCEwIyXtxdvqAylifomzYisEc2iZXs BY+eWYVNEz4ll8APWRzCC5HlzLRc/jL0BPyxoLCuLNivr2NG3oTvUfG9uQd+9WJW0krK /pydZm6N7Ds0SOncxjdMqGdZKEArmQOj1JcWOJf19HErKM2z3+qdRRoQZgpwQvxSh55F uwUw== 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=rvU5neuIo/i72z3weduCvH6J5+auAL0GP0kKKvKhfjCJWlIUQlrX3G9dGjerwio1UE 1RgRtItMGhCZ1tv9LM7u02X3YNK66KBM1ZdpEVcWzwpLeqqq39T0KlogkMtJ4z1sydHO ABCq3ITcgkewkqy3fVvSExrw0ybiXF+O+mzOw+lbGs9ltRRfq1h8S+qbrCQMu5Cn0RUW obGAnByiDVUTxGjnHCBRakhpAzrQTuhqRZMb1/SN7DQZ+eDSyEWnJ6KxuOuKQRAUXSMZ F4Ribxmup4cZ1ncysTv7STF4PwzgiHYrkhiaXCP7blNuPpYS4Igzo/p8jIJDHr15dTjh ZRpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JoO8Nd1p; 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 d3-20020a05651233c300b0047257e1278dsi1880681lfg.559.2022.04.30.07.31.08; Sat, 30 Apr 2022 07:31:38 -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=JoO8Nd1p; 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 S234103AbiD3IPa (ORCPT + 99 others); Sat, 30 Apr 2022 04:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbiD3IPW (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.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6251A5E775 for ; Sat, 30 Apr 2022 01:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651306318; 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=JoO8Nd1pRyBOzDi/uWu6Ciirs23m9BvUd2AMtPrl/SBeUr3Ou+2a83kVZcF0IxnHQfTggM O+1hbU8wjgYB6wH2O+Hi1f4GwvmISnswCASwtPpLjgKieABYcyXcr1yUDV24ZgM7SjeWMh EppknT900PDxxciyOROZh7N7PS4mD4g= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-538-erVI-K63Oka7mikzWL4cYw-1; Sat, 30 Apr 2022 04:11:56 -0400 X-MC-Unique: erVI-K63Oka7mikzWL4cYw-1 Received: by mail-ej1-f70.google.com with SMTP id i14-20020a17090639ce00b006dabe6a112fso5376726eje.13 for ; Sat, 30 Apr 2022 01:11:56 -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=OETaQ5/Y37zyTOSThtA2xK6MYQ7QVWa6AnO4Y3I1+Z5MrtHXpNxiqDvuzANgsnFBIb Yon1ptRRC96MEwbRMjEEKvvjSBZr1tNt4lmX251FFFoSjy2U6u6QBlvBPxI+7nmWKhos HvacehBhQDGJFYWYYacGA4tagtx/9f10WAKC15b7Wy8P0daOaTQmX9cD+V9fgKvC2IWz u306oaoSBApNndNlzBA3b6KMiR6idADki4CMVG9gfnRMjU3JRYQIFL4OXPHmOhkTdehc yy3YnqFqE8mm0EkYkQGYT5e9P4VwsxO8+GbvRQkqOGUDWtujioFlasIS1ACvyTXMeB/7 78aw== X-Gm-Message-State: AOAM532vD5I7BqHe2KT53Opy/+nCXJQbvvTgt3gG33c0pNnlq8O7ifTo VwXU/spkKYQXwTzSXsGl7BE5ecx8XjXmhNRZi9yoK9G2AddwzR3NxK7Li9iQGs1QtxyFNRlBkS9 3hYa+kYDh9SUu36TxFU4KjYkv X-Received: by 2002:aa7:db48:0:b0:425:f93a:de5b with SMTP id n8-20020aa7db48000000b00425f93ade5bmr3394987edt.169.1651306315651; Sat, 30 Apr 2022 01:11:55 -0700 (PDT) X-Received: by 2002:aa7:db48:0:b0:425:f93a:de5b with SMTP id n8-20020aa7db48000000b00425f93ade5bmr3394976edt.169.1651306315380; Sat, 30 Apr 2022 01:11:55 -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 mm30-20020a170906cc5e00b006f3ef214e06sm1394863ejb.108.2022.04.30.01.11.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Apr 2022 01:11:54 -0700 (PDT) Message-ID: <327afdf9-357f-71c7-fd45-56aa41aeb134@redhat.com> Date: Sat, 30 Apr 2022 10:11:53 +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