Skip to content

Commit bd428b8

Browse files
davidhildenbrandClaudio Imbrenda
authored andcommitted
s390/uv: Always return 0 from s390_wiggle_split_folio() if successful
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Message-ID: <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Signed-off-by: Claudio Imbrenda <[email protected]>
1 parent 3ec8a83 commit bd428b8

File tree

1 file changed

+12
-10
lines changed
  • arch/s390/kernel

1 file changed

+12
-10
lines changed

arch/s390/kernel/uv.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,34 +324,36 @@ static int make_folio_secure(struct mm_struct *mm, struct folio *folio, struct u
324324
}
325325

326326
/**
327-
* s390_wiggle_split_folio() - try to drain extra references to a folio and optionally split.
327+
* s390_wiggle_split_folio() - try to drain extra references to a folio and
328+
* split the folio if it is large.
328329
* @mm: the mm containing the folio to work on
329330
* @folio: the folio
330-
* @split: whether to split a large folio
331331
*
332332
* Context: Must be called while holding an extra reference to the folio;
333333
* the mm lock should not be held.
334-
* Return: 0 if the folio was split successfully;
335-
* -EAGAIN if the folio was not split successfully but another attempt
336-
* can be made, or if @split was set to false;
337-
* -EINVAL in case of other errors. See split_folio().
334+
* Return: 0 if the operation was successful;
335+
* -EAGAIN if splitting the large folio was not successful,
336+
* but another attempt can be made;
337+
* -EINVAL in case of other folio splitting errors. See split_folio().
338338
*/
339-
static int s390_wiggle_split_folio(struct mm_struct *mm, struct folio *folio, bool split)
339+
static int s390_wiggle_split_folio(struct mm_struct *mm, struct folio *folio)
340340
{
341341
int rc;
342342

343343
lockdep_assert_not_held(&mm->mmap_lock);
344344
folio_wait_writeback(folio);
345345
lru_add_drain_all();
346-
if (split) {
346+
347+
if (folio_test_large(folio)) {
347348
folio_lock(folio);
348349
rc = split_folio(folio);
349350
folio_unlock(folio);
350351

351352
if (rc != -EBUSY)
352353
return rc;
354+
return -EAGAIN;
353355
}
354-
return -EAGAIN;
356+
return 0;
355357
}
356358

357359
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
394396
mmap_read_unlock(mm);
395397

396398
if (rc == -E2BIG || rc == -EBUSY) {
397-
rc = s390_wiggle_split_folio(mm, folio, rc == -E2BIG);
399+
rc = s390_wiggle_split_folio(mm, folio);
398400
if (!rc)
399401
rc = -EAGAIN;
400402
}

0 commit comments

Comments
 (0)