Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp642386imm; Wed, 29 Aug 2018 08:35:09 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbhe/3xWzqIqmah90Er5QCKg0P78VEeq66LODUsuV/YiQNtmDpwY5XNvGPGlWRow503gZLA X-Received: by 2002:a17:902:6845:: with SMTP id f5-v6mr6577184pln.17.1535556909358; Wed, 29 Aug 2018 08:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535556909; cv=none; d=google.com; s=arc-20160816; b=B3RTDhgf76I+M/00lfl7y0qSHy8V1ucBsRJsdlouSFmlZA8rLQAuEBrfLVnoLPLvqv XUJXEg7/1s4TTtaLQgzHtbw8iqgukktvP3HnlGovRuZj5fjl+nOObDEbJqgvs+IQhTb+ uB2TOBVMrMa46r5uE1WzuOTg4aDANqOfD/4gbg20x0arpszz1bulVGmyeci66ntFEcFf +QDgQ/FoWIf3BaPt2ZB3IEAxxgvljvxxbZkFW0ekK3LdXkHT3qNmVt076WFHSh5pthDy PooNN1auzg0wwjvXUWcCC4p5X2FSr4tIrDdPF/F9P+/893WL26v+bixGj7AaQm7WH/eY vxMA== 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:arc-authentication-results; bh=037JYyAU5bbLm7XscGoOk7eKhJRaXtGZaIEFzUfN+8Q=; b=1CxksyDSO6R9qJjhL38ZMn3DA4dSpJmDIhxOUv6/sYD7INH8xmIPRq2F795VTMg4GN rRckSVoJxYpYlRnO86gBUkTJ8YYuIMLV8+RkSS4tzWwQ5TKeYXY3y5WsDJgAkbeYTemO WKpiZgKj3a4Q7OtFc5oqw9V04UAWV+uQy0rrufYWq3qm6LjpAR8Kh1QHAg4q5cjz40xN kWr0Jke2Ab9ulDUDy6gpiXQ0rjo6F7ZDN/vd1pPaHTpH/4aZUsOpLV3H9gCvC55/r0Kv dYm9h6De7ZkBhi6GUjmzc1ApbgfabJx8ISBICEzEhBAGS/U5aZxs9US9wdkUqrX41uCG /O0Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v61-v6si3874733plb.448.2018.08.29.08.34.53; Wed, 29 Aug 2018 08:35:09 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729168AbeH2TbF (ORCPT + 99 others); Wed, 29 Aug 2018 15:31:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729107AbeH2TbE (ORCPT ); Wed, 29 Aug 2018 15:31:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1858B18A; Wed, 29 Aug 2018 08:33:36 -0700 (PDT) Received: from [10.1.34.70] (deggeman-mac.cambridge.arm.com [10.1.34.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E82003F557; Wed, 29 Aug 2018 08:33:33 -0700 (PDT) Subject: Re: [PATCH] sched/fair: vruntime should normalize when switching from fair To: Peter Zijlstra Cc: Steve Muckle , Miguel de Dios , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-team@android.com, Todd Kjos , Paul Turner , Quentin Perret , Patrick Bellasi , Chris Redpath , Morten Rasmussen , John Dias References: <20180817182728.76129-1-smuckle@google.com> <20180824093227.GN24124@hirez.programming.kicks-ass.net> <20180824094742.GJ24142@hirez.programming.kicks-ass.net> <20180827111458.GB24124@hirez.programming.kicks-ass.net> <2ed346fa-dbe8-4928-928b-a34338b2d8c9@arm.com> <273b9b52-8c00-0414-ea11-214d81cd57c7@arm.com> <20180829115954.GS24124@hirez.programming.kicks-ass.net> From: Dietmar Eggemann Message-ID: Date: Wed, 29 Aug 2018 16:33:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180829115954.GS24124@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/29/2018 12:59 PM, Peter Zijlstra wrote: > On Wed, Aug 29, 2018 at 11:54:58AM +0100, Dietmar Eggemann wrote: >> I forgot to mention that since fair_task's cpu affinity is restricted to >> CPU4, there is no call to set_task_cpu()->migrate_task_rq_fair() since if >> (task_cpu(p) != cpu) fails. >> >> I think the combination of cpu affinity of the fair_task to CPU4 and the >> fact that the scheduler runs on CPU1 when waking fair_task (with the two >> cpus not sharing LLC) while TTWU_QUEUE is enabled is the situation in which >> this vruntime issue can happen. > > Ohhh, D'0h. A remote wakeup that doesn't migrate. Ah, there is this WF_MIGRATED flag, perfect for the distinction whether a task migrated or not. > That would suggest something like so: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index b39fb596f6c1..b3b62cf37fb6 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9638,7 +9638,8 @@ static inline bool vruntime_normalized(struct task_struct *p) > * - A task which has been woken up by try_to_wake_up() and > * waiting for actually being woken up by sched_ttwu_pending(). > */ > - if (!se->sum_exec_runtime || p->state == TASK_WAKING) > + if (!se->sum_exec_runtime || > + (p->state == TASK_WAKING && p->sched_remote_wakeup)) > return true; > > return false; Yes, this solves the issue for the case I described. Using 'p->sched_remote_wakeup' (WF_MIGRATED) looks more elegant than using 'p->sched_class == &fair_sched_class'.