Received: by 10.223.185.116 with SMTP id b49csp1382096wrg; Wed, 21 Feb 2018 18:01:52 -0800 (PST) X-Google-Smtp-Source: AH8x227MkU7Py8ldXq9FkLjQTvu6TAy+NhlB85rtD23barQmAGZZpmMp/6h7DXxzsSTQD/1DmSER X-Received: by 10.98.79.90 with SMTP id d87mr5199089pfb.41.1519264912648; Wed, 21 Feb 2018 18:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519264912; cv=none; d=google.com; s=arc-20160816; b=vdpWPqWSKkWQibMvGVBNffZn6CH3hwoD906k8uSUZczLqvWZFQrFIvXb/VqfSpSa2s WCyxS4Lg4S/1bXKpih1ZOK5pOq91xiXqE/W/fF5dcY/VhQy5Nf7vS9PSIP9cJHaExWPC 4zRUSBTeS8MHS/CL+eO3Bk2ZEl/G8QqFvAk1g64VztD8LiA+QFzWTRiDJzwB7UBkg9Og Q9ku0caiSPf65zkMKt/6AOtgIBWObOpXDxBnJ4VithlMPtw0+/0BWYBYBUjRfysSIx9o rbPrCjLhhYcLVQfeaYWwTsLP4f+gEis4vLAAGeRjaOMz4pEJLRHdxzjDCSa2AknBW1Lf EYZg== 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=EEmUJHg7+SwaCTxGXrplY7GVyzGeU//nYv9U4cR4alA=; b=THGVINygi1qOLWqi5QlVE7kY4K7UMd+20lKhXphb/uFfyD81CMrEPmnjNfVUsn2Vt5 +EjvC7Tw+5N1Wi4o3oOrINjEyDaO3+LgP7IGjYfpItQNcXOQS2nWwVE6pWcEg/Zakk4u a1y4PJReHsY6QOld2da4Qeezw9fT+zQNEeNbRJmuUPzpupGiMu7wD4JTCHux8wFoZxHW iQcUgOD6ezosffwMo2LJOXoKgLYyoS9J7sAgGeAnKCT1ORULz4KEDpuHCuL57a/AHl2D q2EVTGbNL/rBEwmAWh7r8XbzPRqcyNzsE6pxp+kSKfE4QfobuJ6n9f7SgU+P50G3J9g7 pj8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bI/cqePK; 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 i66si724745pgc.445.2018.02.21.18.01.38; Wed, 21 Feb 2018 18:01:52 -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=bI/cqePK; 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 S1752052AbeBVB4r (ORCPT + 99 others); Wed, 21 Feb 2018 20:56:47 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:38515 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943AbeBVB4n (ORCPT ); Wed, 21 Feb 2018 20:56:43 -0500 Received: by mail-qt0-f193.google.com with SMTP id k13so4510381qtg.5; Wed, 21 Feb 2018 17:56:43 -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=EEmUJHg7+SwaCTxGXrplY7GVyzGeU//nYv9U4cR4alA=; b=bI/cqePKr/JBKowuXLKbBxXxLoo60HB23ZYk6nMNGCEc64HrJsleVMBHN/XAwWC5gK 2WA+FTcXTouJaWqyOZuSD0F6sU+7QPX2MeqkWQFbnKJGAz+6d3pUMZ6N1xraho3KVLO4 +IavcY+9wRNCBPIXHt/0ynCHtKUH2FB94KaBhn/TxpL9uxNWHXbMTbYoBEvZKgXBLMRx /uInDZVeQsr6awFz52nI7Jh2t3BNeKVIZldBDo1ZqANAaJfqO4M0aQv7CSSXLU4Pitaf +UQqfiR7SXYOYHgGxqtYdY2oQqZ7mj0RmoWf5J/N7uEgwjffIXtXbzy64PnTsUn5X20q bRqQ== 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=EEmUJHg7+SwaCTxGXrplY7GVyzGeU//nYv9U4cR4alA=; b=OKlyh7OUKGzi1pcnSxiY8jLQj5zeXOa8wJ7fHrRot1aunIp3UDZ0x4o0si/i96P4nC j0JSVtmZKnsiqF+9B8yzlUcftWZ/99Ha8jx3T/CPM1XW8mhyoUZjw7rrJepO11CRZFZl rp6LZsN1rUMgtzco52w/9wxTpUyoSGZF9JKhjvC2ULXi70VV1Cx2xN7kEwjbGOxna2W+ 4afUMZ2ecyMMbkQnZTM80895UkXYwBK/ZSihzOzDMMZcDuvD+wwXSbXk7eWQQ/7eE/CX 8/W1SlVEZNS298DEUQSn7ES6QfhY0DcnPRK9N+QOFESeDNjfjMmaUNVFF4D0Q0X078AO slYA== X-Gm-Message-State: APf1xPA/NSXKuX4uBeGJ2p2eVDFq4pYTVU9Sc57sZCeUpFYIT53YEMpo 5j+byFK3wdnZwwnDYVePWdA= X-Received: by 10.237.41.35 with SMTP id s32mr8094064qtd.200.1519264603007; Wed, 21 Feb 2018 17:56:43 -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 n29sm14182630qtf.18.2018.02.21.17.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 17:56:42 -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 v12 10/22] selftests/vm: introduce two arch independent abstraction Date: Wed, 21 Feb 2018 17:55:29 -0800 Message-Id: <1519264541-7621-11-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-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. cc: Dave Hansen cc: Florian Weimer 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