[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200629154007.2495120-73-sashal@kernel.org>
Date: Mon, 29 Jun 2020 11:38:08 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Ram Pai <linuxram@...ibm.com>,
Sandipan Das <sandipan@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dave Hansen <dave.hansen@...el.com>,
Florian Weimer <fweimer@...hat.com>,
"Desnes A. Nunes do Rosario" <desnesn@...ux.vnet.ibm.com>,
Ingo Molnar <mingo@...nel.org>,
Thiago Jung Bauermann <bauerman@...ux.ibm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>,
Michal Hocko <mhocko@...nel.org>,
Michal Suchanek <msuchanek@...e.de>,
Shuah Khan <shuah@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 4.9 072/191] selftests/vm/pkeys: fix alloc_random_pkey() to make it really random
From: Ram Pai <linuxram@...ibm.com>
[ Upstream commit 6e373263ce07eeaa6410843179535fbdf561fc31 ]
alloc_random_pkey() was allocating the same pkey every time. Not all
pkeys were geting tested. This fixes it.
Signed-off-by: Ram Pai <linuxram@...ibm.com>
Signed-off-by: Sandipan Das <sandipan@...ux.ibm.com>
Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
Acked-by: Dave Hansen <dave.hansen@...el.com>
Cc: Dave Hansen <dave.hansen@...el.com>
Cc: Florian Weimer <fweimer@...hat.com>
Cc: "Desnes A. Nunes do Rosario" <desnesn@...ux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Thiago Jung Bauermann <bauerman@...ux.ibm.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Cc: Michael Ellerman <mpe@...erman.id.au>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Michal Suchanek <msuchanek@...e.de>
Cc: Shuah Khan <shuah@...nel.org>
Link: http://lkml.kernel.org/r/0162f55816d4e783a0d6e49e554d0ab9a3c9a23b.1585646528.git.sandipan@linux.ibm.com
Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/testing/selftests/x86/protection_keys.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
index 874972ccfc95b..5338e668b5e65 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -23,6 +23,7 @@
#define _GNU_SOURCE
#include <errno.h>
#include <linux/futex.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/syscall.h>
#include <string.h>
@@ -608,10 +609,10 @@ int alloc_random_pkey(void)
int nr_alloced = 0;
int random_index;
memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
+ srand((unsigned int)time(NULL));
/* allocate every possible key and make a note of which ones we got */
max_nr_pkey_allocs = NR_PKEYS;
- max_nr_pkey_allocs = 1;
for (i = 0; i < max_nr_pkey_allocs; i++) {
int new_pkey = alloc_pkey();
if (new_pkey < 0)
--
2.25.1
Powered by blists - more mailing lists