From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBBB2C56202 for ; Thu, 26 Nov 2020 09:09:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CC0F20DD4 for ; Thu, 26 Nov 2020 09:09:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VEwDua+o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389148AbgKZJIi (ORCPT ); Thu, 26 Nov 2020 04:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389036AbgKZJId (ORCPT ); Thu, 26 Nov 2020 04:08:33 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7767EC0613D4 for ; Thu, 26 Nov 2020 01:08:33 -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=2zXA8xrVRXPGgqB9cMk3pA+Z8nviwDoJP0B7lI7X6RU=; b=VEwDua+o40NYyE2dEiASgNcM1n Prr3FJf0uYJodu1QlSxpdqmB7nB5Mo6+Svjv5cNNjMxq4pVGPNGWRAg+wUqI+iP3J4bg6WeW7cZsd e4HLiuwjAWT0YRGkMdgblo3zH6otgS0weiEigKES7HkIIzDrYI4mAXE9aJr8eJqXaUaDQW2GtsX+a ldiVdCs8CPNDhw/GUgpApOPUccwRDdZUwbGdKCl/zjthdO785o0DPJFZ5Acle7mcmd3B6JswNWI1U t4G3oofD2QlQwor6rQRWvMBSgYXF5p0uR5O44XRHhE7wLFPwzGeHuqiz/dSi2Vdhjbdc2/qLaY4tP 4eL3aY/Q==; 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 1kiDFB-0005yJ-Uk; Thu, 26 Nov 2020 09:07:14 +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 73F393059DE; Thu, 26 Nov 2020 10:07:10 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 414A32CF9A1E7; Thu, 26 Nov 2020 10:07:10 +0100 (CET) Date: Thu, 26 Nov 2020 10:07:10 +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: <20201126090710.GF2414@hirez.programming.kicks-ass.net> References: <20201117232003.3580179-1-joel@joelfernandes.org> <20201117232003.3580179-3-joel@joelfernandes.org> 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 Wed, Nov 25, 2020 at 05:28:36PM +0100, Vincent Guittot wrote: > On Wed, 18 Nov 2020 at 00:20, Joel Fernandes (Google) > > +#ifdef CONFIG_SMP > > +static struct task_struct *pick_task_fair(struct rq *rq) > > +{ > > + struct cfs_rq *cfs_rq = &rq->cfs; > > + struct sched_entity *se; > > + > > + if (!cfs_rq->nr_running) > > + return NULL; > > + > > + do { > > + struct sched_entity *curr = cfs_rq->curr; > > + > > + se = pick_next_entity(cfs_rq, NULL); > > Calling pick_next_entity clears buddies. This is fine without > coresched because the se will be the next one. But calling > pick_task_fair doesn't mean that the se will be used Urgh, nice one :/ > > + > > + if (curr) { > > + if (se && curr->on_rq) > > + update_curr(cfs_rq); > > + > > Shouldn't you check if cfs_rq is throttled ? Hmm,... I suppose we do. > > + if (!se || entity_before(curr, se)) > > + se = curr; > > + } > > + > > + cfs_rq = group_cfs_rq(se); > > + } while (cfs_rq); > > + > > + return task_of(se); > > +} > > +#endif Something like so then? --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4354,6 +4354,8 @@ check_preempt_tick(struct cfs_rq *cfs_rq static void set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) { + clear_buddies(cfs_rq, se); + /* 'current' is not kept within the tree. */ if (se->on_rq) { /* @@ -4440,8 +4442,6 @@ pick_next_entity(struct cfs_rq *cfs_rq, se = cfs_rq->last; } - clear_buddies(cfs_rq, se); - return se; } @@ -6982,20 +6982,29 @@ static void check_preempt_wakeup(struct #ifdef CONFIG_SMP static struct task_struct *pick_task_fair(struct rq *rq) { - struct cfs_rq *cfs_rq = &rq->cfs; 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; - if (curr && curr->on_rq) - update_curr(cfs_rq); + /* 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; - se = pick_next_entity(cfs_rq, curr); + if (unlikely(check_cfs_rq_runtime(cfs_rq))) + goto again; + } + se = pick_next_entity(cfs_rq, curr); cfs_rq = group_cfs_rq(se); } while (cfs_rq);