Received: by 10.223.176.46 with SMTP id f43csp3256623wra; Mon, 22 Jan 2018 10:55:50 -0800 (PST) X-Google-Smtp-Source: AH8x224z+CrmjDUWGU6ueZ/DFoxqoARyMz348oOr7dI5g48vdZt64L6JAAqTpJFpxwA4mMPZe2FK X-Received: by 10.107.16.71 with SMTP id y68mr9642223ioi.266.1516647350407; Mon, 22 Jan 2018 10:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516647350; cv=none; d=google.com; s=arc-20160816; b=Za676cUKRAbXA7yBVB6qr/MJhdueVC87DTXORU/yIiprLcZnHs7O04fFYsl7GxAoO+ OHGXlvaHXWFszMw3pM4ePlKEfMlCZKq8lbCiLqMkmBvOigP+ROMpXWKMHC2DGlKb87D1 Lhjn8GCMgRAEzWpziGja/WHHOpnPXei9oCiABmv3fQpOhii4Wk8ln8rKhbbb+59jJo8Y xqGWWmaP7XOFZtSTJnsND6zXtp9G0SBFRpMikxVMOwj+z+3ouUpLDaXqYePhJUUDVGD0 vuyOmfxqdetemZBkV6zLMEZwc7AkH8Ngo96XDsdrPW1y62TmpgEhNJKQ1FEThkUu1Q5k EzQw== 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=pMUXcxZ9TqOqM79manQcP4oMRJUuFjP4/HFwR3/nnBk=; b=R0mVp5YdDvqGJGSBiWg16fwFfQtzOyrXzyZTnmZahAQ2/UXsWn0/qPMkl3FhRXiKkE gxFwjnmAb2aVeQHNBiDLR6PeqctuL676ufE2djmx+0rMGQwPJ9mMuO40bV8CDxUliBL0 XLG6v2VK2iVJHCyfL++MWF3INczWi3wzCLO19rHtkwuP5vw+XfkHbGCrC30MlK+IguD8 Gq5WX+QpRULBA310q7bdBJtztHN/c9lAzc0SwgFhLco7rcYhAmZRxF2OVBVeDeBVKZew BBTfDKnO1fL1HK6bQugaXn3P1c3hB/p0DxO2y+hPgX72NmMlHjFNlrtuG1LiGoTlv8lu hjjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BcN9BBc6; 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 g10si8552237ioc.239.2018.01.22.10.55.37; Mon, 22 Jan 2018 10:55:50 -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=BcN9BBc6; 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 S1751780AbeAVSyz (ORCPT + 99 others); Mon, 22 Jan 2018 13:54:55 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:41694 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbeAVSxw (ORCPT ); Mon, 22 Jan 2018 13:53:52 -0500 Received: by mail-qt0-f194.google.com with SMTP id i1so23467279qtj.8; Mon, 22 Jan 2018 10:53:52 -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=pMUXcxZ9TqOqM79manQcP4oMRJUuFjP4/HFwR3/nnBk=; b=BcN9BBc63cFMy4aw1Nr3CF1D5nwUJeBUedBv4AJ5/rslsnHchmklfyGkxoYkCYpaCj chVpuxxUfmksbXZ5qs5GBc8XF7d5iNRKIxXR/YzXAGCad2ew5P0APOvK9OzIAAY78jdm FLPuEZkiDsz4fAdB7JdVM0o6CGC3TBumi1cM8OiIal0/0fZZ64keN2TpG5vb+Ut9SqiQ 1fN2eIVwjA75aT0KbiRZIrCfUEGxmEsTi7ZIJKFN5Xa5I0rK+72XCJ0LECs7fB118H8j JopPECmQJnK2Rcfy6ufkw+vXt/0QBO7y9LGjO0D8JIZqIPQw9NXCcgaK2AW/12XYjHjp r49Q== 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=pMUXcxZ9TqOqM79manQcP4oMRJUuFjP4/HFwR3/nnBk=; b=lPXShAYou7m4eypv7COwcc7C/NRzVe+9cDQfJHJsE77un5mhUemKR8zDDR1p9uetWS WO6+PknXjw5FWPZ9mpOiJCDU6sd9HY5whQBoZ87IjokL2JZhVWuaqBegizacXXkxrvPT fpOsArMTFcmv5nHXsqjUWTxrdoRdiO1qEuIXsuBpVaWr3ZWiCqLJVgKA000+JuRwNyCn HfFhkwZgGip8COGvpwtCfbpBeKkgxqEyagcSq9Z6aOuU1VZZ0Ly/0bqBkzjWtLOk/vOu vOGveTH7PVQFD3MBgnbpCPYhgck1mDoUM3hozlOR3XwGba3pPomSxo7EX3zVyBcmFFBw 3Q6g== X-Gm-Message-State: AKwxytd8rnGZoX5yoMKMlHZ8FOSnVU6RI2zfW8KfpgGJfcXMpEcaJdjh XdSA9WcOwcX9YruemV9KZI8= X-Received: by 10.237.36.205 with SMTP id u13mr12237603qtc.135.1516647231436; Mon, 22 Jan 2018 10:53:51 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 10:53:50 -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 21/24] selftests/vm: sub-page allocator Date: Mon, 22 Jan 2018 10:52:14 -0800 Message-Id: <1516647137-11174-22-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 introduce a new allocator that allocates 4k hardware-pages to back 64k linux-page. This allocator is only applicable on powerpc. Signed-off-by: Ram Pai --- tools/testing/selftests/vm/protection_keys.c | 30 ++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index 5783587..ae71dad 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -766,6 +766,35 @@ void free_pkey_malloc(void *ptr) return ptr; } +void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +{ +#ifdef __powerpc64__ + void *ptr; + int ret; + + dprintf1("doing %s(size=%ld, prot=0x%x, pkey=%d)\n", __func__, + size, prot, pkey); + pkey_assert(pkey < NR_PKEYS); + ptr = mmap(NULL, size, prot, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + pkey_assert(ptr != (void *)-1); + + ret = syscall(__NR_subpage_prot, ptr, size, NULL); + if (ret) { + perror("subpage_perm"); + return PTR_ERR_ENOTSUP; + } + + ret = mprotect_pkey((void *)ptr, PAGE_SIZE, prot, pkey); + pkey_assert(!ret); + record_pkey_malloc(ptr, size); + + dprintf1("%s() for pkey %d @ %p\n", __func__, pkey, ptr); + return ptr; +#else /* __powerpc64__ */ + return PTR_ERR_ENOTSUP; +#endif /* __powerpc64__ */ +} + void *malloc_pkey_anon_huge(long size, int prot, u16 pkey) { int ret; @@ -888,6 +917,7 @@ void setup_hugetlbfs(void) void *(*pkey_malloc[])(long size, int prot, u16 pkey) = { malloc_pkey_with_mprotect, + malloc_pkey_with_mprotect_subpage, malloc_pkey_anon_huge, malloc_pkey_hugetlb /* can not do direct with the pkey_mprotect() API: -- 1.7.1