Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1147382pxu; Fri, 27 Nov 2020 00:25:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwojsq4T2YYLGGBk2ZQv0Nj5EgIJl+dd4kgnep5CGRF7j9hhPOnC9cT0KseJbIHTwaeGGag X-Received: by 2002:a05:6402:22c9:: with SMTP id dm9mr6333833edb.96.1606465517281; Fri, 27 Nov 2020 00:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606465517; cv=none; d=google.com; s=arc-20160816; b=eU+pM6JaJzxjJ7ghufeR4BgqsJf0QpVj6zTZ8d7eqVmqzJuhb6kjNtKVid4Q3LbJ2i e5537SDlcuPib7wU0vLpY5jRB9bUdlLCn1xU3uCJgmfQzDXLEsF6YYTbqdmZf454F4rW tKJqse0Ec13575/e0UmQeYRsumsUKLBrzzdX/s4rSGbJIJOUwbiJo2f1s9h24FJ3DB6w zoxkpVqzvUJ6HYgSOptR9PQjHWnCN83oFNCrlMXVrgCHghd3pr/m+sRnoTHIBs3Wq2M5 WR57f8r4qfwNeFqsWnSrouxW2AkB7l8moiQaev1Ptbm8MmAKGuxqT4RbNPCGERsUlp4G /1xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=p0O18K0NodQGhP9nF2NIBoqyFyxWCXdlWgRp9cTuHDI=; b=dDOsK2CRUQQoYEPtY+CYEm4A+Ttn0ZPMacW3clKqnfQ6rv9nhtVi3iOxG6EC+TvNKa KQ0TREA8qr7zaeOhvZ/VVYKD2Jp/sX2BD9/XlIWquIfnoGFqLKtEEKtaBQ/Ao4MNBRIl /EgwIgz97FIT3ksA1FVaAaadiqGHT/qVp5gqCFsvinbLNId7/n+VG92Udtl8cwxCAdIB KX9o2rRoxLq7OiXIPio3WYWVKb1IcYHjoSkbppdaWc5nXbQsV9MGLqZEWoRLJa4plbKF ziAONFdT+OXipWakICzN7JeST0O+h7xuRtVsoO1KITNGTUNGL9CCNRVD/vCGSlThCaBC mlSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=TNqsk2kf; 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 j9si2420546ejo.609.2020.11.27.00.24.55; Fri, 27 Nov 2020 00:25:17 -0800 (PST) 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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=TNqsk2kf; 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 S2388766AbgKZMlB (ORCPT + 99 others); Thu, 26 Nov 2020 07:41:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731421AbgKZMlA (ORCPT ); Thu, 26 Nov 2020 07:41:00 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 613E1C0613D4 for ; Thu, 26 Nov 2020 04:41:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=p0O18K0NodQGhP9nF2NIBoqyFyxWCXdlWgRp9cTuHDI=; b=TNqsk2kfryt3Cc20TJ2X7HA10y DPzb8qPVEfnsDd3FvIWJZk9lZKR6jYRrRtGxTXSdjXCwooXFrLeD4v4j9HCKPkXsVQKUCGH5cwFhx rWS1+YW5VKO8/aBxu0QCn/TGPauuE5mjrLV/VyrkulsiR1LA5VT+LrGAi3MUE/PuPAkUoM8YnCqeP wVmdOQhjyCYLiv3qKtcpEwiVVQuSpbYzhYj9waGiFhVxEyXOoDK2lnphCC1jT+7S5ZpSb2mW+TjUB ocl/PbiFTiGz9K71YYpjVfZuF0M37qKdn5To97thpn1z7hnxwZR+mFa8JwNZp/bvgv4f1rffs0HQX inlJAe+w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGZI-0002Gl-Vs; Thu, 26 Nov 2020 12:40:13 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 395293059DE; Thu, 26 Nov 2020 13:40:11 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 22F66201E6BBD; Thu, 26 Nov 2020 13:40:11 +0100 (CET) Date: Thu, 26 Nov 2020 13:40:11 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: "Joel Fernandes (Google)" , Nishanth Aravamudan , Julien Desfossez , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , Thomas Gleixner , linux-kernel , Ingo Molnar , Linus Torvalds , Frederic Weisbecker , Kees Cook , Greg Kerr , Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, dfaggioli@suse.com, Paul Turner , Steven Rostedt , Patrick Bellasi , Jiang Biao , Alexandre Chartre , James Bottomley , OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , jsbarnes@google.com, "Hyser,Chris" , Ben Segall , Josh Don , Hao Luo , Tom Lendacky , Aubrey Li , "Paul E. McKenney" , Tim Chen Subject: Re: [PATCH -tip 02/32] sched: Introduce sched_class::pick_task() Message-ID: <20201126124011.GL3040@hirez.programming.kicks-ass.net> References: <20201117232003.3580179-1-joel@joelfernandes.org> <20201117232003.3580179-3-joel@joelfernandes.org> <20201126090710.GF2414@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 26, 2020 at 11:17:48AM +0100, Vincent Guittot wrote: > > Something like so then? > > yes. it seems ok > > > > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -6982,20 +6982,29 @@ static void check_preempt_wakeup(struct > > #ifdef CONFIG_SMP > > static struct task_struct *pick_task_fair(struct rq *rq) > > { > > struct sched_entity *se; > > + struct cfs_rq *cfs_rq; > > + > > +again: > > + cfs_rq = &rq->cfs; > > if (!cfs_rq->nr_running) > > return NULL; > > > > do { > > struct sched_entity *curr = cfs_rq->curr; > > > > + /* When we pick for a remote RQ, we'll not have done put_prev_entity() */ > > + if (curr) { > > + if (curr->on_rq) > > + update_curr(cfs_rq); > > + else > > + curr = NULL; > > > > + if (unlikely(check_cfs_rq_runtime(cfs_rq))) > > + goto again; Head-ache though; pick_task() was supposed to be stateless, but now we're modifying a remote runqueue... I suppose it still works, because irrespective of which task we end up picking (even idle), we'll schedule the remote CPU, which would've resulted in the same (and possibly triggered a reschedule if we'd not done it here). There's a wrinkle through, other than in schedule(), where we dequeue() and keep running with the current task while we release rq->lock, this has preemption enabled as well. This means that if we do this, the remote CPU could preempt, but the task is then no longer on the runqueue. I _think_ it all still works, but yuck! > > + } > > > > + se = pick_next_entity(cfs_rq, curr); > > cfs_rq = group_cfs_rq(se); > > } while (cfs_rq); > >