Commit 1ddae9d6 authored by Brendan Jackman's avatar Brendan Jackman Committed by Andrew Morton
Browse files

selftests/mm/mlock: print error on failure

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.

Link: https://lkml.kernel.org/r/20250311-mm-selftests-v4-12-dec210a658f5@google.com


Signed-off-by: default avatarBrendan Jackman <jackmanb@google.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 5d2146a3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
	}

+7 −1
Original line number Diff line number Diff line
@@ -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)