Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5780250imm; Mon, 27 Aug 2018 04:16:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZDRIRCBFT/jPBuKZu8dKyp6H1koVpsFB1cmDHoJkSZvjyzPZ4qnvlGm5SFp6ByK+JYtu5 X-Received: by 2002:a63:5204:: with SMTP id g4-v6mr11771829pgb.274.1535368614146; Mon, 27 Aug 2018 04:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535368614; cv=none; d=google.com; s=arc-20160816; b=0z2458ofbiiCVdjIWPdZwKYrFpFZvvf54IdyBMmWDrWK7Y3ozj0tHyYnoeJgheCz+U 9nrDcXsmtO66hbGTMrmYJPZbX2GHkYT/RF9DGaO20HEosoTu6+10cJb4AJOaW+aB36Ss 9AoVd1qzrrY81kgTVdGqbbHih2Kj1c1WDV7MHRKltjdOqG6TfQ5aOrVxQVenez24LO5v JMv+Ri3xECLlYJgPhXiKBf95jl3i/PPie75TA6V8CN/WPO6Hlqoj03tMqmx+4CtSci4l r60+oTrVZ5PDqxhRnJ+1QJZyt+WHYsO5wkbqrdPugUY8XEwOsOXCIYdAR95KdvuOSsQ0 I4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=J4Qmd2lna15d2oscrCMDFsZyNTB9HIqjLoxsx0c2Ays=; b=yuadVwBwI6HAzxNwCXYsoh7Zx3572G7BiWeMoLreOMkdhgavUXnSWzTO1CSgpvRjII 9t0e2FSFn2A4v4DzUirjkSCvRW+R0xWPbVO2ZiqHYTbcihQY6dKzMP8TN/9T9lRH/3yv Yiw2ms7a6MPUlRcIG0Kp76XQM6wJENNE2qQtKxFcsqmYraMC1TKarPvFF88cHb7CQBNy We6781ZuVLVNj8y+boxGk2Q5u9msVQ8G9m3IlVRCFpsiH51/uEQrwtaxUmmGiVHy7sZn G7A7uqomgrGuO6FWZ7+1eycHwSR7k3id8QtdNKZwBS3AZnjqTi+eFMsNVZytxC66Sqbj /sxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=jf84q63s; 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 33-v6si13403937plk.300.2018.08.27.04.16.38; Mon, 27 Aug 2018 04:16:54 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=jf84q63s; 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 S1727206AbeH0PBW (ORCPT + 99 others); Mon, 27 Aug 2018 11:01:22 -0400 Received: from merlin.infradead.org ([205.233.59.134]:60922 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbeH0PBV (ORCPT ); Mon, 27 Aug 2018 11:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=J4Qmd2lna15d2oscrCMDFsZyNTB9HIqjLoxsx0c2Ays=; b=jf84q63sy7MV44f6gn+ofBtgz tgWJ8NYsmILL+zUxojkKfe9PUBYQLopby1yOZK9YRXhd409OTMy4Rn9bzsHAa6flj1qkv/jMjTWRV JtxLxQ+3WGkhk+AICi+3L3M/CjFO17u0hBp+FgCC8T58TodaaMHnpRB5b6/vkn/VajABFiaqTKrSZ G2yvxFRESQaipz3UJlsYf2ZEBjQYajbB1vXd+ZHZmDcBCCYbIJ6NwBm9mZxw8lrs+VWephL0zU+qj BIfjLbbCSenS0Cu7hD2LJlE4ta5PYFNEtw6OrfOMVVbzQjXg9DFDZ7BS6tBJ5OOP1OIZdj9wKRkAQ QrTIQKYXA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuFU4-0001hH-4I; Mon, 27 Aug 2018 11:15:00 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B06992024EB1B; Mon, 27 Aug 2018 13:14:58 +0200 (CEST) Date: Mon, 27 Aug 2018 13:14:58 +0200 From: Peter Zijlstra To: Steve Muckle Cc: 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 Subject: Re: [PATCH] sched/fair: vruntime should normalize when switching from fair Message-ID: <20180827111458.GB24124@hirez.programming.kicks-ass.net> References: <20180817182728.76129-1-smuckle@google.com> <20180824093227.GN24124@hirez.programming.kicks-ass.net> <20180824094742.GJ24142@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 24, 2018 at 02:24:48PM -0700, Steve Muckle wrote: > On 08/24/2018 02:47 AM, Peter Zijlstra wrote: > > > > On 08/17/2018 11:27 AM, Steve Muckle wrote: > > > > > > > When rt_mutex_setprio changes a task's scheduling class to RT, > > > > > we're seeing cases where the task's vruntime is not updated > > > > > correctly upon return to the fair class. > > > > > > > Specifically, the following is being observed: > > > > > - task is deactivated while still in the fair class > > > > > - task is boosted to RT via rt_mutex_setprio, which changes > > > > > the task to RT and calls check_class_changed. > > > > > - check_class_changed leads to detach_task_cfs_rq, at which point > > > > > the vruntime_normalized check sees that the task's state is TASK_WAKING, > > > > > which results in skipping the subtraction of the rq's min_vruntime > > > > > from the task's vruntime > > > > > - later, when the prio is deboosted and the task is moved back > > > > > to the fair class, the fair rq's min_vruntime is added to > > > > > the task's vruntime, even though it wasn't subtracted earlier. > > > > I'm thinking that is an incomplete scenario; where do we get to > > TASK_WAKING. > > Yes there's a missing bit of context here at the beginning that the task to > be boosted had already been put into TASK_WAKING. See, I'm confused... The only time TASK_WAKING is visible, is if we've done a remote wakeup and it's 'stuck' on the remote wake_list. And in that case we've done migrate_task_rq_fair() on it. So by the time either rt_mutex_setprio() or __sched_setscheduler() get to calling check_class_changed(), under both pi_lock and rq->lock, the vruntime_normalized() thing should be right. So please detail the exact scenario. Because I'm not seeing it.