Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1951986ybz; Thu, 30 Apr 2020 08:17:59 -0700 (PDT) X-Google-Smtp-Source: APiQypLfdRT/bRxcAALplDKwa1G+B6hOPFvjrnMVf+ew3QDLt9TIdLoHQd+UiLqEa8LpRQvvUT7l X-Received: by 2002:a17:906:200a:: with SMTP id 10mr3022199ejo.294.1588259879123; Thu, 30 Apr 2020 08:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588259879; cv=none; d=google.com; s=arc-20160816; b=cu0jR71sBaKLa3h6OSY+Hr7OTJOrkhNsO47pyPY5dgU0UZyE5318ZPMxs5ZR051jav lt42fTJyFWgkg/i0f59MYlZ1j+vOs8LgPskg+/dHXdeMS+0XAyQfFp7ifkhUqoBhry0t IQ3pKMLD4rntxUbc5n0khrm1jCf3Fo1PAm7HE9Cwj/Jkhx6qERrUg0VscvfsAOnzZM6i TsV07LakPTwHto+PrLltNbaPgE4YCxPSY44akKeD5Nqs8l3X8xlW3vhrlPUSADrpv9qh 7f0gsPCLU7YS4ccED+K8laRh5WHKladAJ5phZfzQ1l5fBd0XvbTtLQ6vp2kk65gNARs+ H8PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=bseDTGJCaQj/ufqdvwkZ0bXU/AGc9+u7Y27ug6Gzvu8=; b=IUAHICgxGYWbMaON6AfUv5SW1+qVV2LV/drvoCK53NNcY6mzZsyK8ep7qpKi2J6e2M raZNqos9FvIwyZi/OYBTFS/+r3wBL0BLdN5fEkYqiVCqYo/Vg4B3toJyH8oEJrxySRA4 ORp5cQmjmsUGDpwIgrsJ4ik6gaKz62e7vxsaO6SFA35HpuGA+iVoHa7Jb6LRQOpqVklW YZ6DSlK9gb6PR+F9BZTBJYqI7ettfvpJEm8YGkTvAAici/Xw42I2fVY0HzFxMcwNEq/b a/2dtfluY0nv5SMWo9uyk4Cbo/aEux0b27ZSRmYpPWs8ELyUt5SduCJjVVTABmNG88u9 aDCQ== 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 d24si5514151edy.387.2020.04.30.08.17.33; Thu, 30 Apr 2020 08:17: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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbgD3PNb (ORCPT + 99 others); Thu, 30 Apr 2020 11:13:31 -0400 Received: from foss.arm.com ([217.140.110.172]:57228 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgD3PNa (ORCPT ); Thu, 30 Apr 2020 11:13:30 -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 114D31FB; Thu, 30 Apr 2020 08:13:30 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8E8B33F68F; Thu, 30 Apr 2020 08:13:28 -0700 (PDT) References: <20200424041832.11364-1-hdanton@sina.com> <20200424043650.14940-1-hdanton@sina.com> <20200430121301.3460-1-hdanton@sina.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Dietmar Eggemann Cc: Hillf Danton , Peter Zijlstra , Ingo Molnar , lkml , Mike Galbraith , Steven Rostedt , Mel Gorman , Vincent Guittot , Phil Auld , Mark Rutland Subject: Re: [PATCH 2/4] sched: set new prio after checking schedule policy In-reply-to: Date: Thu, 30 Apr 2020 16:13:26 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/20 15:18, Valentin Schneider wrote: > On 30/04/20 15:06, Dietmar Eggemann wrote: >>>>> + 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 >> ... > > > Good catch; I suppose we'll want to special case SCHED_IDLE (IIRC should > map to nice 20). > > As you pointed out, right now the newprio computation for CFS tasks is > kinda bonkers, so it seems we'll almost always clear DEQUEUE_MOVE from > queue_flags for them. > Of course I misread that, it's the other way around: since newprio is always 99 for SCHED_OTHER/BATCH/IDLE tasks, we'll never have new_effective_prio == oldprio (unless pi involves a FIFO 99 task), thus will never clear DEQUEUE_MOVE. > For CFS, not having DEQUEUE_MOVE here would lead to not calling > update_min_vruntime() on the dequeue. I'm not sure how much it matters in > this one case - I don't expect sched_setscheduler() calls to be *too* > frequent, and that oughta be fixed by the next entity_tick()) - but that is > an actual change.