From nobody Wed Sep 10 02:39:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525C1C636D6 for ; Thu, 23 Feb 2023 19:11:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229497AbjBWTLY (ORCPT ); Thu, 23 Feb 2023 14:11:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbjBWTLN (ORCPT ); Thu, 23 Feb 2023 14:11:13 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 175FB56529 for ; Thu, 23 Feb 2023 11:10:49 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id bo30so10995816wrb.0 for ; Thu, 23 Feb 2023 11:10:49 -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=fIYGRnAgdM1pkszU9vujdElW+ZXCpTTf26yDfbUIv79L8uorGratJSQKy5JJHH9DQ+ mPbuFR4q4LajY8N0objspMBuREs1C8bEczpR+yZelsroKn3N/FpjN/oT7oxBNg139zUa PyiGiRirGFQgNB0Gd7VZRP6nDveoPxnPuvIJ3741+SjfmENOI4oTXnnvvm/FTpMVQ9N8 aRpzzIsafVX1tcketysgCV3PX8OB9+epSy1Mompzex59kSU8k4jFGekd7RMUSWcJq8TT LmOjl6fYcaFyY2DN/1vWEV0HB7KlYF2iNDl/Trfy7C5ruK9qvJmFBD+6ZkCnqYmRMa9S P0iw== 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=DdfxtuuOFGBZeEVchG32FOcUBdprhv5YOUqcdkNSY2eGWL/Bw9IO1gQonMDQf8UuY/ SQ0IdI3YiSkFIh0kCaYqPvZiowtd4RqKeGTCQqVpkMf/7DWo3mPlX6eJpMP5kC3y/uvm p6RxFoIEM9xpClRoYVP6oznDC4Wd4u4EFZyac72QlszBQ87WrjX+gaba8cx8JdypfXBW Z/SPtq8+6iV2BD13ygK0YECA/uahDsMCT8m3NPJU/F8e1DariSyxiPmBgyuPZBo4cz3Z Yzt2VMom7HlmyfqilRBAyKwneDZn9uaaICjGAZ8GOy8ifBrhpEdFGM1gnfAJIz1Fvanf 48mQ== X-Gm-Message-State: AO0yUKWR7ghw+L9ahMd6EPqnJUmhRsO7iRKsEGKrJePqIBxJIqxFO51R qvYiu83HxhokZu88XGK/Wt0VxA== X-Google-Smtp-Source: AK7set8ailWUj1cm9/MR8T00RP9NTdvcApBMpjUfy6nYCzgaS9+P6dhi4HqQHx97xYFu87vC8YFEtQ== X-Received: by 2002:a05:6000:1c04:b0:2c5:4ffb:b5d4 with SMTP id ba4-20020a0560001c0400b002c54ffbb5d4mr10630447wrb.19.1677179447566; Thu, 23 Feb 2023 11:10:47 -0800 (PST) Received: from vingu-book.. ([2a01:e0a:f:6020:a6f0:4ee9:c103:44cb]) by smtp.gmail.com with ESMTPSA id k2-20020adff282000000b002c6e8cb612fsm9844481wro.92.2023.02.23.11.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 11:10:47 -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, lizefan.x@bytedance.com, hannes@cmpxchg.org, cgroups@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org Cc: tj@kernel.org, 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 v8 2/8] sched: Introduce latency-nice as a per-task attribute Date: Thu, 23 Feb 2023 20:10:35 +0100 Message-Id: <20230223191041.577305-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230223191041.577305-1-vincent.guittot@linaro.org> References: <20230223191041.577305-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D -20 indicates the task to have the least latency as compared to the tasks having latency_nice =3D +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; =20 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); } =20 +/* + * 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 =3D=3D 19 can be hinted as the task with = no + * latency requirements, in contrast to the task with latency_nice =3D=3D = -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 =3D 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, stru= ct pid_namespace *ns, #endif P(policy); P(prio); + P(latency_nice); if (task_has_dl_policy(p)) { P(dl.runtime); P(dl.deadline); --=20 2.34.1