Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7689371ybl; Thu, 16 Jan 2020 04:05:02 -0800 (PST) X-Google-Smtp-Source: APXvYqwyQUbAHmj3bQQdGhqKc2KJaDdlr10jS6e7Y69JQoXc8DwmES1rSwSBUagIka8SlSHVSW2r X-Received: by 2002:a9d:1d02:: with SMTP id m2mr1543773otm.45.1579176302032; Thu, 16 Jan 2020 04:05:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579176302; cv=none; d=google.com; s=arc-20160816; b=Mkf4WtrJzFiuNyzoiOoTPMUgf9ZgR4J7eS7Q97bNnMs9jbA80SbNn1jaJEi4n5CoCS xIyncx2fFNbBBvbbRKa1AYooz87geMcTPxzTTsMGAO+Pngwibjdf+qqvDMnqh3OXlfK2 qV4zpJa0Tt4g+BROSPeSa8pDs0Plgv5lis1/JrD6zOY7+zNwGk6GP2DmTe8qF8YePHBM zh41QGqbIGRektYzgEpDxXcu8WWKveGhBN5qV+nqEfdNN2OyF9oz/5ie7sLzZAntZE23 NXURv590xN7C/myKiqJI+fb/56bqySXU8OMV2PN8pChhtAJQpiRfjgpUlizNVw5hWUe3 MQJw== 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=FBt37izEl+FpZaz2/jI/P5B8OGkpkFIq3nAvlp61tE4=; b=azWIbgNOcIKxGHRZrlm2m61g+nnpMAq5jG7kTaPAj7ptdftB1vDbjs2VdPfZ8UG9FO WA3jkJAAsBT0vG/Qwee3U2F0tEpd89zcLKR5e7Kum1CTjDrcSNCIa8qkG5+bRMjQMDIu 8NzPZQtL++dDKh6lib4ILFy9gMiRYvx9btuAOTbbWM/1RAAV7o/clqx62D0zmF9mTd5p CzRmdb0mOHA7VLnxang7vG/GQjNp0uu7wObu9T+maFWSVtgx3n+QZrALxKnm2jNU5q6g R6vXEHmzaQlM62dZc9M1uxu1TDhoQHmpYp2A7BSIW0TggvX+jidUA9PZdF5iNXwv/pGH pI4Q== 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 c79si11972230oig.208.2020.01.16.04.04.49; Thu, 16 Jan 2020 04:05:02 -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 S1726845AbgAPMCp (ORCPT + 99 others); Thu, 16 Jan 2020 07:02:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56336 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726160AbgAPMCo (ORCPT ); Thu, 16 Jan 2020 07:02:44 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00GBvVMq117995 for ; Thu, 16 Jan 2020 07:02:43 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xhgs7uk2c-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Jan 2020 07:02:42 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 Jan 2020 12:02:41 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 Jan 2020 12:02:36 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00GC2ZHO61407420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 12:02:35 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC9CAA4053; Thu, 16 Jan 2020 12:02:35 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89C0EA405D; Thu, 16 Jan 2020 12:02:33 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.120]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 Jan 2020 12:02:33 +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 v3 1/3] sched: Introduce latency-nice as a per-task attribute Date: Thu, 16 Jan 2020 17:32:28 +0530 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200116120230.16759-1-parth@linux.ibm.com> References: <20200116120230.16759-1-parth@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20011612-0008-0000-0000-00000349E23B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011612-0009-0000-0000-00004A6A3BCC Message-Id: <20200116120230.16759-2-parth@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-16_03:2020-01-16,2020-01-15 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001160103 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. 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 467d26046416..0668948fddcd 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_nice; const struct sched_class *sched_class; struct sched_entity se; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 1a88dc8ad11b..edae9277e48d 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