Received: by 10.223.176.46 with SMTP id f43csp3258982wra; Mon, 22 Jan 2018 10:58:35 -0800 (PST) X-Google-Smtp-Source: AH8x226iMS6ewFWXPx98b6ofSEmiyGkp5RtvJRwXPMgr4BnHabrcKKi04la94dfzd5wH9Nws7YJQ X-Received: by 10.36.83.1 with SMTP id n1mr9485368itb.96.1516647515765; Mon, 22 Jan 2018 10:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516647515; cv=none; d=google.com; s=arc-20160816; b=aQcjBFLOIfDPk9tBwl7LeHUi0FwjV09B0Ml8GF1c2viqTaiW6vBEVNTZYUatNzItZW SMRyxMCYbfb9LurJ9KJiQPbrrjdY4pT1+mhTeuH4ydkhWebLAln+FJyB2pnPeX54122I aID84imVSu1uwBZ6Ax6QxGiB6Kyir8yJvdEnkjFodEmxb/uz/6eQpFhN/HB38zD+D42S eIfWiVlZZhmap/340vWKuv7wBTgJAMCPv5AZDhWIcBttT1b7reoKknK1hCUuceKHJG9i 6d58yaN2EgFBOdMU38WTXwEHTKiMa0HFW9ciGfC7NJuFZ7MYj8edNxJ6EHa0qwsvJ8E7 +7Tw== 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=TWlC7wUoxOfnQMPnbOE2IChF/0OQsYpDpho3CoSgRTc=; b=y40WttdIVUw4MiY//CVaKTLkCnShANmttLCoMvPwZluOSY3MOuZlKF5nE8qMJEaEHi D09CuCilzkdW8Hanjeoxdn0/BtWg7dkF2lRsIAOPIY36UtWmIlLn0ICJPSlnBGiCaRD5 XukHRlsP6wuP+kjVluAoxjK8LkTzIkKm1nzOPCqNZqHxaOraeFlStDx4LaBQPKf25hxk z6bFl+w2mQoTXoiErMAz6IEwC9FhEoWERxmuQVLpMbDVNE0xcisQUn9BdszsMtUDyQ3y cyAi0DyOXFIhyu0RDkDBtsF1u3A/65kTJuMTBYtoogRQ8qaXIMO/tElGL93pWJeVUYA8 6KxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=WGfn2XEE; 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 x5si6451126itg.122.2018.01.22.10.58.23; Mon, 22 Jan 2018 10:58:35 -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=WGfn2XEE; 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 S1751408AbeAVSxW (ORCPT + 99 others); Mon, 22 Jan 2018 13:53:22 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:38762 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbeAVSxR (ORCPT ); Mon, 22 Jan 2018 13:53:17 -0500 Received: by mail-qt0-f196.google.com with SMTP id z10so23464047qti.5; Mon, 22 Jan 2018 10:53:17 -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=TWlC7wUoxOfnQMPnbOE2IChF/0OQsYpDpho3CoSgRTc=; b=WGfn2XEEz/bkG5XNDOwwQj0qWazUWe4afibkYd/elcTE243M3pZpbNQiYrUNGzRUvg ILcPPJnSz6qG17WHBAd4vELOoXlpO+OJjCUkDce3rEUxzNW+2yL6+Xuk4uDJLKb15m/Q MRNFc8VH5nbWZkDM5I+9Sc2aUKwphiqH3D50yw/J52yVkr0I6QXMOGqOEnEzBXioEcIZ MMAe1e2HwVajoXq1LVfMgR2a7BVkZNd9msDmVtwVk/4h9zttwB19zXOXsUZoTXyhtdEi 7pOJsc3MFRgYD9dtUfCsmKYxLM0+hhZYupcMtYy4NSl5vw0WO5kgU2b87oDgTY9sKmiO 3tHg== 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=TWlC7wUoxOfnQMPnbOE2IChF/0OQsYpDpho3CoSgRTc=; b=UQ8L25cqSWKJxjHnRSa2q4z0/OK034Epj2NUywN6RC16IqKlQMehyRSzbA68NieeAR coAVy5pWXQEH35V/VPwOnOsle13nkzg5JKRy8E/zi90xFaHHsrkjhr7W7TZaFZNdQW5F TULrS+q6U7S+XNVyWD+FVSdmGlpNdz91BapiSYD/BRf33+N3k164fnAml9dsWbd40thF 8ZEFPMUbSwDiscELNcKj8lxy1DGeXvGEUIo099APUe9O3lsEsG/B3UEuWhYIvAJp+cKI CCvccrQm9HEOFm/OnOCDjCvSUWCZS1+DI5CTxs+I298qfkpFyNDeyZ58yIaSjTOu9NOT vXFw== X-Gm-Message-State: AKwxytd5Unl/uo086tnJ+FbPRPAEsOWZIgMtfBl2J7kDBopjz/0ShKV/ YG1SQXfF41Mk5egdiA+MiDI= X-Received: by 10.55.43.222 with SMTP id r91mr11534523qkr.309.1516647196595; Mon, 22 Jan 2018 10:53:16 -0800 (PST) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id o20sm10790061qkl.14.2018.01.22.10.53.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:53:16 -0800 (PST) From: Ram Pai To: shuahkh@osg.samsung.com, linux-kselftest@vger.kernel.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, akpm@linux-foundation.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, arnd@arndb.de Subject: [PATCH v10 10/24] selftests/vm: introduce two arch independent abstraction Date: Mon, 22 Jan 2018 10:52:03 -0800 Message-Id: <1516647137-11174-11-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1516647137-11174-1-git-send-email-linuxram@us.ibm.com> References: <1516647137-11174-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 open_hugepage_file() <- opens the huge page file get_start_key() <-- provides the first non-reserved key. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/pkey-helpers.h | 11 +++++++++++ tools/testing/selftests/vm/protection_keys.c | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/vm/pkey-helpers.h b/tools/testing/selftests/vm/pkey-helpers.h index 7c979ad..c8f5739 100644 --- a/tools/testing/selftests/vm/pkey-helpers.h +++ b/tools/testing/selftests/vm/pkey-helpers.h @@ -304,3 +304,14 @@ static inline void __page_o_noops(void) } \ } while (0) #define raw_assert(cond) assert(cond) + +static inline int open_hugepage_file(int flag) +{ + return open("/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages", + O_RDONLY); +} + +static inline int get_start_key(void) +{ + return 1; +} diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 2e4b636..254b66d 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -809,7 +809,7 @@ void setup_hugetlbfs(void) * Now go make sure that we got the pages and that they * are 2M pages. Someone might have made 1G the default. */ - fd = open("/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages", O_RDONLY); + fd = open_hugepage_file(O_RDONLY); if (fd < 0) { perror("opening sysfs 2M hugetlb config"); return; @@ -1087,10 +1087,10 @@ void test_kernel_gup_write_to_write_disabled_region(int *ptr, u16 pkey) void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) { int err; - int i; + int i = get_start_key(); /* Note: 0 is the default pkey, so don't mess with it */ - for (i = 1; i < NR_PKEYS; i++) { + for (; i < NR_PKEYS; i++) { if (pkey == i) continue; -- 1.7.1