s390/uv: Always return 0 from s390_wiggle_split_folio() if successful
authorDavid Hildenbrand <david@redhat.com>
Fri, 16 May 2025 12:39:45 +0000 (14:39 +0200)
committerClaudio Imbrenda <imbrenda@linux.ibm.com>
Wed, 28 May 2025 12:13:25 +0000 (14:13 +0200)
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>
Link: https://lore.kernel.org/r/20250516123946.1648026-3-david@redhat.com
Message-ID: <20250516123946.1648026-3-david@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
arch/s390/kernel/uv.c

index 2cc3b599c7fe334f815fcb42a431dba7da0cb53a..f6ddb2b54032e64f3cca879d3650ea5958a0a3de 100644 (file)
@@ -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;
        }