From patchwork Thu Jun 14 00:45:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10463089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDD65600D0 for ; Thu, 14 Jun 2018 00:47:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF68628988 for ; Thu, 14 Jun 2018 00:47:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A374328BA8; Thu, 14 Jun 2018 00:47:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4902428988 for ; Thu, 14 Jun 2018 00:47:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F7516B0276; Wed, 13 Jun 2018 20:47:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 081506B0278; Wed, 13 Jun 2018 20:47:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8C976B0279; Wed, 13 Jun 2018 20:47:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id BB9C56B0276 for ; Wed, 13 Jun 2018 20:47:09 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id k83-v6so3577082qkl.15 for ; Wed, 13 Jun 2018 17:47:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=OC8b4rVjUTd56ZG7512Qe86UyCO/IKIIUH/nVlsH5m8=; b=GmiBtH7bcfo0P25G4kcUKfM+Wi+enIhqBSEq6RZk5p9p06QOtqZ5m28pUGjDQ9ApYN Ma8EqadmnIQHJf58KYyuhIVcbuW4vXqSZ4gSlqWZt99Vgj966xiF8x5870IiPIWIp+Rz HcVFgVM+cG5ebM0Vd7nPEYjDXJMlff6ec93cwds3JF6POdx2JfnFaZkOHyUCj7bwq4tC hP8DeT6eCV59jI26cIkaQIwJAZjKigZYZ0ZpbZtiY+f/nHmtmfjxZbC+ooRFCTFbzhTf LShl+Gtnbbf5Tjv04gEQLSXTwu7UVpWGwW5c6y/HJ6Th6w6yx9A4H/g7sanJ3PLKX5AG Bw/g== X-Gm-Message-State: APt69E1ksprI+y5nK4u6cr/zHhgbd++U+zZOLCee2EAqW86WOYBLoZvo gRUx8Ke+w4Pxa4rgznQvuYLV3KgxvPl/ul6gJGO1KFUKHFLfH73UwAwVf4KlqJj5DCC1VJbiaq3 FLEqZatG50agoM+yCq5Ec3UhDj2l267Gdj5Bo1nFygVCpDxJz2YM3s6Atr0lbFVmHcT8gci2IFU d7p5H1CNMcI5LEYVaVa56jJR0ad3BH+51CKyeN3TQ5MJ2ZuETNBqIzoio6WXJ4nBqGziyOphSc1 NcLUUJajrSdeaJF6FBpadVzy3ISFhDLwY8byP9Exd4sISa35QHvnd/jnhikMkwW9l4rnPoNsqVo TsBJUB0HcOipphc3u+vGfGqmcj+4Ig02MSN2FarkZOkZDa/RUdEDfih+WhPzsCjjHkndsiK/nw= = X-Received: by 2002:ac8:316e:: with SMTP id h43-v6mr395099qtb.146.1528937229561; Wed, 13 Jun 2018 17:47:09 -0700 (PDT) X-Received: by 2002:ac8:316e:: with SMTP id h43-v6mr395071qtb.146.1528937228822; Wed, 13 Jun 2018 17:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528937228; cv=none; d=google.com; s=arc-20160816; b=rJwyvhkxq6jFRa56xKu5NkpkNsnU1xNYGGrz23t2Y7hxrcAOoLrZVK1f0pM6U5UqX8 uKwIv4nmHB4QRloHmlA/DgntV2IYtE70deJ0v7M+mQE/k0yP2eg23AD4hSKOxkDE54b/ 8Fd29nqHip6G89jLVSirgoWWHN0PyPWVm1NYY7Ds5vgnRX6CleSBUfNYjdYBe/PZZj+R Bg0OCCVNruQEi/m3ElnhuaHtqc9rKa/3owhsf3GxQNgMLLeEmr53RaKdiuHE8Pu5zMTs R6WgScQPHDPSdNKHVQhSAsZzpxHQpfZ9rh/Wsq7FxIb5f3zReqSk8COb7uGE7CARm8Af OT/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature:arc-authentication-results; bh=OC8b4rVjUTd56ZG7512Qe86UyCO/IKIIUH/nVlsH5m8=; b=sAokcMKAUQv9UL/k6SGEwzJCxPmzwvJjgwSZncNDfmPZHq6HGi+DYyScgskHYN+eH0 b4lU8ahK3/tsbotUwcg2VUxBGtMHPQBIeL7Z8ZjZnEvrHVcJ8EdiKsYelcVQHbjMSRBR Ho+SwxDHkeJtol7a49GP4X2Rw96WdmUxD3g7PnsDv7sEUBRNrT6jDzvsAiuKBW1ZZE3m 6k2LWYjn2CKWk+0FcKbdUCjSp3NVWM9HigXSxhDMJpYimAsLS/ETCSYWXRExriMWAKVr gkrZnyYS87768KLQF3oOYaSoQsHV9HIpwFVdIIOy8ElH6ANtxMtzA6VPHi9bgFSVjNvT VYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OjyGJpQp; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a27-v6sor2281041qte.19.2018.06.13.17.47.08 for (Google Transport Security); Wed, 13 Jun 2018 17:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OjyGJpQp; spf=pass (google.com: domain of ram.n.pai@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ram.n.pai@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com 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=OC8b4rVjUTd56ZG7512Qe86UyCO/IKIIUH/nVlsH5m8=; b=OjyGJpQpd/w/NtTdmhPK6ul8FaHd6ubKGmSu5ntbB0bF14CG/VfjSQh60B6IlFVU5N jXXiTrjZtbPmUeN4T3wcHHzbR/+cKVSEsoF9Mg1kr/JmE4oU8HCbq6PSCBvhIBXNLid5 KfJ6OnSW5TYj9DLtaodY4yl1M20GV5gaigWNQ+WSNdNwdepcq6n1FBK+jtpPKBWXUUQt JLV1KrN1G+zudk4RCteEqEiWAkT1M9QFPlB7f4n5SuF/O3LscSY696+KOdvx0fXIDK/I vBg+pfpIRo6vdAqjM54UEJkGEfyeljAPYWrg3HOrZWsjK3LJG4pwaHmeJXs+hfhRDHkN JtDg== X-Google-Smtp-Source: ADUXVKL9mqM3ZMW1aUzGiKT7A6cMzvIUphySS+jsy5UM9OBYmR5WQZtCDoEOYuGWDP+jzoSa6VRRmQ== X-Received: by 2002:ac8:16b3:: with SMTP id r48-v6mr358531qtj.273.1528937228597; Wed, 13 Jun 2018 17:47:08 -0700 (PDT) Received: from localhost.localdomain (50-39-100-161.bvtn.or.frontiernet.net. [50.39.100.161]) by smtp.gmail.com with ESMTPSA id u31-v6sm3225898qtc.28.2018.06.13.17.47.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:47:08 -0700 (PDT) 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, mingo@redhat.com, dave.hansen@intel.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, linuxram@us.ibm.com, fweimer@redhat.com, msuchanek@suse.de, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v13 12/24] selftests/vm: introduce two arch independent abstraction Date: Wed, 13 Jun 2018 17:45:03 -0700 Message-Id: <1528937115-10132-13-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> References: <1528937115-10132-1-git-send-email-linuxram@us.ibm.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP open_hugepage_file() <- opens the huge page file get_start_key() <-- provides the first non-reserved key. cc: Dave Hansen cc: Florian Weimer Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann Reviewed-by: Dave Hansen --- tools/testing/selftests/vm/pkey-helpers.h | 10 ++++++++++ tools/testing/selftests/vm/pkey-x86.h | 1 + tools/testing/selftests/vm/protection_keys.c | 6 +++--- 3 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 ada0146..52a1152 100644 --- a/tools/testing/selftests/vm/pkey-helpers.h +++ b/tools/testing/selftests/vm/pkey-helpers.h @@ -179,4 +179,14 @@ static inline void __pkey_write_allow(int pkey, int do_allow_write) #define __stringify_1(x...) #x #define __stringify(x...) __stringify_1(x) +static inline int open_hugepage_file(int flag) +{ + return open(HUGEPAGE_FILE, flag); +} + +static inline int get_start_key(void) +{ + return 1; +} + #endif /* _PKEYS_HELPER_H */ diff --git a/tools/testing/selftests/vm/pkey-x86.h b/tools/testing/selftests/vm/pkey-x86.h index 2b3780d..d5fa299 100644 --- a/tools/testing/selftests/vm/pkey-x86.h +++ b/tools/testing/selftests/vm/pkey-x86.h @@ -48,6 +48,7 @@ #define MB (1<<20) #define pkey_reg_t u32 #define PKEY_REG_FMT "%016x" +#define HUGEPAGE_FILE "/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages" static inline u32 pkey_bit_position(int pkey) { diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index c5f9776..9afe894 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -791,7 +791,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; @@ -1078,10 +1078,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;