Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1881033ybz; Thu, 30 Apr 2020 07:08:53 -0700 (PDT) X-Google-Smtp-Source: APiQypKfogTQ36u4QBzi6DxsIPTOjp3+/GcYL5R2EFfP06DWuEf8BGgac2DXWtVDFX0oHk9I7jcL X-Received: by 2002:a17:906:d14b:: with SMTP id br11mr2891779ejb.213.1588255733775; Thu, 30 Apr 2020 07:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588255733; cv=none; d=google.com; s=arc-20160816; b=Bt5juu88AHWlO9acgPW1hlBsr2rLFif2Wa2Ht/nZEyGRp/4kSK+ZTRkVf+wcaRxVH5 bWQG1681ZY+dQWD83T54iHMO9RAo3E4YENpLWYEgB6HBtRpIn0+zez4jJXplLrjO2psy NWKFUVby/V0NMtVpS0ZPgsFVcSGpRIhgP73EyDpe5XODvafSxd++EBrftHWQgrgLD6tC kBWsSUTwft3fy+TdCMVVEFzhAmMQqawxe80nSJx8hgLGEIdK3XfR53iq3yaQqxEMqeNy rS0eEuMIbkMR8B6kwor2KjchO7h9zzgogWidSX9y/NXQlGAagZKcSatfS4lyR7iljLNB WRBg== 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:from:references:cc:to:subject; bh=1piNCoAKY1JBRpXyVEEvb7c8uzVZ52NGm765f9B50GI=; b=OOszxDbGm8boseUp/V96qs4AT6qGRT8XbH5cagiurtY/vtWuZjHz136VWp+TK4hdNv 4bRzUXdaW1xP+98GYwGRExjIae5znUQJz5rutmWRFbfQokJqs8xmNqsc3VJJHNu+yWbz UIJ6qkoOSYTBPiIomv/pmJsrvk0zBn1G/mlwjNVu7Sm7xkk5Zzwkbs3KNrrKASsQ8Bc6 +rEQhDwhhgYuFGQcrRRcbELq9EYbItLZsxEt+H8t6e87L13naEGrAjkNwbvx/Bj3wWpT UuTD5SYGG46y4F/60H3xSFkskolMXO1gSgheLoNcEXISpaQIFdPUPsPzr8VgsTPrH/p9 0g+A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b89si5109752edf.345.2020.04.30.07.08.27; Thu, 30 Apr 2020 07:08:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728581AbgD3OGa (ORCPT + 99 others); Thu, 30 Apr 2020 10:06:30 -0400 Received: from foss.arm.com ([217.140.110.172]:55612 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728752AbgD3OGT (ORCPT ); Thu, 30 Apr 2020 10:06:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8CB241063; Thu, 30 Apr 2020 07:06:18 -0700 (PDT) Received: from [192.168.0.7] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DCE0E3F68F; Thu, 30 Apr 2020 07:06:16 -0700 (PDT) Subject: Re: [PATCH 2/4] sched: set new prio after checking schedule policy To: Hillf Danton , Valentin Schneider Cc: Peter Zijlstra , Ingo Molnar , lkml , Mike Galbraith , Steven Rostedt , Mel Gorman , Vincent Guittot , Phil Auld , Mark Rutland References: <20200424041832.11364-1-hdanton@sina.com> <20200424043650.14940-1-hdanton@sina.com> <20200430121301.3460-1-hdanton@sina.com> From: Dietmar Eggemann Message-ID: Date: Thu, 30 Apr 2020 16:06:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200430121301.3460-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/2020 14:13, Hillf Danton wrote: > > On Tue, 28 Apr 2020 17:32:45 Valentin Schneider wrote: >> >>> + else if (fair_policy(policy)) { >>> + if (attr->sched_nice < MIN_NICE || >>> + attr->sched_nice > MAX_NICE) >>> + return -EINVAL; >> >> We can't hit this with the syscall route, since we (silently) clamp those >> values in sched_copy_attr(). setpriority() does the same. There's this >> comment in sched_copy_attr() that asks whether we should clamp or return an >> error; seems like the current consensus is on clamping, but then we might >> want to get rid of that comment :) >> > Yes it's quite likely for me to miss the cases covered by that clamp; > otherwise what is added does not break that consensus. > >>> + newprio = NICE_TO_PRIO(attr->sched_nice); >> >> This is new, however AFAICT it doesn't change anything for CFS (or about to >> be) tasks since what matters is calling check_class_changed() further down. > > Yes it's only used by rt_effective_prio(). > Looks like changing a SCHED_NORMAL to a SCHED_BATCH task will create a different queue_flags value. # chrt -p $$ pid 2803's current scheduling policy: SCHED_OTHER pid 2803's current scheduling priority: 0 # chrt -b -p 0 $$ ... [bash 2803] policy=3 oldprio=120 newprio=[99->120] new_effective_prio=[99->120] queue_flags=[0xe->0xa] [bash 2803] queued=0 running=0 ... But since in this example 'queued=0' it has no further effect here. Why is SCHED_NORMAL/SCHED_BATCH (fair_policy()) now treated differently than SCHED_IDLE? # chrt -i -p 0 $$ ... [bash 2803] policy=5 newprio=99 oldprio=120 new_effective_prio=99 queue_flags=0xe [bash 2803] queued=0 running=0 ...