linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	kvm@vger.kernel.org, linux-mm@kvack.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Thomas Huth <thuth@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Sebastian Mitterle <smitterl@redhat.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v1 1/3] s390/uv: don't return 0 from make_hva_secure() if the operation was not successful
Date: Fri, 16 May 2025 20:02:46 -0400	[thread overview]
Message-ID: <818174C5-0FA3-4FA2-880D-FF5C1102B2B1@nvidia.com> (raw)
In-Reply-To: <0454761b-ec54-4cc8-9d01-b783e2e58f9e@redhat.com>

On 16 May 2025, at 17:20, David Hildenbrand wrote:

> On 16.05.25 23:08, Zi Yan wrote:
>> On 16 May 2025, at 8:39, David Hildenbrand wrote:
>>
>>> If s390_wiggle_split_folio() returns 0 because splitting a large folio
>>> succeeded, we will return 0 from make_hva_secure() even though a retry
>>> is required. Return -EAGAIN in that case.
>>>
>>> Otherwise, we'll return 0 from gmap_make_secure(), and consequently from
>>> unpack_one(). In kvm_s390_pv_unpack(), we assume that unpacking
>>> succeeded and skip unpacking this page. Later on, we run into issues
>>> and fail booting the VM.
>>>
>>> So far, this issue was only observed with follow-up patches where we
>>> split large pagecache XFS folios. Maybe it can also be triggered with
>>> shmem?
>>>
>>> We'll cleanup s390_wiggle_split_folio() a bit next, to also return 0
>>> if no split was required.
>>>
>>> Fixes: d8dfda5af0be ("KVM: s390: pv: fix race when making a page secure")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>> ---
>>>   arch/s390/kernel/uv.c | 5 ++++-
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
>>> index 9a5d5be8acf41..2cc3b599c7fe3 100644
>>> --- a/arch/s390/kernel/uv.c
>>> +++ b/arch/s390/kernel/uv.c
>>> @@ -393,8 +393,11 @@ int make_hva_secure(struct mm_struct *mm, unsigned long hva, struct uv_cb_header
>>>   	folio_walk_end(&fw, vma);
>>>   	mmap_read_unlock(mm);
>>>
>>> -	if (rc == -E2BIG || rc == -EBUSY)
>>> +	if (rc == -E2BIG || rc == -EBUSY) {
>>>   		rc = s390_wiggle_split_folio(mm, folio, rc == -E2BIG);
>>> +		if (!rc)
>>> +			rc = -EAGAIN;
>>
>> Why not just folio_put() then jump back to the beginning of the
>> function to do the retry? This could avoid going all the way back
>> to kvm_s390_unpack().
>
> Hi, thanks for the review.
>
> We had a pretty optimized version with such tricks before Claudio refactored it in:
>
> commit 5cbe24350b7d8ef6d466a37d56b07ae643c622ca
> Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Date:   Thu Jan 23 15:46:17 2025 +0100
>
>     KVM: s390: move pv gmap functions into kvm
>
>
>
> In particular, one relevant hunk was:
>
> -       switch (rc) {
> -       case -E2BIG:
> -               folio_lock(folio);
> -               rc = split_folio(folio);
> -               folio_unlock(folio);
> -               folio_put(folio);
> -
> -               switch (rc) {
> -               case 0:
> -                       /* Splitting succeeded, try again immediately. */
> -                       goto again;
> -               case -EAGAIN:
> -                       /* Additional folio references. */
> -                       if (drain_lru(&drain_lru_called))
> -                               goto again;
> -                       return -EAGAIN;
>
>
>
> Claudio probably had a good reason to rewrite the code -- and I hope we'll be able to rip all of that out soon, so ...
>
> ... minimal changes until then :)

Got it. Acked-by: Zi Yan <ziy@nvidia.com>

--
Best Regards,
Yan, Zi


  reply	other threads:[~2025-05-17  0:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 12:39 [PATCH v1 0/3] s390/uv: handle folios that cannot be split while dirty David Hildenbrand
2025-05-16 12:39 ` [PATCH v1 1/3] s390/uv: don't return 0 from make_hva_secure() if the operation was not successful David Hildenbrand
2025-05-16 14:07   ` David Hildenbrand
2025-05-16 21:08   ` Zi Yan
2025-05-16 21:20     ` David Hildenbrand
2025-05-17  0:02       ` Zi Yan [this message]
2025-05-16 12:39 ` [PATCH v1 2/3] s390/uv: always return 0 from s390_wiggle_split_folio() if successful David Hildenbrand
2025-05-17  0:08   ` Zi Yan
2025-05-16 12:39 ` [PATCH v1 3/3] s390/uv: improve splitting of large folios that cannot be split while dirty David Hildenbrand
2025-05-16 17:07 ` [PATCH v1 0/3] s390/uv: handle " Claudio Imbrenda
2025-05-16 18:55   ` David Hildenbrand
2025-05-16 17:17 ` Claudio Imbrenda
2025-05-16 18:56   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=818174C5-0FA3-4FA2-880D-FF5C1102B2B1@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=smitterl@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=thuth@redhat.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox