Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2210205pxp; Mon, 21 Mar 2022 13:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKGX93tqbS/TVWkR9tLsflcwtd+bLmk37XFBfLXtUsM+J6w4+17OhEe7UmsaibXfm5/4QX X-Received: by 2002:a17:90b:1c0d:b0:1c7:3b02:aa68 with SMTP id oc13-20020a17090b1c0d00b001c73b02aa68mr1013093pjb.187.1647896335576; Mon, 21 Mar 2022 13:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647896335; cv=none; d=google.com; s=arc-20160816; b=YxM0QdOq8Bg4zwd3BzEeirqkbCJ16FL+0EJ4g0SRkQSF2wafKRred3R0TiTJlz+1LQ dBOBxtELjRgsDHBeASmjEPQBr7i7kOIyXavMMCfVUSi07d4Tbfub8nqU7clSZoO26HQs PRhEJen4QVg2EcYFYqTHiVjP/EE8+X5caegPI9SzR5DZM672Z5K8iLlG3W/rTPCdjfWj QhlBGuzfPkp1Y/V2I9VdlR/vc6EAG31Ws4t38H7HrTTOUD8XDgLg9Y+opiEYCtnGC/eM gquQairI3hgW/mfpgzbVdmi0zamwKfGFPBsybgM6Fhs/9Po3mi7G+gsFXtBVVNeh0grE FeMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=oSOPvkTLp9oAxRzDK0c6l+GAQFOnzOPThfWsyVaFIgE=; b=dYx8Fg5JQA87ZBVp4rXk2G5HaIXpKO8tJLDjbPrUr0McAMpbaCbhoYQsVqFpATaww6 FrGhNu+7LV1lluEDmrlXBgavLcC51ErdonMLdvvtdprZ5o6CavxSGJ5u2mwV3UjpHr8v 9XO3VApsiaWMs8UDNd/tuUblPeleRBK5uo6ueX9mGTMjXtEC0tgElOZ7IN696yOJ8o8h 9x08e8E76Yrx2AguOo01exutaaGJ3B2PL69K+EBbbP03wJNJ8R3kmp0ylZFnDCrXfv6Z 0dsXpEVaAxpmkcADD2XJEmJzPQ1D+q4ULd51XT+/NeQ7LlaKqKl65alZli8j5SBHoumd CS9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b18-20020a056a000cd200b004fa3a8dff9dsi4682149pfv.84.2022.03.21.13.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 13:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 896F519609D; Mon, 21 Mar 2022 13:55:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351809AbiCURZL (ORCPT + 99 others); Mon, 21 Mar 2022 13:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345862AbiCURZK (ORCPT ); Mon, 21 Mar 2022 13:25:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F1F7ECD90 for ; Mon, 21 Mar 2022 10:23:44 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2493F1042; Mon, 21 Mar 2022 10:23:44 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E452C3F66F; Mon, 21 Mar 2022 10:23:42 -0700 (PDT) Message-ID: <710b460f-20b9-21c4-3077-8cea35600550@arm.com> Date: Mon, 21 Mar 2022 18:23:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 2/7] sched/fair: Decay task PELT values during migration Content-Language: en-US To: Vincent Donnefort , peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org Cc: linux-kernel@vger.kernel.org, morten.rasmussen@arm.com, chris.redpath@arm.com, qperret@google.com References: <20220308181957.280354-1-vincent.donnefort@arm.com> <20220308181957.280354-3-vincent.donnefort@arm.com> From: Dietmar Eggemann In-Reply-To: <20220308181957.280354-3-vincent.donnefort@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 08/03/2022 19:19, Vincent Donnefort wrote: Patch header: s/during migration/during wakeup migration ? To make sure it's not related to lb migration (TASK_ON_RQ_MIGRATING). [...] > Neither clock_task, clock_pelt nor clock can be accessed without the > runqueue lock. The new cfs_rq last_update_lag is therefore created and > encode those three values when the last_update_time value for that very s/encode/encodes ... It's not really encoding? [...] > Now we have an estimation for A + B, we can create an estimator for the > PELT value at the time of the migration. We need for this purpose to > inject last_update_time which is a combination of both clock_pelt and > lost_idle_time. The latter is a time value which is completely lost form a s/form/from > PELT point of view and must be ignored. And finally, we can write: > > rq_clock_pelt_estimator() = last_update_time + A + B > = last_update_time + > sched_clock_cpu() - last_update_lag rq_clock_pelt_estimator() did exist in v2 but does not in v3 anymore. Might be misleading when people search for it. [...] > @@ -3688,6 +3704,7 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq) > cfs_rq->last_update_time_copy, > sa->last_update_time); > #endif > + update_cfs_rq_lag(cfs_rq); > > return decayed; > } > @@ -6852,6 +6869,44 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > > static void detach_entity_cfs_rq(struct sched_entity *se); > > +#ifdef CONFIG_NO_HZ_COMMON Couldn't you put update_cfs_rq_lag() and migrate_se_pelt_lag() under one CONFIG_NO_HZ_COMMON? > +static inline void migrate_se_pelt_lag(struct sched_entity *se) [...] > + /* > + * The lag estimation comes with a cost we don't want to pay all the > + * time. Hence, limiting to the case where the source CPU is idle and > + * we know we are at the greatest risk to have an outdated clock. > + */ > + if (!is_idle) > + return; > + > + last_update_lag = u64_u32_load(cfs_rq->last_update_lag); So each taskgroup has its own last_update_lag. I guess it works since we sync se in migrate_task_rq_fair() -> remove_entity_load_avg() -> sync_entity_load_avg() with its cfs_rq. [...] > @@ -6859,6 +6914,9 @@ static void detach_entity_cfs_rq(struct sched_entity *se); > */ > static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) > { > + struct sched_entity *se = &p->se; > + struct cfs_rq *cfs_rq = cfs_rq_of(se); This line can stay in the if condition below since cfs_rq is only used there. The brackets are also still there (A). [...] > @@ -6866,8 +6924,6 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) > * the task on the new runqueue. > */ > if (READ_ONCE(p->__state) == TASK_WAKING) { > - struct sched_entity *se = &p->se; <--- (A) > - struct cfs_rq *cfs_rq = cfs_rq_of(se); [...]