Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752738AbcDYEvv (ORCPT ); Mon, 25 Apr 2016 00:51:51 -0400 Received: from mga11.intel.com ([192.55.52.93]:38741 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbcDYEvu (ORCPT ); Mon, 25 Apr 2016 00:51:50 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,531,1455004800"; d="scan'208";a="91230567" Message-ID: <571DA569.5040701@intel.com> Date: Mon, 25 Apr 2016 13:04:41 +0800 From: Zhang Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: mingo@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org CC: "Zhang, Yanmin" Subject: [PATCH] sched: don't output cpu sched info by default Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2150 Lines: 85 From: LongX Zhang Users usually install dozens of apps on Android devices. When system memory is used up as thousands of threads might run, Android userspace debug prcoess might dump system info by sysrq. One info is of cpu sched. Usually, one thread has one line dump. Such log is huge sometimes and such dumping spends lots of time and make the system worse. Sometimes, watchdog resets the system in the end. The patch fixes it by dumping cpu sched info only when sched_debug_enabled is true. Signed-off-by: Zhang Yanmin Signed-off-by: LongX Zhang --- kernel/sched/core.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 8b489fc..92d2d83 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4973,6 +4973,25 @@ void sched_show_task(struct task_struct *p) show_stack(p, NULL); } +#ifdef CONFIG_SCHED_DEBUG + +static __read_mostly int sched_debug_enabled; + +static int __init sched_debug_setup(char *str) +{ + sched_debug_enabled = 1; + + return 0; +} +early_param("sched_debug", sched_debug_setup); + +static inline bool sched_debug(void) +{ + return sched_debug_enabled; +} + +#endif + void show_state_filter(unsigned long state_filter) { struct task_struct *g, *p; @@ -4998,7 +5017,8 @@ void show_state_filter(unsigned long state_filter) touch_all_softlockup_watchdogs(); #ifdef CONFIG_SCHED_DEBUG - sysrq_sched_debug_show(); + if (sched_debug()) + sysrq_sched_debug_show(); #endif rcu_read_unlock(); /* @@ -5499,21 +5519,6 @@ static cpumask_var_t sched_domains_tmpmask; /* sched_domains_mutex */ #ifdef CONFIG_SCHED_DEBUG -static __read_mostly int sched_debug_enabled; - -static int __init sched_debug_setup(char *str) -{ - sched_debug_enabled = 1; - - return 0; -} -early_param("sched_debug", sched_debug_setup); - -static inline bool sched_debug(void) -{ - return sched_debug_enabled; -} - static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, struct cpumask *groupmask) { -- 1.9.1