Received: by 10.223.164.200 with SMTP id h8csp927723wrb; Mon, 6 Nov 2017 01:07:47 -0800 (PST) X-Google-Smtp-Source: ABhQp+S6dLSbyvBQ6UjngBlUdbcqdP+0P2bK8F0ZMzibFgdsYPLcs+nH/yrNEzespVD6+f5Bt5zF X-Received: by 10.84.163.75 with SMTP id n11mr14039311plg.287.1509959267806; Mon, 06 Nov 2017 01:07:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509959267; cv=none; d=google.com; s=arc-20160816; b=MWANmohWhDF9BbVdo4f2y0awLKnXUaVNpkt1gOJwGGosSxw4QfxVwyzhNxbBya7kJ0 Gs2cxW6jl8um/3ilrtaW1YjcxevS3k5JXib8LmVc6S6Q+T5Vk9H/e4mXFe2kcxtlsNdN Enqf2oh3Be4lRZQfqOnqgvhfZI3OcPqT57GRJ2dqpATIh2pNA1IfI6cQo//GcgiaACfv sCF0itQNrrGBJDi33vLMq4LtBYgGtgz1Gz5uL9bgatTyqgyi0vcB/MkYYLKDC4XIvyyG p2o8LlUymmgqKhBaKVYVQMFlNWVASibn6k2t4uXxavMGyj0GMUlp8XuFoyNmCanU6u2N tXVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ykZ663WQ1xhd3Yc6fBndDmWdsEbDVweOM64ri1Zv2uY=; b=mEtZ/HfagXG3D48kYRt4qJskgoK3V175ROWHb/Z55V4P7hdGbs0VQbXn+Q9X+TWE7f sekRzLGPcU5zf+ZypCkK+o+S0ZAzt32w4Nm3FcBTXTx7rEkEaDcKC7MULxWc3QtvLb38 Yc3DM7FLXNOgICpZHX7HGJWFOiHepyWnz0tyP+TujknEEwTuVz/8tu5IzkcQmyWNbAWi S3o/xSvZBieHjmJrFdv0dCXtBX7q+QHST78qxRzkU19Mcmlnf9HqmFKHNGYvHnI+dvyu wcPs3X5YtDTPwCnw2TzXxE9JO3ZZ0Hwq/eBCDN7cbl9qvyiCyd2lYFnXQfGzxk7wPsHw v4gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Lwnv5Mxc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si9819498plz.636.2017.11.06.01.07.34; Mon, 06 Nov 2017 01:07:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Lwnv5Mxc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbdKFJGh (ORCPT + 98 others); Mon, 6 Nov 2017 04:06:37 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:50985 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752350AbdKFJAK (ORCPT ); Mon, 6 Nov 2017 04:00:10 -0500 Received: by mail-qk0-f193.google.com with SMTP id o187so10010287qke.7; Mon, 06 Nov 2017 01:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ykZ663WQ1xhd3Yc6fBndDmWdsEbDVweOM64ri1Zv2uY=; b=Lwnv5MxcQlaiz+Wv+KJ40f2nSef5q7sbKNtrUL7E+4YKWf0HAGSVM5O10xo3O7rkLE lgOPQc4mksEA0GiX2EzivuTFJvk1paWPVe07+fw+gkO/BY8uYYvb0u144MFhNnYilA1M 7kmhU8oHSlxCcj+sFR+NWuVn4K8uzELsx7SnN7NnoSERiklazigzHcUrumuOmtasyiJJ Or1Wa3S9lUgV2ZbVWKWMC/cKPiOL0UWdeTENG++QFcyyp/D69e/fPbs66P58GJomjiwg e9959za0IEZ6/e71at6MyR5uPnFH/Vhq9IoZf6b1uCAskOVz+/XOongMmfjpUiI4eT35 3c9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ykZ663WQ1xhd3Yc6fBndDmWdsEbDVweOM64ri1Zv2uY=; b=Yw/q6RNeorUxKJFZt9jqGUwvIRIwhgqpX6CP59ikZVC0eXePji2p55ysIEGwE5asbo pZ8FQ3Soa94PwiOobQYd05JQcUtZ9h0xX2aBt8BoIzg5vGuHsxFuBsBp8wJwzNQK/Rwq sLkxAReweHLgDHEcJqjeKeeGJTBnRd38ddHJ7rGVCMneNwGGr7PRFol7Niu/hRXYXoiy YSeJi7uihIycYoLnY7gom0FdGLnlM5/EbEgyHEY0sSDJwwjWHx1wL0euD7yu2ONkUomk E3LVb2jOa4pJFMqAOZborRAKw8rxN23npziBGbenCBnp0wtQuSm55QKOuXuibeHZebIZ uB6Q== X-Gm-Message-State: AJaThX4hQPxwIRWKcnhmkEq1MjunZRtf/slMFh+0gdG6XM6xYx+G2t3v IjoeqS2+1bcM5wMopgL4SK4= X-Received: by 10.55.42.139 with SMTP id q11mr4721378qkq.285.1509958810064; Mon, 06 Nov 2017 01:00:10 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.01.00.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:09 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com Subject: [PATCH v9 40/51] selftest/vm: fix alloc_random_pkey() to make it really random Date: Mon, 6 Nov 2017 00:57:32 -0800 Message-Id: <1509958663-18737-41-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. fixed it. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 2823d4d..1a14027 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -24,6 +24,7 @@ #define _GNU_SOURCE #include #include +#include #include #include #include @@ -602,13 +603,15 @@ int alloc_random_pkey(void) int alloced_pkeys[NR_PKEYS]; 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) break; alloced_pkeys[nr_alloced++] = new_pkey; @@ -624,13 +627,14 @@ int alloc_random_pkey(void) /* go through the allocated ones that we did not want and free them */ for (i = 0; i < nr_alloced; i++) { int free_ret; + if (!alloced_pkeys[i]) continue; free_ret = sys_pkey_free(alloced_pkeys[i]); pkey_assert(!free_ret); } - dprintf1("%s()::%d, ret: %d pkey_reg: 0x%x shadow: 0x%x\n", __func__, - __LINE__, ret, __rdpkey_reg(), shadow_pkey_reg); + dprintf1("%s()::%d, ret: %d pkey_reg: 0x%x shadow: 0x%016lx\n", + __func__, __LINE__, ret, __rdpkey_reg(), shadow_pkey_reg); return ret; } -- 1.7.1 From 1583039741698772803@xxx Fri Nov 03 10:19:03 +0000 2017 X-GM-THRID: 1583039741698772803 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread