Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3091281rdb; Wed, 15 Nov 2023 22:51:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQqoC7z3ZOr+e0aK3aGBZq3gF5AS3vqCST9pEBJGdd9cv9JLEyICqrvJjCMH9UcbiBHG8K X-Received: by 2002:a17:90b:3e89:b0:280:74fc:6545 with SMTP id rj9-20020a17090b3e8900b0028074fc6545mr15088129pjb.24.1700117515390; Wed, 15 Nov 2023 22:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700117515; cv=none; d=google.com; s=arc-20160816; b=anooYQseJedNQ+W3YS13pHufwvvaypKrT5aCLk2UuXKNA3+NTMRUWmeIWArJJtSYev apvB/FBBMXIasdnTYiUeoBpWn66WKyMtslaxcihrWmizCjwlqr34yQoxBpdR8AgRJ8XQ HkAfIf1vy6NtxJS1RRBVQaUEn/KTUo8rJ/2/z1BRMmRE1OqGbsAbb/8KHfY8M21SJACj cXkFbpXzwPoZKjuEbfFRS/g6xuNvHgOOmXDMLSr2RH04JXcddPi3VHBzr6uR3yDCsvEX Jo7LaLE38FKEwMOVP3yrapk4l5N5eDbS24cerYR9hsKj1E6x5/cvA4d65e4BmsajkoUN 5hDA== 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=MeRDN0+BzEJDhzSTXzv3THJfG/m7lmaKGuoDAqx8pdw=; fh=E/ZRa9UJxrbXcIFVKu8KXyfyUCX0lBh7wBYVIHW4JvU=; b=EG/9q6PCFcib3kpRIisNv8T352YLySjSRj1nDoe7IQv7QowvHpyBFunq2IxbZweNUT EuJAn7ZxkuWomrMTmtcT4zP8QiiLIypnYOOMaSFBU5OpWDhZkpRKNHQwqf254nHUTobM HZItpqEsmJThyINJvT77pnWWuEUvWJ16rI2lvPhYpiYpUzpvfeLAhINzj2lsGs9zfgG1 0SvBnC0lkeLFYM3BHw4xUYktqhbSiVuDmofMCRz9N+M2T90lvXHsaAZ59BJv65JoO1i3 grKWUYuTV4DkSNw0tz8XNVXfj+hxWn2ZF2r5O4DGjqt/z+HBqg0iDt7wYo3OB+m/CgpF 3j8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ml6N1yTp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id nh13-20020a17090b364d00b00274df6d4c38si1303438pjb.89.2023.11.15.22.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 22:51:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ml6N1yTp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 87D2081444D8; Wed, 15 Nov 2023 22:51:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbjKPGvi (ORCPT + 99 others); Thu, 16 Nov 2023 01:51:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229638AbjKPGvh (ORCPT ); Thu, 16 Nov 2023 01:51:37 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907B5130 for ; Wed, 15 Nov 2023 22:51:34 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cc3bb32b5dso4506885ad.3 for ; Wed, 15 Nov 2023 22:51:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700117494; x=1700722294; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MeRDN0+BzEJDhzSTXzv3THJfG/m7lmaKGuoDAqx8pdw=; b=Ml6N1yTp3XfzCPxfdDkpONdud49NVVbQeuHQz/OVcq4rQ89gxdicFtzCWxV3wDq1XG LTdPdvRkT8TN3LLv6dI5R8/rXWy2SITUGZo2jxoEUoP2rbAgmmDfQkgcBeoT5EPtYtuT efWPWpho2BP+mOlg5YNtDmxoFKphPtJVp4V85XUmfOSP47pjZte5KIFrAgSfpvDv/StZ YqJhm/11WE3uUnL0RYO9xaweSk5oQM1LSHL5h58TTiugQn2CzBjNMmukW9Tpt40b/b2v ltZqqKu/6bmQO8v0GXTJNWb1FyEaBj4L8ZKFg4nyMp0Jh6+bEA4rxNx6/13okBQMnTYG yYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700117494; x=1700722294; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MeRDN0+BzEJDhzSTXzv3THJfG/m7lmaKGuoDAqx8pdw=; b=fnDVy2C8c/UXac2JhyQguEYd4aLYXYhGO/UK7jMvJQ8b+Fwrl0fteipGT1AvPFg7i0 O5Dd60KxxxzcMudLEUZsFCNJ4veyXDErnVkgi1NfNT83BFFtlgUtnn+gfv/NqrAYGfYM BZUvJJChuyw/nMA5wfQe7aA9/sXsAhUowCPQBT/2Y16VoVaLB4fEkuX8gjJCMcUbdbq6 3023AhJsboPZoj3juQW5TyBfepCvUt90so9dwLkRs2IdC4Kv79vwWbG1LIQtA/S2lTRy AoS4a7zIvKWxPmQ3vpb2eq8fwaT2KowYOynRaSVXK+KsAwOB23glwOWo4rOW7x4HwgW9 wJAg== X-Gm-Message-State: AOJu0Yxp9eAlmMM9R3UFykQjEq63MkLTVT3BFoMW5uSj+IKJYh1mkvrx mtti4ImsyMXJrXLLHiIKKUI= X-Received: by 2002:a17:902:e88e:b0:1c2:1068:1f4f with SMTP id w14-20020a170902e88e00b001c210681f4fmr8580678plg.17.1700117493905; Wed, 15 Nov 2023 22:51:33 -0800 (PST) Received: from [192.168.1.105] (111-255-239-171.dynamic-ip.hinet.net. [111.255.239.171]) by smtp.gmail.com with ESMTPSA id s10-20020a170902ea0a00b001b3bf8001a9sm8474771plg.48.2023.11.15.22.51.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Nov 2023 22:51:33 -0800 (PST) Message-ID: <446aeb22-55c4-4ef6-81cc-1d1d994d5268@gmail.com> Date: Thu, 16 Nov 2023 14:51:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] sched/eevdf: Fix vruntime adjustment on reweight Content-Language: en-US To: Abel Wu Cc: Barry Song <21cnbao@gmail.com>, Benjamin Segall , Chen Yu , Daniel Jordan , "Gautham R . Shenoy" , Joel Fernandes , K Prateek Nayak , Mike Galbraith , Qais Yousef , Tim Chen , Yicong Yang , Youssef Esmat , linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Valentin Schneider References: <20231107090510.71322-1-wuyun.abel@bytedance.com> <20231107090510.71322-2-wuyun.abel@bytedance.com> <23cebdf8-1a51-481e-a8c2-e17021099e05@bytedance.com> <19c6accf-1cc0-489d-9c82-e0ddf982b098@bytedance.com> From: Yiwei Lin In-Reply-To: <19c6accf-1cc0-489d-9c82-e0ddf982b098@bytedance.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 22:51:39 -0800 (PST) On 11/16/23 13:07, Abel Wu wrote: > On 11/16/23 12:48 PM, Abel Wu Wrote: >> On 11/15/23 11:36 PM, Yiwei Lin Wrote: >>> >>>> @@ -3712,8 +3811,17 @@ static void reweight_entity(struct cfs_rq >>>> *cfs_rq, struct sched_entity *se, >>>>       enqueue_load_avg(cfs_rq, se); >>>>       if (se->on_rq) { >>>>           update_load_add(&cfs_rq->load, se->load.weight); >>>> -        if (cfs_rq->curr != se) >>>> -            avg_vruntime_add(cfs_rq, se); >>>> +        if (!curr) { >>>> +            /* >>>> +             * The entity's vruntime has been adjusted, so let's >>>> check >>>> +             * whether the rq-wide min_vruntime needs updated too. >>>> Since >>>> +             * the calculations above require stable min_vruntime >>>> rather >>>> +             * than up-to-date one, we do the update at the end of >>>> the >>>> +             * reweight process. >>>> +             */ >>>> +            __enqueue_entity(cfs_rq, se); >>>> +            update_min_vruntime(cfs_rq); >>>> +        } >>>>       } >>>>   } >>> Sorry if I am asking stupid question...... It looks like >>> reweight_entity() may have chance to change the weight of >>> cfs_rq->curr entity, but we'll never update_min_vruntime() when >>> reweighting it. Is there any reason that we can skip the >>> update_min_vruntime() for this case? >> >> No, you are right! > > I was intended to update_min_vruntime() if se->on_rq and no matter > it is curr or not, just as you suggested. But after a second thought > I wonder if it is necessary to update *NOW*, since we will always > update_curr() before making any change to cfs_rq. Thoughts? I lost the fact that we'll update_min_vruntime() every time we update_curr(). Because of this fact, we can indeed wait until we need the correct min_vruntime and update_min_vruntime() then. The only consideration that I came up with is that the sched_debug may not be able to reflect the accurate min_vruntime in time. But this may not be a big problem. Further, I have another advanced thought we can remove the update_min_vruntime() here in the reweight_entity() directly to save more time. The reason that I think this is because min_vruntime is not for normalization of vruntime as before which is required on CFS, so we will always update_curr() for the latest min_vruntime before using it. Also, the update_min_vruntime() in dequeue_entity() may also be removed as the reason, i.e. just do update_min_vruntime() in update_curr() to simplify. What do you think? Thanks, Yiwei Lin