linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Brendan Jackman <jackmanb@google.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Shuah Khan <shuah@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Brendan Jackman <jackmanb@google.com>
Subject: [PATCH v4 12/12] selftests/mm/mlock: Print error on failure
Date: Tue, 11 Mar 2025 13:18:23 +0000	[thread overview]
Message-ID: <20250311-mm-selftests-v4-12-dec210a658f5@google.com> (raw)
In-Reply-To: <20250311-mm-selftests-v4-0-dec210a658f5@google.com>

It's not really possible to start diagnosing this without knowing the
actual error.

Also update the mlock2 helper to behave like libc would by setting errno
and returning -1.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 tools/testing/selftests/mm/mlock-random-test.c | 4 ++--
 tools/testing/selftests/mm/mlock2.h            | 8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/mlock-random-test.c b/tools/testing/selftests/mm/mlock-random-test.c
index 1cd80b0f76c33f04ef01f4dee6602f28b6a7c991..b8d7e966f44c67e5606d384bd660e5a4e5e8fda9 100644
--- a/tools/testing/selftests/mm/mlock-random-test.c
+++ b/tools/testing/selftests/mm/mlock-random-test.c
@@ -161,9 +161,9 @@ static void test_mlock_within_limit(char *p, int alloc_size)
 				       MLOCK_ONFAULT);
 
 		if (ret)
-			ksft_exit_fail_msg("%s() failure at |%p(%d)| mlock:|%p(%d)|\n",
+			ksft_exit_fail_msg("%s() failure (%s) at |%p(%d)| mlock:|%p(%d)|\n",
 					   is_mlock ? "mlock" : "mlock2",
-					   p, alloc_size,
+					   strerror(errno), p, alloc_size,
 					   p + start_offset, lock_size);
 	}
 
diff --git a/tools/testing/selftests/mm/mlock2.h b/tools/testing/selftests/mm/mlock2.h
index 4417eaa5cfb78ba2bb0f51d3418c9b768ff0fe90..81e77fa41901a095cc041e05d01da7dffbf2f4fe 100644
--- a/tools/testing/selftests/mm/mlock2.h
+++ b/tools/testing/selftests/mm/mlock2.h
@@ -6,7 +6,13 @@
 
 static int mlock2_(void *start, size_t len, int flags)
 {
-	return syscall(__NR_mlock2, start, len, flags);
+	int ret = syscall(__NR_mlock2, start, len, flags);
+
+	if (ret) {
+		errno = ret;
+		return -1;
+	}
+	return 0;
 }
 
 static FILE *seek_to_smaps_entry(unsigned long addr)

-- 
2.49.0.rc0.332.g42c0ae87b1-goog



      parent reply	other threads:[~2025-03-11 13:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 13:18 [PATCH v4 00/12] selftests/mm: Some cleanups from trying to run them Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 01/12] selftests/mm: Report errno when things fail in gup_longterm Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 02/12] selftests/mm: Skip uffd-stress if userfaultfd not available Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 03/12] selftests/mm: Skip uffd-wp-mremap " Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 04/12] selftests/mm/uffd: Rename nr_cpus -> nr_parallel Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 05/12] selftests/mm: Print some details when uffd-stress gets bad params Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 06/12] selftests/mm: Don't fail uffd-stress if too many CPUs Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 07/12] selftests/mm: Skip map_populate on weird filesystems Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 08/12] selftests/mm: Skip gup_longterm tests " Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 09/12] selftests/mm: Drop unnecessary sudo usage Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 10/12] selftests/mm: Ensure uffd-wp-mremap gets pages of each size Brendan Jackman
2025-03-11 13:18 ` [PATCH v4 11/12] selftests/mm: Skip mlock tests if nobody user can't read it Brendan Jackman
2025-03-11 13:18 ` Brendan Jackman [this message]

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=20250311-mm-selftests-v4-12-dec210a658f5@google.com \
    --to=jackmanb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=dev.jain@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=shuah@kernel.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