Received: by 10.223.164.200 with SMTP id h8csp923126wrb; Mon, 6 Nov 2017 01:02:29 -0800 (PST) X-Google-Smtp-Source: ABhQp+ThdYQIT2KNBcYdvKaAVhP7Qm9ua0eRia38rz0ZJN8nuiQz6RUSJP45MVa7QbYobOE26wUO X-Received: by 10.99.160.86 with SMTP id u22mr14481420pgn.283.1509958949504; Mon, 06 Nov 2017 01:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509958949; cv=none; d=google.com; s=arc-20160816; b=oWPhIn3HD+vyfy9JNOMsv7deTBsTp0ga0KnXexnsni/NaI2aBNLxR/sL3gCSrHNr1y vjiQLajl1JjS9dZHtjMJmtjOnU5CfVg6xxrae/SCqh34xJfUm/Zn8Lum+JfBlob7Zifa rFuS33CM+ZL6jJ5AUoaG5acL8dTD4ylYvv/QeizOqoGYSS1PdkBeGfGV0YhC3OwvdcTs FolBfnVs9YHB4zrOgBkQbLGUx41OCjPRjEJ6j39M2ZtyLG5CNQkTMq46SxC6bemHoDLF V1ADMpThtkN49IEvxC9RKDbRD217ptLMbMFYZWja8jsZiHPA+7mthSKC3rSabfoPSZh+ pzpA== 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=55jjc4JBxDkFjLHU+c6h5UMRgXQ4dhHY8adg+GWI+JI=; b=S0EsFLii7Xx79A+cblWnUESMpirpfhgk8s9q9L4S29zjTRhhTSQoULkPHzVYE3a5gZ qK2a67OTIcHpQVAzHQ7gn4mNMQvWC3hEFmXEos4Wim6XlemWWAKPeQpXJC3OLM8U/QXT TI3N5U4MTXK87mT6alSJ4g+JiSZFcGOoRC8bXGizfkV6gghGko72oKv6+2BIztDbyf/6 qPTBola0RzKbLBO1oA/1zH5Jp0qRfGC+woBHxCbHXQqlRngnS1dN8H4mWSwPLtvuRrX9 fDm4Jxy6FQAye1F7yYnS5Xd2Eu/n3L81RJ2tAVVvHuwiabc25SX6Wh6BT1cM8gyazWJm 07EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t25s/5p/; 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 t12si11243092pgq.122.2017.11.06.01.02.15; Mon, 06 Nov 2017 01:02:29 -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=t25s/5p/; 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 S1752718AbdKFJAq (ORCPT + 98 others); Mon, 6 Nov 2017 04:00:46 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:47545 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752710AbdKFJAk (ORCPT ); Mon, 6 Nov 2017 04:00:40 -0500 Received: by mail-qt0-f196.google.com with SMTP id z50so10011568qtj.4; Mon, 06 Nov 2017 01:00:40 -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=55jjc4JBxDkFjLHU+c6h5UMRgXQ4dhHY8adg+GWI+JI=; b=t25s/5p/ASOLovVvjdKuuHEfF4VUaWASXk8oaHh97qTYi0G4QpSxfa7DMGmKhKEjLW UAoiD0FtPiMyV00INGGx0VavrjTP7W8mVsnkMoSYMHZZ9zM8/leIDog7wtzpPatggKTD k9pl14x0axy+UC40xtPnxNDV4r0gdBi3g2Lx1t5e5FF6j1NGrkK0GIQut8++TF9kb6NW GbHM7fha08A6aPPLdaznNqyhwoE8SbV7l4J5AOVx0TOBi7No9nvyFH6hl5ZHaDz1+v1W WC4n/qC4/1ZY9ETfZrgKzxMLbrKHYK88vplsH13PKq/7tY0L2+G8GoAQG2xOcWv78iEb GdQg== 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=55jjc4JBxDkFjLHU+c6h5UMRgXQ4dhHY8adg+GWI+JI=; b=Q1xZrF8kpRs7Rsk5nOiUrNh5VB3hKSUw0tkcfq9FjM3Y81jEJUvWwOzokgZQRaT6+k OcBE9rj2zQ6G6gc1ZnZ1pYGJ1KArj9DUikmfWWK2zNUw6BqQ3qGvQL7OnQmLuLT2m27C rbG4Rf4uPY2AsP/ahxD/QGX/ebSZOWqTaIVMbnla4FbUKFOwKDocwpaJSoqw4WFpMGzP yRKitNbRbLXzVnRU9A0pz3ak0d0zummKc0voFtZEzGUB3+2zkMNXPcMW27isZC/ErAyL nva0WWS0/qM4Guk8YiJi8hVIpsvbCMyfWxyCwU6z+rMExZrhhgUd3wkKgJD1UZD+7OJ3 w1cw== X-Gm-Message-State: AMCzsaUGq0dFK6IXMocMCRIUJc5+nnVyyss52yUNdJzWEH/3u7ZIqc/2 2QnRJB+3POIxLAWRx7o2dQQ= X-Received: by 10.237.55.102 with SMTP id i93mr22964335qtb.333.1509958839948; Mon, 06 Nov 2017 01:00:39 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 01:00:39 -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 49/51] selftest/vm: sub-page allocator Date: Mon, 6 Nov 2017 00:57:41 -0800 Message-Id: <1509958663-18737-50-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 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 c790bff..7b3649f 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -765,6 +765,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; @@ -887,6 +916,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 From 1583317021580141345@xxx Mon Nov 06 11:46:18 +0000 2017 X-GM-THRID: 1583317021580141345 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread