Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1894915ybz; Thu, 30 Apr 2020 07:21:37 -0700 (PDT) X-Google-Smtp-Source: APiQypKo7GV/42ygLofYI+dzBB3tsQ4F/RNjuFaMukdFwLLuP67XZkj7u8I3nD1XqkwPojeifX5c X-Received: by 2002:aa7:d0d6:: with SMTP id u22mr3040306edo.262.1588256497347; Thu, 30 Apr 2020 07:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588256497; cv=none; d=google.com; s=arc-20160816; b=ltaOGkZi5RN0QFrqY7MvEdbcxVCr58b1ShMvItORN7YcAK6Uh4MNTsp7FIaM6pbH4v no2woP7z6LyJ1z82GoiSNl386kANTV9VTaI4fGzGr2U1jkFlfbM6f6ViqwdolaEuY8Zd ZVcoVISN7Dda6t1XYureFJNlSNff9nLLxdKbjWnYnI8XA7O0gv2z1PVy4dg3H2bux5t2 B+mPkL+RHtXZhnn54f3eJvxcIBln0m3IC3cB3uolk3pzbSCLKV5WYquO00XFqrNM7yZv BCv2+uPb5HsI+3FQxn22/QS1IsXL+RyY1wFC4+ZFe1MTgHjS75Ke1b3axHu8hzHDJrw9 CQkg== 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=epiXdY2pOLxZOSnodgUq4JAegx6DdxmytZT1Lg2SBZ0=; b=xbRQhDx1WR8LVNJXjkHXfBh/kimupFXBd5yGb0bbJgQ5eJ4o/L+5JKBuLi9Vu8J2lY TdHUT6bKcPFR9xD9apzO7PCQU/yPIBMx+v9METcwFtPtm8YggVMqOQpHt9jKOwzIUbho yumqOBTh7W6dH93kVTCnUjhTyO9mwfcSZffoKbBPAroYjaQ4iPLoW2KnOCy5ebZd1Cft S4DopkfOLIP14TvNOurE8qmZsU4BrgS7/ri2l25gYfcjWEBmUpT9DkoMgaoeZMPmDA/V rbI0mjMMUuEJtybsu163fbuXkK05Q2K96wbJmRI7K/vfTg8WcCTAIkregF7QMciDVpiP zyLA== 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 p1si5875972ejw.313.2020.04.30.07.21.13; Thu, 30 Apr 2020 07:21:37 -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 S1726885AbgD3OSq (ORCPT + 99 others); Thu, 30 Apr 2020 10:18:46 -0400 Received: from foss.arm.com ([217.140.110.172]:55924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbgD3OSq (ORCPT ); Thu, 30 Apr 2020 10:18:46 -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 387BC1063; Thu, 30 Apr 2020 07:18:45 -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 C1CAD3F68F; Thu, 30 Apr 2020 07:18:43 -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 15:18:41 +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: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. 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.