Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp455997ybf; Fri, 28 Feb 2020 01:10:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwxwiAMbVGHq4hhSzfSyCLCglt544I/bjFAgNiCYldZQs0D/lLS/XNMZJRWoDfaUU3Y1RsD X-Received: by 2002:aca:dd05:: with SMTP id u5mr2396594oig.91.1582881027896; Fri, 28 Feb 2020 01:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582881027; cv=none; d=google.com; s=arc-20160816; b=UgUON4yDgoYDmCkSB3sayn5Hxvsz5dybZUSvRw5C1P3JXKGeVVcKkHX5PSrMRSJDHJ QslNdXZMBCSq2cX+Pig8vWIOLQKVY/1ip8yoXH7kM/chbZVxeNQsJiJOpn86b7quz++8 DzCVjasvwm1EyTp8mgLwayPDH9hVNztVtRpGhEWXjpGPJ8gXuLtaI4oQbt29ALtUrdJp nYa6yR008R56YWJ394T6Iq3X1F+6jYVf72dLoeu+6HU3dMgOB1mtsvEFe57Il/WlmjHw zVSZ/DYByvrk2aEMAtkMAUUEY3i90OVRzyDAYpbpp2qPPWY3mPv5xd0l4Vw54vBGKUDi 2A3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=83uLx13CE6UHSTnCcCr0TMySML95azmzfjMJjIFNHGo=; b=loDUz4GtdK80fGtNhmFSom0M7doFVVnj/T97M747xCMLaqWQk2SmiIHSNf9XAa2aey MlVubHeU+McxZdwYh+YnNI0LJmODVTxQ9QSAuq/0S5ckccuc5cTEMFXKwmcRwDQPQDOY AzEladFKYL3e63UzptWkAKGzN11ApDsmd0qIsqdjlUZvI0kz8Fu0dCQj0TiSxa32BGKG wMa0V0ZF0cApyfMFIaBjbJhx2WzQzrSkGgrvX/DcGKAZ0lepC88ciS/6sTvfdKhLbp6e Hw4+2I4vSELdowFJCiRKv3mtJb+zDoxejFteDxSV5VgAzCtTXx1XFbk12IAksbmswask gyzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t22si1193981otc.167.2020.02.28.01.10.15; Fri, 28 Feb 2020 01:10:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726887AbgB1JI3 (ORCPT + 99 others); Fri, 28 Feb 2020 04:08:29 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:27956 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbgB1JI2 (ORCPT ); Fri, 28 Feb 2020 04:08:28 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01S91qpx030091 for ; Fri, 28 Feb 2020 04:08:27 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2yepy6e6qf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Feb 2020 04:08:25 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 28 Feb 2020 09:08:07 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 28 Feb 2020 09:08:02 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01S974Tn46399824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Feb 2020 09:07:04 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 69C06AE058; Fri, 28 Feb 2020 09:08:01 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA78CAE051; Fri, 28 Feb 2020 09:07:58 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.18]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Feb 2020 09:07:58 +0000 (GMT) From: Parth Shah To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, qais.yousef@arm.com, chris.hyser@oracle.com, pkondeti@codeaurora.org, patrick.bellasi@matbug.net, valentin.schneider@arm.com, 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 Subject: [PATCH v5 1/4] sched: Introduce latency-nice as a per-task attribute Date: Fri, 28 Feb 2020 14:37:52 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200228090755.22829-1-parth@linux.ibm.com> References: <20200228090755.22829-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20022809-0016-0000-0000-000002EB1742 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022809-0017-0000-0000-0000334E4F99 Message-Id: <20200228090755.22829-2-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-28_02:2020-02-26,2020-02-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=1 spamscore=0 clxscore=1015 phishscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002280075 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Qais Yousef --- 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 2e9199bf947b..cf23c147dd36 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -679,6 +679,7 @@ struct task_struct { int static_prio; int normal_prio; unsigned int rt_priority; + int latency_nice; const struct sched_class *sched_class; struct sched_entity se; diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 8331bc04aea2..2a96dadc9752 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -958,6 +958,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 2a0caf394dd4..a857e1baebd7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -101,6 +101,24 @@ extern long calc_load_fold_active(struct rq *this_rq, long adjust); */ #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.2