Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7641135imu; Wed, 14 Nov 2018 22:19:52 -0800 (PST) X-Google-Smtp-Source: AJdET5ewog/1RsHguwkgN+IQrO6e1av8dQzRbodTFDEPr6EkUoc/N9r0jB4D13nmDLGE08pSHE/h X-Received: by 2002:a63:374e:: with SMTP id g14mr4707750pgn.59.1542262791998; Wed, 14 Nov 2018 22:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542262791; cv=none; d=google.com; s=arc-20160816; b=Bz0rtwE1/ZWux5lfkiAaEB0B95eUhsRv12WIa3FpidTbD9UbEYOBtj/8sUjfAuGQ0C 0qYeCpKgXtuHhPsMX/++zmhih5Pe4rZwDt8naufJGmk+ZWAi6Gfweekm/PCaqXhfHiEV vj2tyEQX1zzX+UUwgpTwqAeuq0dvnW0HL1N1z57qlDVr/sAdj/ZDwNz9wzCzb69a/g+P uWsUnYy4QFNIWV6qEPwelh9JFixC9XaGBPrw94OtZFwZ1hPYQav4qXUIuHToOwswE/E0 ZG24n+y5bClNIuGL2Z0cHyG4nXnmcFW6Usfr/D69D2jvbD5K6EFNghjCrHrWKRtpB9KC D+aw== 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; bh=ZN18r9NmiSDQkqPpWuId3mjpDpKP8Xhw4tLz6OwusCg=; b=hHydjCKp1QVTlbzBUP4SeqBQEhGz8I+D5cKJvLeWfoOOv1QWdRicKoK2iBfSa+7vqa thC3IC6PM8pkzsMj/f6k/vIACbN81yUAJAfqJwzZDzyxxGxgyWNXhsMCUVaI8+uCDNUv jf4/iWz0ISXyAGqYZGH1rdIVRkcjaIP0JUOo3lWiuwinmB5qECAAFOe69++E89TAccDC X+Ec2lhpuzBdos7V1BMehZDxQMRPH+rpOrtW34hNJw1c5WECfUDKcxYQ/GpGDnRxsspw AK8PM9R+CFBtQgcuy7eqZ4o/1SSwdCCmPHzWG199NiTOc3J5o9kK97Yzm6hhYOwSYlPs HpTg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si1685003pga.102.2018.11.14.22.19.37; Wed, 14 Nov 2018 22:19:51 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728575AbeKOQXu (ORCPT + 99 others); Thu, 15 Nov 2018 11:23:50 -0500 Received: from mga12.intel.com ([192.55.52.136]:13841 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbeKOQXt (ORCPT ); Thu, 15 Nov 2018 11:23:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2018 22:17:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,235,1539673200"; d="scan'208";a="281236377" Received: from aubrey-skl.sh.intel.com ([10.239.53.9]) by fmsmga006.fm.intel.com with ESMTP; 14 Nov 2018 22:17:18 -0800 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, aubrey.li@intel.com, linux-kernel@vger.kernel.org, Aubrey Li Subject: [PATCH v3 2/2] proc: add /proc//arch_state Date: Thu, 15 Nov 2018 07:00:07 +0800 Message-Id: <1542236407-4323-2-git-send-email-aubrey.li@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542236407-4323-1-git-send-email-aubrey.li@intel.com> References: <1542236407-4323-1-git-send-email-aubrey.li@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a /proc//arch_state interface to expose per-task cpu specific state values. Exposing AVX-512 Hi16_ZMM registers usage is for the user space job scheduler to cluster AVX-512 using tasks together, because these tasks could cause core turbo frequency drop. Signed-off-by: Aubrey Li Cc: Peter Zijlstra Cc: Andi Kleen Cc: Tim Chen Cc: Arjan van de Ven --- arch/x86/kernel/fpu/xstate.c | 16 ++++++++++++++++ fs/proc/base.c | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 87a57b7..10224ee 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -1245,3 +1246,18 @@ int copy_user_to_xstate(struct xregs_state *xsave, const void __user *ubuf) return 0; } + +/* + * report CPU specific thread state + */ +void arch_thread_state(struct seq_file *m, struct task_struct *task) +{ + /* + * Report AVX-512 Hi16_ZMM registers usage + */ + if (task->thread.fpu.hi16zmm_usage) + seq_putc(m, '1'); + else + seq_putc(m, '0'); + seq_putc(m, '\n'); +} diff --git a/fs/proc/base.c b/fs/proc/base.c index aaffc0c..efd51ec 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2893,6 +2893,17 @@ static int proc_pid_patch_state(struct seq_file *m, struct pid_namespace *ns, } #endif /* CONFIG_LIVEPATCH */ +void __weak arch_thread_state(struct seq_file *m, struct task_struct *task) +{ +} + +static int proc_pid_arch_state(struct seq_file *m, struct pid_namespace *ns, + struct pid *pid, struct task_struct *task) +{ + arch_thread_state(m, task); + return 0; +} + /* * Thread groups */ @@ -2994,6 +3005,7 @@ static const struct pid_entry tgid_base_stuff[] = { #ifdef CONFIG_LIVEPATCH ONE("patch_state", S_IRUSR, proc_pid_patch_state), #endif + ONE("arch_state", S_IRUSR, proc_pid_arch_state), }; static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx) @@ -3372,6 +3384,7 @@ static const struct pid_entry tid_base_stuff[] = { #ifdef CONFIG_LIVEPATCH ONE("patch_state", S_IRUSR, proc_pid_patch_state), #endif + ONE("arch_state", S_IRUSR, proc_pid_arch_state), }; static int proc_tid_base_readdir(struct file *file, struct dir_context *ctx) -- 2.7.4