Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp773598pxp; Fri, 11 Mar 2022 14:46:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxI+2SSAPe4e7EPnBYEue9nxDAdDOkhKeYbPVsdmSeRICs8/eH60T5TSMHNziwuTsX09KUh X-Received: by 2002:a17:902:e949:b0:14d:8ab1:919 with SMTP id b9-20020a170902e94900b0014d8ab10919mr12737681pll.122.1647038786681; Fri, 11 Mar 2022 14:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647038786; cv=none; d=google.com; s=arc-20160816; b=yd41tYbQYALlhZeeJmiJhbgogvgD9GTp+t6j/uylxpLUIu7hpgL7CNcMKDTxRMwuxd 62yzDHpSqsUid4sOmy7ZpEk5zvJSeOjGMhK+ioH932lvkBUVwNTSDAB6XQ7bwJr/c7ne vUin/RmCSV1k0Ln0iz1UmljDCueQU+MDcWABeHyxria0UWpGWLgkApcroalC9ISbZXnv h1JqLyDocEQQB3jP4urGKNco+JezEPRxFOF+kgXZuDh0roKp5xdKSUesIBbRPDIeen8h 9hFCJo1KblVzCxJEsqU6WE0BwBOSDoi7S1YklRZxQKbi56+NyYeLlhD5dVT45lhtJ7bi WenA== 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=+DjhWNCi1uAUKSxL3o4kQa/u0xQ6TtRjRzuu8WmiLaA=; b=HWGKf4u1aPo46BK06jvEiS+owgIZ2rsAtWrYZBn3MG76C99+jsIVqH+t6PtCH4bVPR 1W9f2T9Vk23vGFr1n8J1d8bQjgqaxjAvvMZwvcxejktutZVPo3RF7DBYVxK5yTevQ3fZ j3JN4W/PQaQ8fm86qFkaig1p6Ioz0gcsTv8hqNZfP8auYdekrX6znFxJ7buPdYwSmHH9 ZCyiY5qP5pV27e/5QFCR79BdspaIW0zvVsjv0nTxsAccGZOkcfBAvFlrH/VrEPxUpZH1 I+cAT8z9pawqmeMeETHUOfIV0fNdH3+raNfgnxH1hI+SqEuQZBnTb+AyLva3oOhKTTTn LeZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SL+WZJnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s11-20020a17090a880b00b001bd14e01f63si8744319pjn.81.2022.03.11.14.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:46:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SL+WZJnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CABBF2D59A8; Fri, 11 Mar 2022 14:00:28 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350166AbiCKQPW (ORCPT + 99 others); Fri, 11 Mar 2022 11:15:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350151AbiCKQPT (ORCPT ); Fri, 11 Mar 2022 11:15:19 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB98818A798 for ; Fri, 11 Mar 2022 08:14:14 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id u1so13646416wrg.11 for ; Fri, 11 Mar 2022 08:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+DjhWNCi1uAUKSxL3o4kQa/u0xQ6TtRjRzuu8WmiLaA=; b=SL+WZJnQKpD0l7IOGXck34pr1hW6R496L7GYyFu03/z798wBhFlB76Bu6IUwjmvZfj lJ3anW+iAlNt8KPB6/NbTRTwT+rZEPi3Rae1oXXiV/KNNzbB86EfqLn83VSGRO3VNLra yhkX7jlBCKuaYv8qQe4U5enUppkW7wT/7Elbtaw68HFwpYz2VSCwS3aYh5fDHdfG6bAm 9MnLglDvVLr6nxBRefcerGlP+KjTJwGAA0WaHy+Cn6raBL3Y4a4j4EcALzv4/QgxuH12 Jpbq4/4LGg2XJm5slMrBm5X4cyQXoo9os/bpa9uy5Qn+gxmr1gCukxRWw8Cn+oybayDY UPXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+DjhWNCi1uAUKSxL3o4kQa/u0xQ6TtRjRzuu8WmiLaA=; b=JH/mUnYZLG8tQhwP9dpc+vzXDQ5f6lZcIB7zgyC4Kza/8yYd3uIizG/mX1/M68Sm8R aZ0Cu0n20tqHvmComiZRnagNA+i+xPWeRAqlCD33VTxM9uwM3t3z4H4tRFYey8DWcppG Gc9TYefKHzlO1s25OBn7jEpdRAyl5Z2a2kVCK+dbrAEGJ7d9dxFUhQKToKbXEZCs07ag fPR4siFo9v97bD6HAkfsQkynXSL23Cuw2XaAaAwdCBeiODRiNvrUQ5ffJVGStu9xQ8hT +W+qeECF4pt3NbnLqT1U7gun+ThtW2BPXqJ7cNFizL6zsStYAakqCqjV4Y6pfG5CyGEd 4avg== X-Gm-Message-State: AOAM530SQbIXwkDWjDgcgUPBdzd7xx/CV8Emo8Sf/3l4XefR4J2GOYgk Ke7B41RM8TT3+HjVn/BfOXwAJA== X-Received: by 2002:a5d:500e:0:b0:1f0:2509:ee3f with SMTP id e14-20020a5d500e000000b001f02509ee3fmr8180955wrt.381.1647015253226; Fri, 11 Mar 2022 08:14:13 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:70d9:405c:a1e4:4d23]) by smtp.gmail.com with ESMTPSA id 4-20020a056000154400b00203812ca383sm6464137wry.78.2022.03.11.08.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 08:14:12 -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, linux-kernel@vger.kernel.org, parth@linux.ibm.com Cc: qais.yousef@arm.com, chris.hyser@oracle.com, pkondeti@codeaurora.org, valentin.schneider@arm.com, patrick.bellasi@matbug.net, David.Laight@aculab.com, pjt@google.com, pavel@ucw.cz, tj@kernel.org, dhaval.giani@oracle.com, qperret@google.com, tim.c.chen@linux.intel.com, Vincent Guittot Subject: [PATCH 1/6] sched: Introduce latency-nice as a per-task attribute Date: Fri, 11 Mar 2022 17:14:01 +0100 Message-Id: <20220311161406.23497-2-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220311161406.23497-1-vincent.guittot@linaro.org> References: <20220311161406.23497-1-vincent.guittot@linaro.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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] Signed-off-by: Vincent Guittot --- include/linux/sched.h | 1 + kernel/sched/debug.c | 1 + kernel/sched/sched.h | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 508b91d57470..2aa889a59054 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -779,6 +779,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/kernel/sched/debug.c b/kernel/sched/debug.c index 102d6f70e84d..5d76a8927888 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); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9b33ba9c3c42..456ad2159eb1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -105,6 +105,24 @@ extern void call_trace_sched_update_nr_running(struct rq *rq, int count); */ #define NS_TO_JIFFIES(TIME) ((unsigned long)(TIME) / (NSEC_PER_SEC / HZ)) +/* + * 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 + /* * Increase resolution of nice-level calculations for 64-bit architectures. * The extra resolution improves shares distribution and load balancing of -- 2.17.1