From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935310AbdIYMMv (ORCPT ); Mon, 25 Sep 2017 08:12:51 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:41129 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935240AbdIYMMV (ORCPT ); Mon, 25 Sep 2017 08:12:21 -0400 Message-Id: <20170925121117.281046221@infradead.org> User-Agent: quilt/0.63-1 Date: Mon, 25 Sep 2017 14:07:54 +0200 From: Peter Zijlstra To: mingo@kernel.org, markus@trippelsdorf.de, rostedt@goodmis.org Cc: tj@kernel.org, mcgrof@kernel.org, ebiederm@xmission.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] sched: Ignore TASK_IDLE for SysRq-W References: <20170925120747.125098571@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-sched-state-7.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Markus reported that tasks in TASK_IDLE state are reported by SysRq-W, which results in undesirable clutter. Reported-by: Markus Trippelsdorf Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5164,6 +5164,28 @@ void sched_show_task(struct task_struct put_task_stack(p); } +static inline bool +state_filter_match(unsigned long state_filter, struct task_struct *p) +{ + /* no filter, everything matches */ + if (!state_filter) + return true; + + /* filter, but doesn't match */ + if (!(p->state & state_filter)) + return false; + + /* + * When looking for TASK_UNINTERRUPTIBLE skip TASK_IDLE (allows + * TASK_KILLABLE). + */ + if (state_filter == TASK_UNINTERRUPTIBLE && p->state == TASK_IDLE) + return false; + + return true; +} + + void show_state_filter(unsigned long state_filter) { struct task_struct *g, *p; @@ -5186,7 +5208,7 @@ void show_state_filter(unsigned long sta */ touch_nmi_watchdog(); touch_all_softlockup_watchdogs(); - if (!state_filter || (p->state & state_filter)) + if (state_filter_match(state_filter, p)) sched_show_task(p); }