From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
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>, Zi Yan <ziy@nvidia.com>,
Sebastian Mitterle <smitterl@redhat.com>
Subject: [PATCH v1 2/3] s390/uv: always return 0 from s390_wiggle_split_folio() if successful
Date: Fri, 16 May 2025 14:39:45 +0200 [thread overview]
Message-ID: <20250516123946.1648026-3-david@redhat.com> (raw)
In-Reply-To: <20250516123946.1648026-1-david@redhat.com>
Let's consistently return 0 if the operation was successful, and just
detect ourselves whether splitting is required -- folio_test_large() is
a cheap operation.
Update the documentation.
Should we simply always return -EAGAIN instead of 0, so we don't have
to handle it in the caller? Not sure, staring at the documentation, this
way looks a bit cleaner.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
arch/s390/kernel/uv.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
index 2cc3b599c7fe3..f6ddb2b54032e 100644
--- a/arch/s390/kernel/uv.c
+++ b/arch/s390/kernel/uv.c
@@ -324,34 +324,36 @@ static int make_folio_secure(struct mm_struct *mm, struct folio *folio, struct u
}
/**
- * s390_wiggle_split_folio() - try to drain extra references to a folio and optionally split.
+ * s390_wiggle_split_folio() - try to drain extra references to a folio and
+ * split the folio if it is large.
* @mm: the mm containing the folio to work on
* @folio: the folio
- * @split: whether to split a large folio
*
* Context: Must be called while holding an extra reference to the folio;
* the mm lock should not be held.
- * Return: 0 if the folio was split successfully;
- * -EAGAIN if the folio was not split successfully but another attempt
- * can be made, or if @split was set to false;
- * -EINVAL in case of other errors. See split_folio().
+ * Return: 0 if the operation was successful;
+ * -EAGAIN if splitting the large folio was not successful,
+ * but another attempt can be made;
+ * -EINVAL in case of other folio splitting errors. See split_folio().
*/
-static int s390_wiggle_split_folio(struct mm_struct *mm, struct folio *folio, bool split)
+static int s390_wiggle_split_folio(struct mm_struct *mm, struct folio *folio)
{
int rc;
lockdep_assert_not_held(&mm->mmap_lock);
folio_wait_writeback(folio);
lru_add_drain_all();
- if (split) {
+
+ if (folio_test_large(folio)) {
folio_lock(folio);
rc = split_folio(folio);
folio_unlock(folio);
if (rc != -EBUSY)
return rc;
+ return -EAGAIN;
}
- return -EAGAIN;
+ return 0;
}
int make_hva_secure(struct mm_struct *mm, unsigned long hva, struct uv_cb_header *uvcb)
@@ -394,7 +396,7 @@ int make_hva_secure(struct mm_struct *mm, unsigned long hva, struct uv_cb_header
mmap_read_unlock(mm);
if (rc == -E2BIG || rc == -EBUSY) {
- rc = s390_wiggle_split_folio(mm, folio, rc == -E2BIG);
+ rc = s390_wiggle_split_folio(mm, folio);
if (!rc)
rc = -EAGAIN;
}
--
2.49.0
next prev parent reply other threads:[~2025-05-16 12:39 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
2025-05-16 12:39 ` David Hildenbrand [this message]
2025-05-17 0:08 ` [PATCH v1 2/3] s390/uv: always return 0 from s390_wiggle_split_folio() if successful 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=20250516123946.1648026-3-david@redhat.com \
--to=david@redhat.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.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=svens@linux.ibm.com \
--cc=thuth@redhat.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/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