Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933296AbbDJUsv (ORCPT ); Fri, 10 Apr 2015 16:48:51 -0400 Received: from mail-db3on0086.outbound.protection.outlook.com ([157.55.234.86]:9180 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932343AbbDJUsp (ORCPT ); Fri, 10 Apr 2015 16:48:45 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; From: Chris Metcalf To: Frederic Weisbecker , Don Zickus , Ingo Molnar , Andrew Morton , Andrew Jones , chai wen , Ulrich Obergfell , Fabian Frederick , Aaron Tomlin , Ben Zhang , "Christoph Lameter" , Gilad Ben-Yossef , "Steven Rostedt" , , "Jonathan Corbet" , , Thomas Gleixner , Peter Zijlstra CC: Chris Metcalf Subject: [PATCH v7 3/3] procfs: treat parked tasks as sleeping for task state Date: Fri, 10 Apr 2015 16:48:20 -0400 Message-ID: <1428698900-13358-3-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1428698900-13358-1-git-send-email-cmetcalf@ezchip.com> References: <20150410015842.GG18314@lerouge> <1428698900-13358-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(62966003)(33646002)(104016003)(106466001)(77156002)(50226001)(229853001)(105606002)(85426001)(42186005)(47776003)(76176999)(50986999)(50466002)(575784001)(86362001)(48376002)(19580405001)(19580395003)(92566002)(6806004)(2950100001)(87936001)(46102003)(36756003)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR02MB0774;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB0774;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB0711; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006);SRVR:DB5PR02MB0774;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB0774; X-Forefront-PRVS: 054231DC40 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2015 20:48:39.0707 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR02MB0774 X-OriginatorOrg: ezchip.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1914 Lines: 47 Allowing watchdog threads to be parked means that we now have the opportunity of actually seeing persistent parked threads in the output of /proc's stat and status files. The existing code reported such threads as "Running", which is kind-of true if you think of the case where we park them as part of taking cpus offline. But if we allow parking them indefinitely, "Running" is pretty misleading, so we report them as "Sleeping" instead. We could simply report them with a new string, "Parked", but it feels like it's a bit risky for userspace to see unexpected new values. The scheduler does report parked tasks with a "P" in debugging output from sched_show_task() or dump_cpu_task(), but that's a different API. This change seemed slightly cleaner than updating the task_state_array to have additional rows. TASK_DEAD should be subsumed by the exit_state bits; TASK_WAKEKILL is just a modifier; and TASK_WAKING can very reasonably be reported as "Running" (as it is now). Only TASK_PARKED shows up with unreasonable output here. Signed-off-by: Chris Metcalf --- fs/proc/array.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/proc/array.c b/fs/proc/array.c index a3893b7505b2..2eb623ffb0b7 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -126,6 +126,10 @@ static inline const char *get_task_state(struct task_struct *tsk) { unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT; + /* Treat parked tasks as sleeping. */ + if (state == TASK_PARKED) + state = TASK_SLEEPING; + BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1); return task_state_array[fls(state)]; -- 2.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/