From patchwork Fri Feb 24 09:34:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 61208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:7b8e:b0:9f:8c76:fea4 with SMTP id j14csp1222452dyk; Fri, 24 Feb 2023 01:39:03 -0800 (PST) X-Google-Smtp-Source: AK7set9JFZOJpDhmWqvkdOdfY3+HqXe40XozB3/3WWC11XpQCjApfB+D8BlIzSOCKJzdXY5+Xhx7 X-Received: by 2002:a17:906:5d0f:b0:8f0:143d:ee28 with SMTP id g15-20020a1709065d0f00b008f0143dee28mr6112243ejt.16.1677231542918; Fri, 24 Feb 2023 01:39:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677231542; cv=none; d=google.com; s=arc-20160816; b=1J09ls1VWkvCN/eCoagD9aBvskPUrebdV7aQ3yZMB2P3BeO2bo948fJtW7CpBCirJ4 UTb8+PG1hz8AP/TaYaMlMzDTTeUgFR29C+8M3RW1OPupq0+FGQKb1gPdo+GVf//qFZus K3hf8CxNkbh8AVL/m/dtsAgdmmzsoh5fc1B+jXXrG59iLOSIOnPfvfn1hTNxPOYH2x/m cpzimJaI34/RDz7a0rpMGQhlK5xYMv3nS0PwXFF+29sFpev5bYC7pxeTaKMsNsCTQ1R7 Qypuqw+Gf+fWlVD2oW65Bky2JdOY+1tcBDv9B03+GClumpirP1pPL/VNMkhHU43bWrn2 FMnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kiVS63wbAWm+QNHUVgj2Zht/JYfZt2Iaghb+UJPmGJA=; b=jGSU2w5xzgM9+KHJg7U7wlDM/le2cv9UHHM1OfUQjq0GZXVbZBVL//4Y5RR0+23sRy WY7yIbSp7PHbS+j9A5KIg2GCCm6sYpSNIl7fPIsAEHZYp+p5vxnsj0ejz02RBizCwPfe GpZk0Ema8oK+ICW3nTnU1W8fVCl9/AgFUdJbvYaXxnvwNKcJAlbh1P49Iqg43tAvKmem wlz5kkfYvNwiBpgzwk/8VLIcbp9VewGnZy+ZspFI7BwCPDmhcrsfpKn6CPzL6M1o3OF+ XE73JNv+N6SQtisC8/vtu1uPzIZkaGnIHR7WfseBzi87spbHhHqNoQfjt1Jf+ANmNO/T AaUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrTYP59U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fq38-20020a1709069da600b008dfead50664si11233137ejc.114.2023.02.24.01.38.40; Fri, 24 Feb 2023 01:39:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrTYP59U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229551AbjBXJfK (ORCPT + 99 others); Fri, 24 Feb 2023 04:35:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjBXJfD (ORCPT ); Fri, 24 Feb 2023 04:35:03 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A5F45193C for ; Fri, 24 Feb 2023 01:35:01 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id o38-20020a05600c512600b003e8320d1c11so3870076wms.1 for ; Fri, 24 Feb 2023 01:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kiVS63wbAWm+QNHUVgj2Zht/JYfZt2Iaghb+UJPmGJA=; b=QrTYP59UXLyEyZXXYAeeXw2AFfFauFp/C2n/IOyN3xqbAk8jjk7e20YwjW4/43PsBi 4QPrI/QTUmePR3SOLNczxnpoBs5aDDxAEopDH+YvwI2cwTf4AF65FfzRnZObTfbN+Hec WFZO5EQCCOfR7bZFaP2tJLma9p8iRxA7DlUro5Z4PqHmwHBB+u2FhNfrug7WVn7wubU3 GzPZ6F/YVjhhCLmMkMui/c6pr2O5+yI85Yufy2TgrbyHe/rdl02i5nnCM0km4exhBi3P cJhw7ozhoXe+F0JqtenV03G1YlpZGakYFvT8fC0bLeE7ExceapOsAmy4aB88jY7A/oFs 835g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kiVS63wbAWm+QNHUVgj2Zht/JYfZt2Iaghb+UJPmGJA=; b=mCnaB2o5Qy77vWFPB7nD8fjXcAmmC+6Vus1lNr63iw0PdzFAdO2+rbrNfbW0UGlc+8 wJShK8kxLFnjar6tl9qnDTNyregjTa1V/y7HHu5/dRkfrJ8VrhJR8QmGgKfGz9nLxPas MSW5DV7cxqFHN3qd2eyvkMl3n5qGcwUzHYDMFMbJrC0LThqEoCFKJ8f7GQ4WxANpEDEy rp6toz7YpDipCtsl2Jl4Gwz5JXswuXzdvONxrfggq40OZdxWmRRNHKQc6UVghjQxzEul kFCW3o0ya1dowy1b4GR1hVEWa5Y1+mRhpfsSl5hk9Z6GNq34DcLCGvw8zzJsyBMDvOwB ybCQ== X-Gm-Message-State: AO0yUKVpMFBeFXYc2nkOJ++NSqu1TrjXuP54oiSonTc4xfW1d10N7wfV OwbwLx/gCYZpI9dJht6WtHQy7w== X-Received: by 2002:a05:600c:4929:b0:3e2:1f63:4beb with SMTP id f41-20020a05600c492900b003e21f634bebmr11748426wmp.19.1677231300127; Fri, 24 Feb 2023 01:35:00 -0800 (PST) Received: from vingu-book.. ([2a01:e0a:f:6020:a6f0:4ee9:c103:44cb]) by smtp.gmail.com with ESMTPSA id d18-20020a05600c34d200b003e6dcd562a6sm2239179wmq.28.2023.02.24.01.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 01:34:59 -0800 (PST) From: Vincent Guittot To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, parth@linux.ibm.com, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, cgroups@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org Cc: qyousef@layalina.io, chris.hyser@oracle.com, patrick.bellasi@matbug.net, David.Laight@aculab.com, pjt@google.com, pavel@ucw.cz, qperret@google.com, tim.c.chen@linux.intel.com, joshdon@google.com, timj@gnu.org, kprateek.nayak@amd.com, yu.c.chen@intel.com, youssefesmat@chromium.org, joel@joelfernandes.org, Vincent Guittot Subject: [PATCH v12 2/8] sched: Introduce latency-nice as a per-task attribute Date: Fri, 24 Feb 2023 10:34:48 +0100 Message-Id: <20230224093454.956298-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230224093454.956298-1-vincent.guittot@linaro.org> References: <20230224093454.956298-1-vincent.guittot@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758704742340097029?= X-GMAIL-MSGID: =?utf-8?q?1758704742340097029?= From: Parth Shah Latency-nice indicates the latency requirements of a task with respect to the other tasks in the system. The value of the attribute can be within the range of [-20, 19] both inclusive to be in-line with the values just like task nice values. latency_nice = -20 indicates the task to have the least latency as compared to the tasks having latency_nice = +19. The latency_nice may affect only the CFS SCHED_CLASS by getting latency requirements from the userspace. Additionally, add debugging bits for newly added latency_nice attribute. Signed-off-by: Parth Shah [rebase, move defines in sched/prio.h] Signed-off-by: Vincent Guittot Tested-by: K Prateek Nayak --- include/linux/sched.h | 1 + include/linux/sched/prio.h | 18 ++++++++++++++++++ kernel/sched/debug.c | 1 + 3 files changed, 20 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 4df2b3e76b30..6c61bde49152 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -784,6 +784,7 @@ struct task_struct { int static_prio; int normal_prio; unsigned int rt_priority; + int latency_nice; struct sched_entity se; struct sched_rt_entity rt; diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h index ab83d85e1183..bfcd7f1d1e11 100644 --- a/include/linux/sched/prio.h +++ b/include/linux/sched/prio.h @@ -42,4 +42,22 @@ static inline long rlimit_to_nice(long prio) return (MAX_NICE - prio + 1); } +/* + * Latency nice is meant to provide scheduler hints about the relative + * latency requirements of a task with respect to other tasks. + * Thus a task with latency_nice == 19 can be hinted as the task with no + * latency requirements, in contrast to the task with latency_nice == -20 + * which should be given priority in terms of lower latency. + */ +#define MAX_LATENCY_NICE 19 +#define MIN_LATENCY_NICE -20 + +#define LATENCY_NICE_WIDTH \ + (MAX_LATENCY_NICE - MIN_LATENCY_NICE + 1) + +/* + * Default tasks should be treated as a task with latency_nice = 0. + */ +#define DEFAULT_LATENCY_NICE 0 + #endif /* _LINUX_SCHED_PRIO_H */ diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 1637b65ba07a..68be7a3e42a3 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -1043,6 +1043,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, #endif P(policy); P(prio); + P(latency_nice); if (task_has_dl_policy(p)) { P(dl.runtime); P(dl.deadline);