Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp197700imn; Wed, 27 Jul 2022 03:59:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vVYjJNQysF+jp/mghZowZ96zn0FVXgJDjZMW/aeGSW8INcH6vkvPlTabPC7KuF6HnBJBJq X-Received: by 2002:aa7:de91:0:b0:43a:d5b0:e0bb with SMTP id j17-20020aa7de91000000b0043ad5b0e0bbmr22251366edv.165.1658919549330; Wed, 27 Jul 2022 03:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658919549; cv=none; d=google.com; s=arc-20160816; b=Qc6cf3yCDdZDcgW6nzGtCDXuNAYHk5DXFYkTwxBP7Ne+B6Qi5u8DBIGagbR8X3gA/Q jKqeuDBUHscHvmR93uFmCQ7yoDx8QHgDhb7FcMOxzAOsH1adD47vjgcZpqHUXPEBrFRZ TZCN8DbvT3Lbxdt/3H/LQ4L//f2/WZ5o573hJj+uNWpDddSmqs94IYiPxPwgC53j9b+S t0ENugfUdct6L7YldvXjRfnP0Mak2Vin15g0I/RUoVc1WyYOXziDnRstx1FE1day7C67 nYDBQO2ZJ3tfCct+4oldOl850b9+o1PQalqs72LAt29X9/DX8At31xPZ7w+lBLTcZZAK UUkw== 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:dkim-signature; bh=NwH2wazb67m8SHtqlH7y9TgCFprrSka3vLwtXCOoEz4=; b=nwQKTrCKcFh1CzBQJ5Bwi0cShHBsSmkjMTh6aF3VkHbp6L5H9QBPZF/6/iX2w2JSvJ zkpiqU7a/1Xpk6KCZytTkW99tUr7+zoCffcaIf4rmL9floZPDOdRG+u0BePdrZRJZwy/ /OvO91dRaFgQoHlZooHTuAbEcI8IJIt7CUKk9YK4/Cfc87KBghCw0NarEjJdRd60dLPX eZcAcpupcLMcxftrFzXOh/glNwJ7eCIZZJGPq+ctdceLXTv5g7F9XRLcwatRhVOCQXcw 5OKLcOMl2UvMBm4odmExMKfXiTRomxPPngf1XYhXrlg6h7e4mQvOccjwHZZJYQkydlmV jTpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1FKk1ryM; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a056402520f00b0043c45284ef9si5922180edd.562.2022.07.27.03.58.44; Wed, 27 Jul 2022 03:59:09 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1FKk1ryM; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbiG0Kzq (ORCPT + 99 others); Wed, 27 Jul 2022 06:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbiG0Kzj (ORCPT ); Wed, 27 Jul 2022 06:55:39 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 118923E765 for ; Wed, 27 Jul 2022 03:55:38 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id 70so15822006pfx.1 for ; Wed, 27 Jul 2022 03:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=NwH2wazb67m8SHtqlH7y9TgCFprrSka3vLwtXCOoEz4=; b=1FKk1ryMpPV0kycnP8NuMg7A8i/j6pKesCdWoPLhkwKIn88gBPfAoowHMtJTkSaqUi sB+p/IftV/nCcPoZn6Uh8lEY8+gdksnWmz2JQKhCxD6L0IjyC36WYFb8mDh4bcFS8dkM MxpXAOQPV1DEMQvyYn0bOGb1bcDDqr5H56KMH/F2O2gbw17VB5rZwvXDJ46ICkJgHFMx mjOMLBkACPnhx+doBRZddWMVE3lAC4Tn0paXsuAqt4+2qiQyTdXZvonnNOGVijaA0GLt P3Dj/ariwLD7KlLTaCHOOO8NtSXpQqrgvUAd/gKEIl2e37d0ohtyyBcGkdb2nKq7IBV+ r+BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=NwH2wazb67m8SHtqlH7y9TgCFprrSka3vLwtXCOoEz4=; b=60lmYh7KHKZ6A07lW4SiCF4v3zNoqnEBZ1zJR6wsX/Y8g4FURRmYLVN8Xpxq16q7LQ T8YQ/lMZi4y2fpnVjJEWiVLRVxhEF98ogjMNKkw3MsMd3ww9WQlivJsM5iENCmIDyWsq jPsYnHhd+sHE8Z1XUW+kj+jjUVq4wy5PRmcdaMJckZOMwmAyrQAIpbwAx9pmRAwyHWAN zuIa7/DAnSilozObboZrr7DVZmAwGU176qz8zuj+vipNcqGRHIkeiKr9paPvqVmA1KfW nPzkUR4IokFiF8H4lR8t5q7Yg7iv8/pr8zfyYBAGVB1NefBlKG/Y/7qiU/20SzIvmQBv usiQ== X-Gm-Message-State: AJIora/kyGTz0VTl0GUL2XJyP9xlOXj7WZm4QMiXEH1ci2v1up18fBeK 4C9Ra/OFBnVM/5luDA6z+7UoAQ== X-Received: by 2002:a63:2051:0:b0:412:6d61:ab0a with SMTP id r17-20020a632051000000b004126d61ab0amr19091264pgm.52.1658919337485; Wed, 27 Jul 2022 03:55:37 -0700 (PDT) Received: from [10.4.228.171] ([139.177.225.235]) by smtp.gmail.com with ESMTPSA id 63-20020a621942000000b005255263a864sm13453978pfz.169.2022.07.27.03.55.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Jul 2022 03:55:37 -0700 (PDT) Message-ID: <011a2a34-69c4-0d12-0121-92d6f526a23b@bytedance.com> Date: Wed, 27 Jul 2022 18:55:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 Subject: Re: [PATCH v2 09/10] sched/fair: stop load tracking when task switched_from_fair() Content-Language: en-US To: Vincent Guittot Cc: mingo@redhat.com, peterz@infradead.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, vschneid@redhat.com, linux-kernel@vger.kernel.org References: <20220713040430.25778-1-zhouchengming@bytedance.com> <20220713040430.25778-10-zhouchengming@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On 2022/7/19 21:20, Vincent Guittot wrote: > On Wed, 13 Jul 2022 at 06:05, Chengming Zhou > wrote: >> >> The same reason as the previous commit, if we don't reset the >> sched_avg last_update_time to 0, after a while in switched_to_fair(): >> >> switched_to_fair >> attach_task_cfs_rq >> attach_entity_cfs_rq >> update_load_avg >> __update_load_avg_se(now, cfs_rq, se) >> >> The delta (now - sa->last_update_time) will wrongly contribute/decay >> sched_avg depends on the task running/runnable status at that time. > > I think that we always decay the time spent in !fair class and never contribute > > This one is a bit more complex than the new task one. Generally > speaking, I would say that we should decay the load while running in > !fair case because the value becomes less and less relevant over time. > What's the meaning of pelt values when the task has run seconds as a > fifo ? The only case that would need a particular attention, is the pi > boost case but there is no way to now how long is runs and sleep when > !fair After thought for a while, I agree with you on that the PELT values become meaningless after running as a FIFO task. So yes it's best for now to always decay them when switched_to_fair(). So in the next version: 1. don't set for !fair in post_init_entity_util_avg() 2. keep last_update_time when switched_from_fair() 3. should we still keep SKIP_AGE_LOAD ? I don't understand what's its usage in switched_to_fair(). Or should we just delete it? Thanks! > >> >> This patch reset it's sched_avg last_update_time to 0, stop load >> tracking for !fair task, later in switched_to_fair() -> >> update_load_avg(), we can use its saved sched_avg. >> >> Signed-off-by: Chengming Zhou >> --- >> kernel/sched/fair.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 50f65a2ede32..576028f5a09e 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -11552,6 +11552,11 @@ static void attach_task_cfs_rq(struct task_struct *p) >> static void switched_from_fair(struct rq *rq, struct task_struct *p) >> { >> detach_task_cfs_rq(p); >> + >> +#ifdef CONFIG_SMP >> + /* Stop load tracking for !fair task */ >> + p->se.avg.last_update_time = 0; >> +#endif >> } >> >> static void switched_to_fair(struct rq *rq, struct task_struct *p) >> -- >> 2.36.1 >>