Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp428036pxb; Thu, 31 Mar 2022 08:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRBXNctsCaXLWZWVvd/nTW0xdirh8JmeNlqCoQT/uTUJ1T0sCzJdLwOcRE+GlqVg4/nZ83 X-Received: by 2002:a17:902:a413:b0:156:15b:524a with SMTP id p19-20020a170902a41300b00156015b524amr5890116plq.106.1648740733934; Thu, 31 Mar 2022 08:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648740733; cv=none; d=google.com; s=arc-20160816; b=0WhKlgEEbbXTPyuXCV/CL8cglTS9aR4OReVIy8T1xNVtFKa4iJ5GwBi7jdG524pVuK uEH6twdFdNtRArCUwHe8Q/zIGctGCV/+OCXA0NNu6xhqgWeCXS2VdjiDNbFdcQ5H0wKe LLB5DCcUjskVPQ3LjRA+CNoktpEVSrM+zbsPj0u86AJK342IDTR5FQv5Mb3zwawV3nvv trpDTOB7XXVt3642LC0ywVAwQ7ZyCu1/vwW816aN6CsjPw19mcAxlwxtJaWHEldxrbdM pgB88TxFNpDPx/R/rNghMRnwdm6s6qyTWsRdVS7FQRkFFEzh5IT/iprMbH0Lwgj13Fh3 g3tQ== 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=B/zRduQvtiaKtm4fp81K8YIkVw/D3P2vKnzcPBQVppg=; b=PmuYykjBknGqNgZHN57QfFVPcCDIkY4L3+K+r4cZXKaMbEklQa0qCQJXCr9F2YNP+E KxcGnfAFFH9Wu8P4rcryQ6Benx0xIZCMmjXWbi5uiZMcoFk/0E9H2wlZsNJ+Gj9olqtb Vmvwll+qdxsxO/VBwJqSbtLjT/lkn96D10IrKOOsqcsLyQ2jDt7an9mYoYjZAQ4zWNYa 9sk+HRqZMozizzJsiaGPD7QWea/PPkiWSadodZiaJgV3D+zrO5qnpYL+9prfS4gVDGaq SR0RPyz2hAOQiKZN3qQLVAP98tmOr864jmaliB/XEkkFT6RdgaSjv/U+sN6pE2iQnzfI jv0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=n9O7D5Vk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n64-20020a632743000000b003816043ef93si25175792pgn.392.2022.03.31.08.31.59; Thu, 31 Mar 2022 08:32:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=n9O7D5Vk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235132AbiCaLtT (ORCPT + 99 others); Thu, 31 Mar 2022 07:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbiCaLtS (ORCPT ); Thu, 31 Mar 2022 07:49:18 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C926F20826F for ; Thu, 31 Mar 2022 04:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=B/zRduQvtiaKtm4fp81K8YIkVw/D3P2vKnzcPBQVppg=; b=n9O7D5VkAfDLSOuzTQhQL79hvu NthO6bLDZ08uHcmP0igXjwk4xwMskc9ZrkbR/HJCf+Viyz4MEdZ5gcXpgijEFaskfv2oBFZS6z1sU 9j+uu2u+dEqUm0FtSmGf54DGK25/AF4LYw7J+OlWV8S5wW9akHZkMFTteaco+GwYuuvz1ZWBR5Ppy kZm1up92Nndozycb4X86NKLhJDY6/2ar811JPCASmq99TrEkQGsVAQbTfNJ2pX3zyEjMcRBPwCZsx HXcnMvlNIhnWbXtrT1xUhYZbBR+t/HZOnMRPbmAlM3J/2Mx1UXBWhUWcc5LNFojcktWk9tCRJ9vFn f8c3JT1A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZtGi-0002pI-4C; Thu, 31 Mar 2022 11:47:13 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id CE9B89861D6; Thu, 31 Mar 2022 13:47:09 +0200 (CEST) Date: Thu, 31 Mar 2022 13:47:09 +0200 From: Peter Zijlstra To: Vincent Guittot Cc: Tim Chen , Ingo Molnar , Juri Lelli , Yu Chen , Walter Mack , Mel Gorman , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] sched/fair: Simple runqueue order on migrate Message-ID: <20220331114709.GS8939@worktop.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's been 3 months since I wrote these patches, so memory is vague at best :/ On Tue, Mar 29, 2022 at 11:03:44AM +0200, Vincent Guittot wrote: > > +static void place_entity_migrate(struct cfs_rq *cfs_rq, struct sched_entity *se) > > +{ > > + if (!sched_feat(PLACE_MIGRATE)) > > + return; > > + > > + if (cfs_rq->nr_running < se->migrated) { > > + /* > > + * Migrated to a shorter runqueue, go first because > > + * we were under-served on the old runqueue. > > + */ > > + se->vruntime = cfs_rq->min_vruntime; > > + return; > > + } > > + > > + /* > > + * Migrated to a longer runqueue, go last because > > + * we got over-served on the old runqueue. > > + */ > > + se->vruntime = cfs_rq->min_vruntime + sched_vslice(cfs_rq, se); > > +} > > + > > static void check_enqueue_throttle(struct cfs_rq *cfs_rq); > > > > static inline bool cfs_bandwidth_used(void); > > @@ -4296,6 +4317,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) > > > > if (flags & ENQUEUE_WAKEUP) > > place_entity(cfs_rq, se, 0); > > + else if (se->migrated) > > + place_entity_migrate(cfs_rq, se); > > > > check_schedstat_required(); > > update_stats_enqueue_fair(cfs_rq, se, flags); > > @@ -6973,14 +6997,15 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) > > * wakee task is less decayed, but giving the wakee more load > > * sounds not bad. > > */ > > - remove_entity_load_avg(&p->se); > > + remove_entity_load_avg(se); > > } > > > > /* Tell new CPU we are migrated */ > > - p->se.avg.last_update_time = 0; > > + se->avg.last_update_time = 0; > > > > /* We have migrated, no longer consider this task hot */ > > - p->se.migrated = 1; > > + for_each_sched_entity(se) > > + se->migrated = READ_ONCE(cfs_rq_of(se)->nr_running) + !se->on_rq; > > Why do we need to loop on se ? Isn't p->se enough ? Yeah; I really don't recall why I did that. And looking at it now, it doesn't really make much sense. I suppose it will trigger place_entity_migrate() for the group entries, but on the old CPU.