From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=DATE_IN_PAST_06_12, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB4B1C10F14 for ; Mon, 22 Apr 2019 01:57:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB4362087F for ; Mon, 22 Apr 2019 01:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbfDVB5U (ORCPT ); Sun, 21 Apr 2019 21:57:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:48592 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbfDVB5T (ORCPT ); Sun, 21 Apr 2019 21:57:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2019 18:57:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,380,1549958400"; d="scan'208";a="151240124" Received: from aubrey-skl.sh.intel.com ([10.239.53.6]) by FMSMGA003.fm.intel.com with ESMTP; 21 Apr 2019 18:57:16 -0700 From: Aubrey Li To: tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, hpa@zytor.com Cc: ak@linux.intel.com, tim.c.chen@linux.intel.com, dave.hansen@intel.com, arjan@linux.intel.com, adobriyan@gmail.com, akpm@linux-foundation.org, aubrey.li@intel.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Aubrey Li , Andy Lutomirski Subject: [PATCH v17 1/3] proc: add /proc//arch_status Date: Mon, 22 Apr 2019 02:35:27 +0800 Message-Id: <20190421183529.9141-1-aubrey.li@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The architecture specific information of the running processes could be useful to the userland. Add /proc//arch_status interface support to examine process architecture specific information externally. Signed-off-by: Aubrey Li Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Andi Kleen Cc: Tim Chen Cc: Dave Hansen Cc: Arjan van de Ven Cc: Alexey Dobriyan Cc: Andrew Morton Cc: Andy Lutomirski Cc: Linux API --- arch/x86/Kconfig | 1 + fs/proc/Kconfig | 10 ++++++++++ fs/proc/base.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5ad92419be19..d5a9c5ddd453 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -208,6 +208,7 @@ config X86 select USER_STACKTRACE_SUPPORT select VIRT_TO_BUS select X86_FEATURE_NAMES if PROC_FS + select PROC_PID_ARCH_STATUS if PROC_FS config INSTRUCTION_DECODER def_bool y diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig index 817c02b13b1d..101bf5054e81 100644 --- a/fs/proc/Kconfig +++ b/fs/proc/Kconfig @@ -97,3 +97,13 @@ config PROC_CHILDREN Say Y if you are running any user-space software which takes benefit from this interface. For example, rkt is such a piece of software. + +config PROC_PID_ARCH_STATUS + bool "Enable /proc//arch_status file" + default n + help + Provides a way to examine process architecture specific information. + See for more information. + + Say Y if you are running any user-space software which wants to obtain + process architecture specific information from this interface. diff --git a/fs/proc/base.c b/fs/proc/base.c index 6a803a0b75df..a890d9f12851 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -94,6 +94,7 @@ #include #include #include +#include #include #include "internal.h" #include "fd.h" @@ -2957,6 +2958,22 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns, } #endif /* CONFIG_STACKLEAK_METRICS */ +/* + * Add support for task architecture specific output in /proc/pid/arch_status. + * task_arch_status() must be defined in asm/processor.h + */ +#ifdef CONFIG_PROC_PID_ARCH_STATUS +# ifndef task_arch_status +# define task_arch_status(m, task) +# endif +static int proc_pid_arch_status(struct seq_file *m, struct pid_namespace *ns, + struct pid *pid, struct task_struct *task) +{ + task_arch_status(m, task); + return 0; +} +#endif /* CONFIG_PROC_PID_ARCH_STATUS */ + /* * Thread groups */ @@ -3061,6 +3078,9 @@ static const struct pid_entry tgid_base_stuff[] = { #ifdef CONFIG_STACKLEAK_METRICS ONE("stack_depth", S_IRUGO, proc_stack_depth), #endif +#ifdef CONFIG_PROC_PID_ARCH_STATUS + ONE("arch_status", S_IRUGO, proc_pid_arch_status), +#endif }; static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx) @@ -3449,6 +3469,9 @@ static const struct pid_entry tid_base_stuff[] = { #ifdef CONFIG_LIVEPATCH ONE("patch_state", S_IRUSR, proc_pid_patch_state), #endif +#ifdef CONFIG_PROC_PID_ARCH_STATUS + ONE("arch_status", S_IRUGO, proc_pid_arch_status), +#endif }; static int proc_tid_base_readdir(struct file *file, struct dir_context *ctx) -- 2.17.1