Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3779430ybv; Tue, 25 Feb 2020 07:10:54 -0800 (PST) X-Google-Smtp-Source: APXvYqwP9E1eobB1XB7iR2qlQ0Xnirs4EfhLU4MK2step7trb+mP8RtXwNul8OuTOvAnw9KBmJdo X-Received: by 2002:aca:b608:: with SMTP id g8mr1454415oif.142.1582643454492; Tue, 25 Feb 2020 07:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582643454; cv=none; d=google.com; s=arc-20160816; b=KrXB7n1mrjlsZvPc6uv++QWB2YVCyYhLqzmR/SAb+pmvdhuT+r7rjdSSIKTutIs2cN 51pO9dsnSQ+7aTOf5dcxGi52C4STOhzhUQsaVTpidYZNiVDGDBsr3/wUaZlcsHjnojPg ZR21dPPnXMLE3B9rP4EBW01uKPceOUqFBz0q5GFBTV6o5lwl9H2xCV3fprlRAqxFhn6A +JZkktI7oQAPzOnV5v/KmCV33ifewYqlh+yZKBwuWBzwy+Axlp7oJkPK3N6ijgv9BaQJ 2BUrF/xxEXRpeW6Wnc5ZP3wxt3gkzz1I2aC8JslF/oawtR3PZHWLrnd7QcKMwOLh6Kh7 JkVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=VatAFH9FQPzXyIClvueo2DGuenrycNk6Jj2+/cHe5h4=; b=xUroLiFOVxnOX3uXi3W09jPecdEyRoUUplp7KwPdf+p85gas9nb63PSVEGlKBiX+V/ czAt6SGl8Ulr87HoSPXDhy0wdEFESMMVcEd9L3eLAd6eQd+sFHo+Cmz2d6857fHlGndH yphWhUxkS1Ql0n6lALrMTsy15DRt/B0GMjFZxl8Chftwpf3nHcN3vBCal2VakHaaOGnR 2mEMxxV+WYmfbkqtcnROkjiNCrwsALEsj+WFuDQgIHgl1c2A/LyipAVaVMx2Xt3aIFaK 4j34DL0OW4HC4CzChtIhfhgVroP3iWha6vq4LUSUELSa03ICy04SptTXU2P2l3jEmFFr 2Gug== 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 j2si7587375otr.255.2020.02.25.07.10.24; Tue, 25 Feb 2020 07:10:54 -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 S1730990AbgBYPE2 (ORCPT + 99 others); Tue, 25 Feb 2020 10:04:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:62162 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729870AbgBYPE2 (ORCPT ); Tue, 25 Feb 2020 10:04:28 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01PExW4H009745 for ; Tue, 25 Feb 2020 10:04:27 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ycy1py430-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Feb 2020 10:04:22 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Feb 2020 15:04:11 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 25 Feb 2020 15:04:05 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01PF37RX46858616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Feb 2020 15:03:08 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A916852054; Tue, 25 Feb 2020 15:04:04 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.92.137]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 07A2452051; Tue, 25 Feb 2020 15:03:55 +0000 (GMT) Subject: Re: [PATCH v4 3/4] sched: Allow sched_{get,set}attr to change latency_nice of the task To: Pavan Kondeti Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, qais.yousef@arm.com, chris.hyser@oracle.com, 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: <20200224085918.16955-1-parth@linux.ibm.com> <20200224085918.16955-4-parth@linux.ibm.com> <20200225065409.GK28029@codeaurora.org> From: Parth Shah Date: Tue, 25 Feb 2020 20:33: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: <20200225065409.GK28029@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20022515-0012-0000-0000-0000038A29F4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022515-0013-0000-0000-000021C6CCF3 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-25_05:2020-02-21,2020-02-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002250118 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/25/20 12:24 PM, Pavan Kondeti wrote: > On Mon, Feb 24, 2020 at 02:29:17PM +0530, Parth Shah wrote: > > [...] > >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 65b6c00d6dac..e1dc536d4ca3 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -4723,6 +4723,8 @@ 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); >> + >> + p->latency_nice = attr->sched_latency_nice; >> } > > We don't want this when SCHED_FLAG_LATENCY_NICE is not set in > attr->flags. > > The user may pass SCHED_FLAG_KEEP_PARAMS | SCHED_FLAG_LATENCY_NICE to > change only latency nice value. So we have to update latency_nice > outside __setscheduler_params(), I think. AFAICT, passing SCHED_FLAG_KEEP_PARAMS with any other flag will prevent us from changing the latency_nice value because of the below code flow: __sched_setscheduler() __setscheduler() if (attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) return; __setscheduler_params() whereas, one thing we still can do is add if condition when setting the value, i.e., @@ -4724,7 +4724,8 @@ static void __setscheduler_params(struct task_struct *p, p->normal_prio = normal_prio(p); set_load_weight(p, true); - p->latency_nice = attr->sched_latency_nice; + if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE) + p->latency_nice = attr->sched_latency_nice; } > >> >> /* Actually do priority change: must hold pi & rq lock. */ >> @@ -4880,6 +4882,13 @@ static int __sched_setscheduler(struct task_struct *p, >> return retval; >> } >> >> + if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE) { >> + if (attr->sched_latency_nice > MAX_LATENCY_NICE) >> + return -EINVAL; >> + if (attr->sched_latency_nice < MIN_LATENCY_NICE) >> + return -EINVAL; >> + } >> + >> if (pi) >> cpuset_read_lock(); >> >> @@ -4914,6 +4923,9 @@ static int __sched_setscheduler(struct task_struct *p, >> goto change; >> if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) >> goto change; >> + if (attr->sched_flags & SCHED_FLAG_LATENCY_NICE && >> + attr->sched_latency_nice != p->latency_nice) >> + goto change; >> >> p->sched_reset_on_fork = reset_on_fork; >> retval = 0; >> @@ -5162,6 +5174,9 @@ static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *a >> size < SCHED_ATTR_SIZE_VER1) >> return -EINVAL; >> >> + if ((attr->sched_flags & SCHED_FLAG_LATENCY_NICE) && >> + size < SCHED_ATTR_SIZE_VER2) >> + return -EINVAL; >> /* >> * XXX: Do we want to be lenient like existing syscalls; or do we want >> * to be strict and return an error on out-of-bounds values? >> @@ -5391,6 +5406,8 @@ SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr, >> else >> kattr.sched_nice = task_nice(p); >> >> + kattr.sched_latency_nice = p->latency_nice; >> + > > Can you consider printing latency_nice value in proc_sched_show_task() in this > patch/series? Sure, I will add it. Thanks, Parth