Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7248767rwb; Tue, 15 Nov 2022 09:30:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5tBbtx4f683sMb/haq7Gut0ij4QXvHCgbN/thGlLGb4UonW4jolvafF35kJ1DBeW2/T+J+ X-Received: by 2002:aa7:d697:0:b0:461:dbcc:5176 with SMTP id d23-20020aa7d697000000b00461dbcc5176mr15896420edr.53.1668533414718; Tue, 15 Nov 2022 09:30:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668533414; cv=none; d=google.com; s=arc-20160816; b=Tq8K+zcwHLvXxJG2nJzO/Z5WVwcGM9PYIX9fwB+T1yhUf29CrOO4uCf8c2NQUfZCUK x3zIlVrehEcb4W5WKisKj7L4/eRmL6rQ2+RWVI6JzQ5YfvvY/WTDGADeP9IGZOKZ0L9+ vkHHsaV+UmJzTa9FloWu3WusBBPTe9ovyimAl5FDYPVwFZ5qwGsGS1EHUK/+kPf9+c4+ yT2t8fk1vuh/40S5IhFaiSvbYlmLAkiyLIYxwI/R6W+oZ3EcT3JCbGabh1QhQPjAW5Yx lLv6eu5EJZ8nElUs66ED9FBZdbBMu+yj5vRAm7ycsfTIE5Hm6zBPhCc5y0gt63n28+pF dfDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=wENRkgQEb1UIrFAJEzEMVqSnf8X2lmPttrPLcOcx98M=; b=NESGD0uhWOHGvT/PSwf1peQL2vd+st6uV71cZ1aGpdX/4AB9PKZymN20RThNzqvJ/z BKc1twawKsm4ZmvHAo9gf8+UJ0QX7i3WAvNUe9c2IglvBYSY+5o/u3Rkg329r+CQ/cKy gW/h+ENBJl6f1TKYJXv0LFhXylee4b+T0TdHpj7XjHkNtJlJjFt3WA5W01EuC6b+Vr78 MQPfJ6c1PC7WBvJsMhbIQ6jjsbEOIJINXGBAqsZd1t8hZWO+OnpDikxXfaz4wWuyvQbV J76tZZ8yFTCnY4bmR/sAdHqaTTM0cG5znKaKE+YOYyPOuOMM+2z81qCChzi+Fhgi/eHq fZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8A8G6ry; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a0564021f8a00b004585e0f44fesi10670243edc.60.2022.11.15.09.29.50; Tue, 15 Nov 2022 09:30:14 -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=V8A8G6ry; 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 S231473AbiKORTZ (ORCPT + 90 others); Tue, 15 Nov 2022 12:19:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbiKORTM (ORCPT ); Tue, 15 Nov 2022 12:19:12 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D08A415FED for ; Tue, 15 Nov 2022 09:19:03 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id h186-20020a1c21c3000000b003cfe48519a6so613264wmh.0 for ; Tue, 15 Nov 2022 09:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=wENRkgQEb1UIrFAJEzEMVqSnf8X2lmPttrPLcOcx98M=; b=V8A8G6ryEkY5Zlffpr5423h5AkfoG7/Qhh7Vlc9PP2tE1WGksWc1eHVvpKMWVAlMIP LC2+wujeeQCObNicxOUGyWmP+3mepaba6VKelY6mL1fOpMT4RJfQuDFU5IiFtFj34H8H 9Ivypn2vI8GqdeKikXiN0ZNL59NXJIOsMZToD+8SRuqnm8DTtnKgADjDp6k2k0Ar+o+Z FpmrRoKOri2cs7JrU4I/2SYXHZ8d6dDq36ZQqrRDRVhRrqJqnzFvxrmhMOsks2aDyDPf YnRPygFpUMxOZhJDIxdASEgxbJb8x3cW2tO3ieCbqCmsZ8/g5XrPi9AgTRnkUaZ5ufRT 8ozQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=wENRkgQEb1UIrFAJEzEMVqSnf8X2lmPttrPLcOcx98M=; b=JndTdytMHVyNLCs5J8hAaLFjnL1c6KnKQAfKkU4sMusc+qt329UG2QDrZ2zI7ervLS sCgu/S1qLy0AAwqJ0JYcTi+Zcq1kdC2KfGBKL/E2hPoYODNHDMS0B/6i5/vaPUGlq1y2 ip8WbKK49wxFy1V6qw1LCWmia5MwK1V3REZWmbrCqJ5UBQqLEb5JXCSBIrVR7oArLdQG xt9GF9yeWCCFchsMQdVd5CmHqlCRkZ+szXdEE/NrI0DOZU7JbIVxiXWgmGAG1pX8T7ck J/xxKseipjGQa61V9nPHSBjMN7KNhDtpztnrdRu16BQqkkPqZOHjG5k8EPNAt/DTbMpo 7A1Q== X-Gm-Message-State: ANoB5pmu/E3pyZqcTDEQS6T7b3aWrfgPzjN6lG+cihUgj4AZEjKzyCVD HeEDGeCzDNCmlQACv7lpvAm/0g== X-Received: by 2002:a05:600c:1d0a:b0:3cf:735c:9d5a with SMTP id l10-20020a05600c1d0a00b003cf735c9d5amr2297722wms.113.1668532742172; Tue, 15 Nov 2022 09:19:02 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:91c8:7496:8b73:811f]) by smtp.gmail.com with ESMTPSA id bg40-20020a05600c3ca800b003cf78aafdd7sm16846461wmb.39.2022.11.15.09.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 09:19:01 -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 Cc: qyousef@layalina.io, chris.hyser@oracle.com, patrick.bellasi@matbug.net, David.Laight@aculab.com, pjt@google.com, pavel@ucw.cz, tj@kernel.org, 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 v9 2/9] sched: Introduce latency-nice as a per-task attribute Date: Tue, 15 Nov 2022 18:18:44 +0100 Message-Id: <20221115171851.835-3-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221115171851.835-1-vincent.guittot@linaro.org> References: <20221115171851.835-1-vincent.guittot@linaro.org> 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 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 --- 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 23de7fe86cc4..856240573300 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); -- 2.17.1