Received: by 10.223.176.46 with SMTP id f43csp1248491wra; Fri, 19 Jan 2018 08:52:37 -0800 (PST) X-Google-Smtp-Source: ACJfBosug/V/+sv8cZhKFycCbz1+C/8+Zy5RlXKk2pWEUyWcMMGhCdTrLGywlU+z6VatSbjIxIDi X-Received: by 10.101.73.131 with SMTP id r3mr18252620pgs.76.1516380757479; Fri, 19 Jan 2018 08:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516380757; cv=none; d=google.com; s=arc-20160816; b=A18ooIvnMK03H24cKiyuE/imJhDPv4eGBbjKM8uPlxZmq00YR3CsDIMsg5x4QeAB3S 75VJMAqwLtWFuM7AhYA1AFA/3bEaM6uUMhzN6aHzCtEjJA0pWFyrQT7bjj1mhpCPC+5y vFVFLJ0R/BCK5YF6Q8NLqVwMzc/1AyRAeFwloOqjFPZNO0l4gwQOI7MyVFNJREHq69fh oVgelumJy4LdhZfp7RPr9Db8Mw6uK/Wgu277FD0ekb/zxKrIneuGbOHbl4rQfPP5eKXx cjygS17tpqWUSdXQ6mwRUggow61/hddxNNMatGlatMHh81iu0n8vMb1J21YzvaNpigoq 5F9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=OqOAW+QIgsd7A5bsG/7/R4OyUPxRhXUdZzP+NmDNS50=; b=qiQCLFXVoBYqDI2Njp1Yx0eJIR9QHJIrKE4r307aK3ZpOLcoN8lnAXcXklNnAa+YVb eYmw5oLcMExIr4EIr8YLEa13u4zFbMsoroS0YaOU5y8mR0OGQiNXA5WflF+gKAUFDE1I BREKRApEq4ehrL5veCfT76iSh2h7+LfT6ZMGntgWsMsrvg1nWFjkIoytUi7N6rHi6z/5 XkbexX9HWaGX9eVrqptUWJaqjdkEkwAtTR3p6LAd90JhFeiSJofYsmxrd5dCkvHQk8oK z4g8wHxI4BvZU+x0fmEZ5rVzk5euTNT9TJBeWnRXY+RYMqUM+PPjGKvub3vvWVXtlH7h zdJg== ARC-Authentication-Results: i=1; mx.google.com; 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 i15si8394911pgp.516.2018.01.19.08.52.23; Fri, 19 Jan 2018 08:52:37 -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; 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 S1756138AbeASQvX (ORCPT + 99 others); Fri, 19 Jan 2018 11:51:23 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49272 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755983AbeASQvP (ORCPT ); Fri, 19 Jan 2018 11:51:15 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0JGmaqv118037 for ; Fri, 19 Jan 2018 11:51:14 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fkm169efa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 Jan 2018 11:51:13 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Jan 2018 16:51:11 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Jan 2018 16:51:04 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0JGp4ef48889894; Fri, 19 Jan 2018 16:51:04 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F06CFA4051; Fri, 19 Jan 2018 16:44:47 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4963A4055; Fri, 19 Jan 2018 16:44:37 +0000 (GMT) Received: from ram.oc3035372033.ibm.com (unknown [9.85.190.213]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 19 Jan 2018 16:44:37 +0000 (GMT) Date: Fri, 19 Jan 2018 08:50:50 -0800 From: Ram Pai To: "Eric W. Biederman" Cc: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de, 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 Subject: Re: [PATCH v10 27/27] mm: display pkey in smaps if arch_pkeys_enabled() is true Reply-To: Ram Pai References: <1516326648-22775-1-git-send-email-linuxram@us.ibm.com> <1516326648-22775-28-git-send-email-linuxram@us.ibm.com> <87shb1de4a.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87shb1de4a.fsf@xmission.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18011916-0012-0000-0000-000005A5AB74 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011916-0013-0000-0000-000019212AAB Message-Id: <20180119165050.GK5612@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-19_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801190220 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 19, 2018 at 10:09:41AM -0600, Eric W. Biederman wrote: > Ram Pai writes: > > > Currently the architecture specific code is expected to > > display the protection keys in smap for a given vma. > > This can lead to redundant code and possibly to divergent > > formats in which the key gets displayed. > > > > This patch changes the implementation. It displays the > > pkey only if the architecture support pkeys. > > > > x86 arch_show_smap() function is not needed anymore. > > Delete it. > > > > Signed-off-by: Ram Pai > > --- > > arch/x86/kernel/setup.c | 8 -------- > > fs/proc/task_mmu.c | 11 ++++++----- > > 2 files changed, 6 insertions(+), 13 deletions(-) > > > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > > index 8af2e8d..ddf945a 100644 > > --- a/arch/x86/kernel/setup.c > > +++ b/arch/x86/kernel/setup.c > > @@ -1326,11 +1326,3 @@ static int __init register_kernel_offset_dumper(void) > > return 0; > > } > > __initcall(register_kernel_offset_dumper); > > - > > -void arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) > > -{ > > - if (!boot_cpu_has(X86_FEATURE_OSPKE)) > > - return; > > - > > - seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); > > -} > > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c > > index 0edd4da..4b39a94 100644 > > --- a/fs/proc/task_mmu.c > > +++ b/fs/proc/task_mmu.c > > @@ -18,6 +18,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -728,10 +729,6 @@ static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask, > > } > > #endif /* HUGETLB_PAGE */ > > > > -void __weak arch_show_smap(struct seq_file *m, struct vm_area_struct *vma) > > -{ > > -} > > - > > static int show_smap(struct seq_file *m, void *v, int is_pid) > > { > > struct proc_maps_private *priv = m->private; > > @@ -851,9 +848,13 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) > > (unsigned long)(mss->pss >> (10 + PSS_SHIFT))); > > > > if (!rollup_mode) { > > - arch_show_smap(m, vma); > > +#ifdef CONFIG_ARCH_HAS_PKEYS > > + if (arch_pkeys_enabled()) > > + seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); > > +#endif > > Would it be worth it making vma_pkey a noop on architectures that don't > support protection keys so that we don't need the #ifdef here? You mean something like this? #define vma_pkey(vma) It will lead to compilation error. I can make it #define vma_pkey(vma) 0 and that will work and get rid of the #ifdef RP