From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 601371FC7D2 for ; Mon, 26 May 2025 12:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748261408; cv=none; b=OhUtJUeLXDCUIgUJSBOPAuHP1Lp1OSUlacAO88tCEMOL5inXhHsbvvHg/0i2GGUKCzfF5100jtMPvRHnvOwq+kkASJMikvgB1WrExP6VHeG48mjrktr5cwuIHCQHlCvzIsTVBOUX3kuRJqqfkhDN5nfBwvXeceipLRm00gJ8xD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748261408; c=relaxed/simple; bh=moF0IQ2rO67KpCSP6WDey4hHJ1Upq3MjGmq9ovgCilU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=B3RlhdcHV6aFOGQuc33AlH/y5bESM8bNdi8Fd/0jCI4aFHyzV6Tpx+xfe7fLH+5ApAg9jZ2OC2NiZSDJbj63M+LezSl4AWJ782/+TDc4coDBrjIyKubBmAMk0TGJlVGPML4LtlNNSKxmyVZkMSudY3WejCk/uPhFx5ViKZemVQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YDSUbvmN; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YDSUbvmN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748261405; 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:autocrypt:autocrypt; bh=2Wk87Cm7jjBBm8iiBlCN+GurF/4VqzUoHWzk9TpnoUU=; b=YDSUbvmNkUU6wg513O6EbQP8hz9jFy/J3DITAlr1N/0RRzFaWnt0S11A1p+9PbkcBQcaxf O6JrGwi3p6GiIVEhxkxBeIeuYxKwlY1c4ZZIFeJCK+ZhBn6hVLQCnm3LSi/vN5gXobCJwP 3ioFqCwSB5b4ihRg7uSIh9wNrTCp4PE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-oBewJTVZOtaMYWVseQXjHg-1; Mon, 26 May 2025 08:10:03 -0400 X-MC-Unique: oBewJTVZOtaMYWVseQXjHg-1 X-Mimecast-MFC-AGG-ID: oBewJTVZOtaMYWVseQXjHg_1748261403 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43e9b0fd00cso11365925e9.0 for ; Mon, 26 May 2025 05:10:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748261403; x=1748866203; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=2Wk87Cm7jjBBm8iiBlCN+GurF/4VqzUoHWzk9TpnoUU=; b=YxdGtj7Dl0ijIbcofkFEIutjN5HGXwzMeCcapKZ+YP8KnOvy8JYskRq4RIbufVDapH +wLPRKlXWu/5BPAKj4ij2gCd37yHplkH+EqVvY1Xui92yA41cijaj4Jw3BP3Wpdg42eu LiE+xG6G7QaCAdyL0DxfwxLm7lo6XlE35v0sa23DRjnexXS+CfwZ1H8tyNkLIXtAnazt IoeO7I2qU/c8g7/B9GW43O26S6BOJLDSfcih56/KGQt23ehmAWsB7q5zYY57U5/hdYXO GVUpNg+EqzWz2r+JJ8V9EVzKw+36slHr6y75y48mZveF8TcY0bLs0JtEB6HObP+hRdie 6VOg== X-Forwarded-Encrypted: i=1; AJvYcCUoSGPLl+MJwW5d+qLFE6EBvVhcrCdRjTpPblUuUaTFqYQ45ub3EfNLahTEQjjH8ErH8Fw=@vger.kernel.org X-Gm-Message-State: AOJu0YxisRMgD8h0b4IuY9qkpWeF1BnMg3oZ2AwG2LSSfoqzhjNtZEM6 VVHnE6x7r+i0c8b1ntom0RbgrJbQAN44k90PxXjCZcC2FBMm0fNivQTCFYOb/rFCxH25MUMJWmm w10PtdOVJkv7zSTkhO9Y1iFuHbyxhLj1ItKIN0qjD7uK49nskvo/dkw== X-Gm-Gg: ASbGnctZfXKptzkdWKHeRIFp1lQz30fRpC/qLmoFHAsrpIuO4G8lOpWBusUIrrC5ueh qsBQ36UtdNWDiULcwIoVI/EbP0N+hyGXauPUGxKRPi4G1VSca44zzI5lNa6PX1focjHM/v6fD9U WlfSgFizXmONebBa6z/jkhbyowMsmJ72PDJ/3K6PYp9g7U9qR8PpBGkxlERRISg6y7GFu4nKPji D4BNgPnU0XLNmlIFonc+YsO9jWg+AiGbjfGPjZbtu2NyflvF+Bkg+N5+rAwBtCJgh/2OBJtK25G xnp4gj9FDiIfxUDKJN03he+AVkHnNPM4nM0fBD4mDUQ= X-Received: by 2002:a05:600c:3588:b0:442:f904:1305 with SMTP id 5b1f17b1804b1-44c7aa382c7mr80905445e9.6.1748261402624; Mon, 26 May 2025 05:10:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuXOWKXwKh3t9jsw1KbvqY/91/N1BDZCPncjgfrfmKEI0om76KSci+fI8LxzWcVgWgV7QZGQ== X-Received: by 2002:a05:600c:3588:b0:442:f904:1305 with SMTP id 5b1f17b1804b1-44c7aa382c7mr80905135e9.6.1748261402211; Mon, 26 May 2025 05:10:02 -0700 (PDT) Received: from [192.168.3.141] (p57a1aec8.dip0.t-ipconnect.de. [87.161.174.200]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-447f23bfd54sm244727325e9.17.2025.05.26.05.10.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 May 2025 05:10:01 -0700 (PDT) Message-ID: Date: Mon, 26 May 2025 14:10:00 +0200 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 10/10] ram-block-attribute: Add more error handling during state changes To: Chenyi Qiang , Alexey Kardashevskiy , Peter Xu , Gupta Pankaj , Paolo Bonzini , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , Michael Roth Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Williams Dan J , Zhao Liu , Baolu Lu , Gao Chao , Xu Yilun , Li Xiaoyao References: <20250520102856.132417-1-chenyi.qiang@intel.com> <20250520102856.132417-11-chenyi.qiang@intel.com> <6b5957fa-8036-40b6-b79d-db5babb5f7b9@redhat.com> <1674a16c-e4fb-4702-a21d-9c4923528b2f@intel.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qa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xDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <1674a16c-e4fb-4702-a21d-9c4923528b2f@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 26.05.25 12:19, Chenyi Qiang wrote: > > > On 5/26/2025 5:17 PM, David Hildenbrand wrote: >> On 20.05.25 12:28, Chenyi Qiang wrote: >>> The current error handling is simple with the following assumption: >>> - QEMU will quit instead of resuming the guest if kvm_convert_memory() >>>    fails, thus no need to do rollback. >>> - The convert range is required to be in the desired state. It is not >>>    allowed to handle the mixture case. >>> - The conversion from shared to private is a non-failure operation. >>> >>> This is sufficient for now as complext error handling is not required. >>> For future extension, add some potential error handling. >>> - For private to shared conversion, do the rollback operation if >>>    ram_block_attribute_notify_to_populated() fails. >>> - For shared to private conversion, still assert it as a non-failure >>>    operation for now. It could be an easy fail path with in-place >>>    conversion, which will likely have to retry the conversion until it >>>    works in the future. >>> - For mixture case, process individual blocks for ease of rollback. >>> >>> Signed-off-by: Chenyi Qiang >>> --- >>>   system/ram-block-attribute.c | 116 +++++++++++++++++++++++++++-------- >>>   1 file changed, 90 insertions(+), 26 deletions(-) >>> >>> diff --git a/system/ram-block-attribute.c b/system/ram-block-attribute.c >>> index 387501b569..0af3396aa4 100644 >>> --- a/system/ram-block-attribute.c >>> +++ b/system/ram-block-attribute.c >>> @@ -289,7 +289,12 @@ static int >>> ram_block_attribute_notify_to_discard(RamBlockAttribute *attr, >>>           } >>>           ret = rdl->notify_discard(rdl, &tmp); >>>           if (ret) { >>> -            break; >>> +            /* >>> +             * The current to_private listeners (VFIO dma_unmap and >>> +             * KVM set_attribute_private) are non-failing operations. >>> +             * TODO: add rollback operations if it is allowed to fail. >>> +             */ >>> +            g_assert(ret); >>>           } >>>       } >>> >> >> If it's not allowed to fail for now, then patch #8 does not make sense >> and should be dropped :) > > It was intended for future extension as in-place conversion to_private > allows it to fail. So I add the patch #8. > > But as you mentioned, since the conversion path is changing, and maybe > it is easier to handle from KVM code directly. Let me drop patch #8 and > wait for the in-place conversion to mature. Makes sense. I'm afraid it might all be a bit complicated to handle: vfio can fail private -> shared conversion and KVM the shared -> private conversion. So recovering ... will not be straight forward once multiple pages are converted. > >> >> The implementations (vfio) should likely exit() instead on unexpected >> errors when discarding. > > After drop patch #8, maybe keep vfio discard handling as it was. Adding > an additional exit() is also OK to me since it's non-fail case. > >> >> >> >> Why not squash all the below into the corresponding patch? Looks mostly >> like handling partial conversions correctly (as discussed previously)? > > I extract these two handling 1) mixture conversion; 2) operation > rollback into this individual patch because they are not the practical > cases and are untested. > > For 1), I still don't see any real case which will convert a range with > mixture attributes. Okay. I thought we were not sure if the guest could trigger that? I think it would be better to just include the "mixture" handling in the original patch. > > For 2), current failure of memory conversion (as seen in kvm_cpu_exec() > ->kvm_convert_memory()) will cause the QEMU to quit instead of resuming > guest. Doing the rollback seems useless at present. Makes sense. -- Cheers, David / dhildenb