Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp448996ybk; Wed, 13 May 2020 04:29:59 -0700 (PDT) X-Google-Smtp-Source: APiQypLcbOLz+murJXZ6F1r80oSjhAOSHj+11gEArB/dhv20YZm5gRI0oPET9IQwnxac472uOoWx X-Received: by 2002:a50:9b58:: with SMTP id a24mr15293289edj.256.1589369399250; Wed, 13 May 2020 04:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589369399; cv=none; d=google.com; s=arc-20160816; b=mexaOZhJlGJitd+ImVdBD5jt9QGaY413bss4vb5b3gCg4xod7CDKeIedGKeKTBetee 4igiXcu/TJ9ve9/GAlKNE1M8OnSgjDJDJTI1UuufMz3DPyH7RLSyq5we255k9PfOek+b 6+RpAFZT11iPI8oUSliG5Do08J29LxaPkbg8wix6ds1DisF5dL+y9b4VYAnmkKC5wFiy v8juSSDSCINfm15ZidEgKq/aSFMNPkAcC2Qqv9t49f7BclOdTBT8XfaJ8zyS2nVOLs8V Pdd2/DSzhlFiG2q/WVw4D3NcBmfSuALA11HIeZuJ0x8snmiWWbLf0NtoVH66wRVMZOZ5 mO6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=UClyyMHZbBF2RqcqoHgO0eYDz2a6FXj8VRN3Rzo8Z9A=; b=aULf2KrzcqTR6Hh7b8GpBavTEa1jmrbgqxX3+x9gmyitxNqsbYFU0KaUipjQV9wVIG 0XrYGEYc1ZjsiPm5OvPInc10PuBYuzhn/hjqWTdp9lUZZR8fjUPtkdhVs9MKU4sAOfzU HNnRx+Ax+UKUAK8vhAR/BzNDcupDeHQlBxhstG4ebHgeuhdf8vOQQNbsuV2u9cfnEWUA 9n/0k/i+teYKbkuIdT54Qx6F3SX+YS5hV7bvO/UdcJiM/lT9/QI/VgAGT013pl8WuMv/ H6HcxR2jCPKwdJAma6d8eq6BqhIkhYTUcls9STSW7kkestGlZOjxeW9lHOQ/GMRWdZmC fwEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a3si9484208edv.206.2020.05.13.04.29.36; Wed, 13 May 2020 04:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731504AbgEMLPY (ORCPT + 99 others); Wed, 13 May 2020 07:15:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35140 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbgEMLPX (ORCPT ); Wed, 13 May 2020 07:15:23 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04DB1xpa022374; Wed, 13 May 2020 07:15:06 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3101m17sxu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2020 07:15:05 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04DBAo9K061317; Wed, 13 May 2020 07:15:05 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3101m17swb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2020 07:15:05 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04DBF2k9020086; Wed, 13 May 2020 11:15:02 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 3100uc0jnq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2020 11:15:02 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04DBF0OB57082046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2020 11:15:00 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 275BCAE045; Wed, 13 May 2020 11:15:00 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7DC1AE04D; Wed, 13 May 2020 11:14:54 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.94.237]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 13 May 2020 11:14:54 +0000 (GMT) Subject: Re: [PATCH v5 3/4] sched: Allow sched_{get,set}attr to change latency_nice of the task From: Parth Shah To: Dietmar Eggemann , linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, 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 References: <20200228090755.22829-1-parth@linux.ibm.com> <20200228090755.22829-4-parth@linux.ibm.com> <00bf190a-6d84-48aa-83cb-b25e6c24777c@arm.com> <6fc4bbba-c024-1248-4837-977f0adba2d3@linux.ibm.com> Message-ID: Date: Wed, 13 May 2020 16:44:53 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <6fc4bbba-c024-1248-4837-977f0adba2d3@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.676 definitions=2020-05-13_04:2020-05-11,2020-05-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 cotscore=-2147483648 impostorscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005130096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/13/20 3:11 PM, Parth Shah wrote: > > > On 5/11/20 4:43 PM, Dietmar Eggemann wrote: >> On 28/02/2020 10:07, Parth Shah wrote: >>> Introduce the latency_nice attribute to sched_attr and provide a >>> mechanism to change the value with the use of sched_setattr/sched_getattr >>> syscall. >>> >>> Also add new flag "SCHED_FLAG_LATENCY_NICE" to hint the change in >>> latency_nice of the task on every sched_setattr syscall. >>> >>> Signed-off-by: Parth Shah >>> Reviewed-by: Qais Yousef >> >> [...] >> >> ndif /* _UAPI_LINUX_SCHED_TYPES_H */ >>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >>> index 866ea3d2d284..cd1fb9c8be26 100644 >>> --- a/kernel/sched/core.c >>> +++ b/kernel/sched/core.c >>> @@ -4710,6 +4710,9 @@ static void __setscheduler_params(struct task_struct *p, >>> p->rt_priority = attr->sched_priority; >>> p->normal_prio = normal_prio(p); >>> set_load_weight(p, true); >>> + >>> + if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE) >>> + p->latency_nice = attr->sched_latency_nice; >>> } >> >> How do you make sure that p->latency_nice can be set independently from >> p->static_prio? >> >> AFAICS, util_clamp achieves this by relying on SCHED_FLAG_KEEP_PARAMS, >> so completely bypassing __setscheduler_params() and using it's own >> __setscheduler_uclamp(). >> > > Right. good catch. > Use of SCHED_FLAG_LATENCY_NICE/SCHED_FLAG_ALL is must to change > latency_nice value, but currently setting latency_nice value also changes > static_prio. > > One possible solution here is to move the above code to _setscheduler(): > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 6031ec58c7ae..44bcbf060718 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -4731,9 +4731,6 @@ static void __setscheduler_params(struct task_struct *p, > p->rt_priority = attr->sched_priority; > p->normal_prio = normal_prio(p); > set_load_weight(p, true); > - > - if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE) > - p->latency_nice = attr->sched_latency_nice; > } > > /* Actually do priority change: must hold pi & rq lock. */ > @@ -4749,6 +4746,13 @@ static void __setscheduler(struct rq *rq, struct > task_struct *p, > > __setscheduler_params(p, attr); > > + /* > + * Change latency_nice value only when SCHED_FLAG_LATENCY_NICE or > + * SCHED_FLAG_ALL sched_flag is set. > + */ > + if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE) > + p->latency_nice = attr->sched_latency_nice; > + > > This should allow setting value only on above flags, also restricts setting > the value when SCHED_FLAG_KEEP_PARAMS/SCHED_FLAG_KEEP_ALL is passed. and also get rid of __setscheduler_params(p, attr) when attr->sched_flags == SCHED_FLAG_LATENCY_NICE Other way is surely to bypass keep_param check just like UCLAMP. > > > Thanks, > Parth >