Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2688602ybl; Sat, 7 Dec 2019 22:05:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyMW4BvIK4p7LgMZu1vRZyt4WOdh3f0vAi/f4xQyjEqS4JTOGx3FLxEmEmeKr4iRvzuCwC3 X-Received: by 2002:a9d:5888:: with SMTP id x8mr16521573otg.361.1575785134416; Sat, 07 Dec 2019 22:05:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575785134; cv=none; d=google.com; s=arc-20160816; b=uOvMgqA6hhnw2t+QdEYMO70+W0wmZMZ+jdFLZZNLEFsIV8WE/nKsLA2SRsBZbwSSGK 43U0GpIu75u4Et5EdKAHiLvnQ0BR4nTSVNin8G9Ui9ekVTPsORdFnVN8ka7l+HkpnUQ0 cvFhVFBHUr4etNAtMkZQSpEJIKOWaJFEhuRwnaVsFI2AaqMRNVDu21YXy+fisl0JN0hC /Zf/8tV5am/0MClogCCmXmxxIpcFpYGj125xcXbAEihNpTvsgFni4RASoljLbUgoUfCZ d7DEWx+aaDSOX6Ehh8Tx0zzAXsaZeTnOwuGGilMdzDucsXqKaMBxzpuaBo3M31zPdKbb AdCw== 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=UrB60ZofgRQwic/gDdY4MEGlyHYuK8KVjdaJcqT2dw4=; b=HTWZOVplSqfWrkGYbgf+D38UboFrFfKQCy34cZ/PN5ccIxaAuzfZ29HKl3ID/RZZKS TQ3Op4J6+g+KvbUHLrxsZ88Uho2VJQUGrF3EwR/dwtoec8gB9EYnDfPbiI63YreCkLxM 2i49Nsrjaagl2gg0gZcc/1dQe5Xx9l7IPnQORHD4aO80ZSbu/ggCDpGRYnALyZl8BqUK rSVK4FHL5Fz6gs5hqkfbYwax+gNW5oCRtMv6LzPl9kfbFsKWRi3PLDLJuwWSlw7ZI8hl PoTOLr8DXPKyj5zM/djMV8awmyFtK9jBi739LV6V5WSsguViuFA9LsMwMak/pBsCwiY3 C5ZA== 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 x8si10613279oto.259.2019.12.07.22.05.22; Sat, 07 Dec 2019 22:05:34 -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 S1726472AbfLHGEe (ORCPT + 99 others); Sun, 8 Dec 2019 01:04:34 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44196 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfLHGEd (ORCPT ); Sun, 8 Dec 2019 01:04:33 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xB85xGJL032730 for ; Sun, 8 Dec 2019 01:04:32 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wr7s7g7hy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 08 Dec 2019 01:04:31 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 8 Dec 2019 06:04:28 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 8 Dec 2019 06:04:22 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xB864LkV47513818 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 8 Dec 2019 06:04:21 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE00411C04A; Sun, 8 Dec 2019 06:04:21 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C772911C04C; Sun, 8 Dec 2019 06:04:17 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.71.101]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 8 Dec 2019 06:04:17 +0000 (GMT) From: Parth Shah To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, patrick.bellasi@matbug.net, valentin.schneider@arm.com, qais.yousef@arm.com, pavel@ucw.cz, dhaval.giani@oracle.com, qperret@qperret.net, David.Laight@ACULAB.COM, pjt@google.com, tj@kernel.org, dietmar.eggemann@arm.com Subject: [PATCH v2 1/3] sched: Introduce latency-tolerance as a per-task attribute Date: Sun, 8 Dec 2019 11:34:08 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20191208060410.17814-1-parth@linux.ibm.com> References: <20191208060410.17814-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19120806-0020-0000-0000-000003957198 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120806-0021-0000-0000-000021ECA8B3 Message-Id: <20191208060410.17814-2-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-08_01:2019-12-05,2019-12-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 suspectscore=1 spamscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912080054 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Latency-tolerance 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_tolerance = -20 indicates the task to have the least latency as compared to the tasks having latency_tolerance = +19. The latency_tolerance may affect only the CFS SCHED_CLASS by getting latency requirements from the userspace. Signed-off-by: Parth Shah Reviewed-by: Qais Yousef --- include/linux/sched.h | 1 + kernel/sched/sched.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 84b26d38c929..d5f907d7a91a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -676,6 +676,7 @@ struct task_struct { int static_prio; int normal_prio; unsigned int rt_priority; + int latency_tolerance; const struct sched_class *sched_class; struct sched_entity se; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 280a3c735935..3d68aaad02cc 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 tolerance is meant to provide scheduler hints about the relative + * latency requirements of a task with respect to other tasks. + * Thus a task with latency_tolerance == 19 can be hinted as the task with no + * latency requirements, in contrast to the task with latency_tolerance == -20 + * which should be given priority in terms of lower latency. + */ +#define MAX_LATENCY_TOLERANCE 19 +#define MIN_LATENCY_TOLERANCE -20 + +#define LATENCY_TOLERANCE_WIDTH \ + (MAX_LATENCY_TOLERANCE - MIN_LATENCY_TOLERANCE + 1) + +/* + * Default tasks should be treated as a task with latency_tolerance = 0. + */ +#define DEFAULT_LATENCY_TOLERANCE 0 + /* * Increase resolution of nice-level calculations for 64-bit architectures. * The extra resolution improves shares distribution and load balancing of -- 2.17.2