Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp187822pxb; Thu, 20 Jan 2022 11:19:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnQIFRp6bEFNpWRxm9UBHD7JkUgyYL+2QJ2hxHOG2nOtx5d3sA7kwqrAtO81Ts871sjalO X-Received: by 2002:a17:902:e741:b0:14a:5a65:dcdb with SMTP id p1-20020a170902e74100b0014a5a65dcdbmr467652plf.135.1642706391462; Thu, 20 Jan 2022 11:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642706391; cv=none; d=google.com; s=arc-20160816; b=d10yK7KAcauvdAySDxfa5hi6grVYSnQxv06FpmEIEg//RgOkzGHPiDdLhWP9Q9Xnh3 4LZ5eOn25Mr/t6JCEd6bD+1D89qxNSboJDOGFolaq/+SAWHYyrqIharu6yrgrlItww3c VTdbC2J+b/C50XUr5cHL8lMZzN7Lg6jSQdaNGsogGBqHLPm8+HCWFmtSzCGsSifrFpwX uBaisUdvfI0sgzqiW2C7LvYB5XJ0bfQOLtMcFAS0sF3fcJg3CSbaJ01hL70/Y9STjuFI V4gx3O++WixPw+C5NmGMgBXyW58fR8KjaLKt5psEXa5G+C0q3Hng4vgvKU0xDK0h8HYt BVeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=/6tyuXeDrSKtHxlz0ga1EhCl7CpgipCHv2xf+EWYsS0=; b=1DnwVbICqV761McOAerg/gdUCz2GYS2Vduj12AAQrOBA3QUXhFI+XgPXCBcpzFo60g BS62F6E08O6v65B4PenbHTIMkwGky2pGdGVUyXLHjtM9bl1OYwZqTphK/8h6Txb7EpLf R4KYS/kStQZnhO0TC9Axb69itDkkbnk5ixti8TJcCcqAgk9PmLom763efu1KEjRTgpWJ U5IfEkzGeZCpP+imk4hcJcKk9u/hbByPIruqfRRyKJ83urFwnQ5o/gZxDQn4YOcwOXIX xw8zMZldRafRhPXkVYFOKPacYf3pnM+54mAT/l9ryi+TL6h42yT3e5OEz7LVm/SACi3M 7Erw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si3878878plz.574.2022.01.20.11.19.39; Thu, 20 Jan 2022 11:19:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347268AbiARR31 (ORCPT + 99 others); Tue, 18 Jan 2022 12:29:27 -0500 Received: from foss.arm.com ([217.140.110.172]:33994 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347244AbiARR31 (ORCPT ); Tue, 18 Jan 2022 12:29:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A693BD6E; Tue, 18 Jan 2022 09:29:26 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.196.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B9D03F774; Tue, 18 Jan 2022 09:29:24 -0800 (PST) From: Valentin Schneider To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Steven Rostedt , Sebastian Andrzej Siewior , Abhijeet Dharmapurikar , Dietmar Eggemann , Peter Zijlstra , Ingo Molnar , Vincent Guittot , Thomas Gleixner , Juri Lelli , Daniel Bristot de Oliveira , Kees Cook , Andrew Morton , Alexey Gladkov , "Kenta.Tada\@sony.com" , Randy Dunlap , Ed Tsai , linux-api@vger.kernel.org Subject: Re: [PATCH v2 2/2] sched/tracing: Add TASK_RTLOCK_WAIT to TASK_REPORT In-Reply-To: <878rve89cc.fsf@email.froward.int.ebiederm.org> References: <20220117164633.322550-1-valentin.schneider@arm.com> <20220117164633.322550-3-valentin.schneider@arm.com> <878rve89cc.fsf@email.froward.int.ebiederm.org> Date: Tue, 18 Jan 2022 17:29:21 +0000 Message-ID: <878rvd6jgu.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/01/22 13:12, Eric W. Biederman wrote: > Valentin Schneider writes: >> --- a/fs/proc/array.c >> +++ b/fs/proc/array.c >> @@ -128,9 +128,10 @@ static const char * const task_state_array[] = { >> "X (dead)", /* 0x10 */ >> "Z (zombie)", /* 0x20 */ >> "P (parked)", /* 0x40 */ >> + "L (rt-locked)", /* 0x80 */ >> >> /* states beyond TASK_REPORT: */ >> - "I (idle)", /* 0x80 */ >> + "I (idle)", /* 0x100 */ >> }; > > I think this is at least possibly an ABI break. I have a vague memory > that userspace is not ready being reported new task states. Which is > why we encode some of our states the way we do. > > Maybe it was just someone being very conservative. > > Still if you are going to add new states to userspace and risk breaking > them can you do some basic analysis and report what ps and similar > programs do. > > Simply changing userspace without even mentioning that you are changing > the userspace output of proc looks dangerous indeed. > Yeah, you're right. > Looking in the history commit 74e37200de8e ("proc: cleanup/simplify > get_task_state/task_state_array") seems to best document the concern > that userspace does not know how to handle new states. > Thanks for the sha1 and for digging around. Now, I read 74e37200de8e ("proc: cleanup/simplify get_task_state/task_state_array") as "get_task_state() isn't clear vs what value is actually exposed to userspace" rather than "get_task_state() could expose things userspace doesn't know what to do with". > The fact we have had a parked state for quite a few years despite that > concern seems to argue it is possible to extend the states. Or perhaps > it just argues that parked states are rare enough it does not matter. > > It is definitely the case that the ps manpage documents the possible > states and as such they could be a part of anyone's shell scripts. > 06eb61844d84 ("sched/debug: Add explicit TASK_IDLE printing") for instance seems to suggest extending the states OK, but you're right that this then requires updating ps' manpage. Alternatively, TASK_RTLOCK_WAIT could be masqueraded as TASK_(UN)INTERRUPTIBLE when reported to userspace - it is actually somewhat similar, unlike TASK_IDLE vs TASK_UNINTERRUPTIBLE for instance. The handling in get_task_state() will be fugly, but it might be preferable over exposing a detail userspace might not need to be made aware of? > From the ps man page: >> Here are the different values that the s, stat and state output >> specifiers (header "STAT" or "S") will display to describe the >> state of a process: >> >> D uninterruptible sleep (usually IO) >> I Idle kernel thread >> R running or runnable (on run queue) >> S interruptible sleep (waiting for an event to complete) >> T stopped by job control signal >> t stopped by debugger during the tracing >> W paging (not valid since the 2.6.xx kernel) >> X dead (should never be seen) >> Z defunct ("zombie") process, terminated but not reaped by its parent >> > > So it looks like a change that adds to the number of states in the > kernel should update the ps man page as well. > > Eric