Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp456216pxu; Thu, 26 Nov 2020 03:09:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPTHTBtC89kcJN+o1ZEpZjPoktoPP0B80SVYBpEChe3xtrUsSHZ1jjmX68GNek0RNm0SXD X-Received: by 2002:a50:8714:: with SMTP id i20mr1989860edb.200.1606388965232; Thu, 26 Nov 2020 03:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606388965; cv=none; d=google.com; s=arc-20160816; b=RVJ4VeXh1nFIo7/4QJqHDqhDBUibu6Sc1No1WF4xW34eIrmbWuIHEV8WPFEWlyLQl0 ZQh4c0eF5SiGDJ/GtyOKqozgtKBLe68vLVM35xj1L4YzpqsSQ+ALgAC7fdlkflUBoydI HASthWit+AGfyQpzmfp/sz0v1mFZaf9fqFv9EOwAJg/lKEmslUmyLAWFURp2kAREARAB 3IXsd+LivVtOxBgsbeAJzNRzk94Lth1erbsdRUbi/AJLgT/yy8BwIVuhLhp920mzSAgT l5LeHi1zPKQEJ2Vsa8BH3BEipKrj67TCGR3QHv+r3QQATYvLp3PRXeN9bkUuXAAq4VJh Qylg== 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=2zXA8xrVRXPGgqB9cMk3pA+Z8nviwDoJP0B7lI7X6RU=; b=rro8/P4D55D6aRIwIoI4vKDxlTjaVmTLFzVn0euGBlIbLyfRhMG3D4x3M0M3K5bPqw j65+H9O/jF7aMYsdwO6+YGMkQDz6EDe4rrH9xt0gBHFxeTgzs1gEipUMDGaj/BMcPd4O hgkuRSMP7plOUPNemBaLKSisfh6hUrcaziqyHboU6OMt7o27qDH/kczsJXFAUCt1wsPh SfyBVr1hT4fD10I2sR2GoPvYJWSec4t6U/3KPLsC/CiANgdjy67WycyVlmOdEEzlYJNH RD7b/4UzYu4yk0mKr+sBqkKNs8cRGdAZocPsMBm+x4WMysqzoX4pNbeigSim/gYY/BHy AOFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VEwDua+o; 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 l25si350257edf.392.2020.11.26.03.09.02; Thu, 26 Nov 2020 03:09:25 -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=VEwDua+o; 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 S2389144AbgKZJIi (ORCPT + 99 others); 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);