Received: by 10.223.164.200 with SMTP id h8csp922573wrb; Mon, 6 Nov 2017 01:01:54 -0800 (PST) X-Google-Smtp-Source: ABhQp+RIEbmWquYVUXcPJRrpQ1seRj/BR1rzBWwzLEV/m/gaJrtCH9T3luuPs43aGdGkHGIFv9z/ X-Received: by 10.159.211.11 with SMTP id bc11mr13965896plb.187.1509958914613; Mon, 06 Nov 2017 01:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509958914; cv=none; d=google.com; s=arc-20160816; b=dT76uHLjJ4e0g90i/7WPuidzw1toxvVo+zr1TrDuCE0o66Eq+oZ/PP3rgYWT4ub+Ls aBFXC0Tp98A1XF5EkGGl0CT7nDmNouCusOt56CxyWXbZXotsNIdmYK9SASVVpNaS//r0 gecNSrlNBeeywHJ8UPOgQ78OFjVycRj57c5L+9I9Sr/i8iNDNW3FV6DdFtt6jrbGICZu Lv2jiP9G+7aGuJ1rY7Kpie6eDwwERKYHNwV7BZnoiR+iLhpLaEynC6gvC+ZS8rEs5Dn+ tOr/InpilsZZypifIU12wKz9NqCxtV/5uQxWl52IuBubZQDJ/od0YYEpCygeUApFohLJ YlFw== 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=RWwHpg/Ts30eobD2e//6APSsRFyIWIzQJakPNzyxnSs=; b=XAXiYRxVTSzlzg8SLSZDpMYQpQVnC6u3Aw88ICu7t0WjXSwwQ69R8uK2lzXyLec2Az t4sMh92Nbe/1q7/2FqZNELZwdo4BC6qC931KL9d4WC3H+2PCaeejy1oDMC2/F5+bH2kh u1MZQA6RqHZvj/1HxrGUVinAEfNcVPRiUM6E2ZzaIBanWDv1dBDS/ZWcS43vPA2OaQLW xwBt/iNHMUg3x+qPDLiwGiBfIWccyYX2bNysTqjW+1lkOSujn7CEWtuxoNGhAGTtzEE4 yb/7WeEdzOtxF0Kgnbgz6pLRhelnit0HdzhrvOw5FWQkwQ4S+G8mQ27NgBCB38OmaIFU nkqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AEsUZ6TS; 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 b14si9949353plk.487.2017.11.06.01.01.40; Mon, 06 Nov 2017 01:01:54 -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=AEsUZ6TS; 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 S1752606AbdKFJAR (ORCPT + 98 others); Mon, 6 Nov 2017 04:00:17 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:46029 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752503AbdKFJAN (ORCPT ); Mon, 6 Nov 2017 04:00:13 -0500 Received: by mail-qk0-f193.google.com with SMTP id f199so10017744qke.2; Mon, 06 Nov 2017 01:00:13 -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=RWwHpg/Ts30eobD2e//6APSsRFyIWIzQJakPNzyxnSs=; b=AEsUZ6TSdr5Gr8YkcwWrEAkEgRsqwEdkrdUOja1zDirBM4JfLRX8l2wVVyZRvzJMnx pAh2WA7EVvihAvACdo3SkFSbI5cb1woPha+d24et3Opq15gY40BBXTzQdJvv/FoWC/lm mYQeDfGnb/ahEOyaOgrQzhA3YDqayZAHj6M0QVY9oMm2wYA5jxs0EmwnOaoQrohHOBuC PMYC8mQ0FQ6zdgv7HKmyUOHUtyuspVAo3zuQkt/llG5p8Mwt7a24WMwrT8a9V2c2AIIl r7y3hwtOasrFnVwHzX4b9E0P01WIQSU9S1zzIJJTws8eDteYIB+rZqC/FYPEUZvzJVDk cO1A== 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=RWwHpg/Ts30eobD2e//6APSsRFyIWIzQJakPNzyxnSs=; b=YqbQAq2OYr3OiUGQTnHfmA/6WrpprxdOGMzkjzVa1qQhDuqqmGWjcss3Rd6OCPN8B4 hr1NMGlUPk9sGlZwjWy8IWzJmbGvbGTO776gm58B8GVptEq/XOk+jpKVTZABxbZGgmq5 HLF6d5un5WnoLLgp3Nqr4n95/WgNRLIVDwTRO9H4qKH0TLfI2+LjxdsyQkZt9xyqsXb+ 7pbzgCmBZLaZE2mXx26KN5GFjqDSnSVmGWpNmBBdzcE58Zc6r9DdZESo+iBfWSnBBZKy GlxbrVHGOhrqO402MDDfSWjhDlpmz/RbDn2NouuRhmIgMod53S8sncVoLLxeJEYsCXkc 56HA== X-Gm-Message-State: AMCzsaUuNfL+GEzeEGkIOqMGfR4d7SN1HB6K8tedc8e3GCdyG2hhz1Vx ShIPWo/5Y9LXKHXxfQsWdbM= X-Received: by 10.55.184.71 with SMTP id i68mr19568175qkf.150.1509958812636; Mon, 06 Nov 2017 01:00:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:12 -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 41/51] selftest/vm: introduce two arch independent abstraction Date: Mon, 6 Nov 2017 00:57:33 -0800 Message-Id: <1509958663-18737-42-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 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 d521f53..30755be 100644 --- a/tools/testing/selftests/vm/pkey-helpers.h +++ b/tools/testing/selftests/vm/pkey-helpers.h @@ -301,3 +301,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 1a14027..19ae991 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 From 1584955083550997535@xxx Fri Nov 24 13:42:35 +0000 2017 X-GM-THRID: 1584680927621956878 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread