Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3099579rdb; Wed, 15 Nov 2023 23:11:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFw9HWGoUYCbrd+e5VQqFNkj/TAZWEypn4fDx2lH3Ttwbhki0KxDUBXDgbJprThF4KQ9S83 X-Received: by 2002:a05:6a20:8f19:b0:187:afb0:c2f5 with SMTP id b25-20020a056a208f1900b00187afb0c2f5mr1559858pzk.3.1700118696546; Wed, 15 Nov 2023 23:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700118696; cv=none; d=google.com; s=arc-20160816; b=faACbiSRspA5sgyJIk5D/65R/hQM6MW53GZNT/mZga+mp/EoHbfL3Jnk7NYECgHBlh 4DmmvqYChGqSZPZpfgH+5oaHlYHi90U98wNOreHFfucJpb4JRjjkZ4IdmJuy2pgVDkSA +TzX4p5Cg48BrejwxjWWt1oVQ3Zf7hBLT5vaX0vTmymt1Jd2POXcBy5YiaCGOV2BZk/Q 1m30yhVqJqbwlWQ0RXT60pCTQOeSAe0mx8tLQvQ7zEHcvy7A7igAnvo7jrY3Cvleh3kq flgRvr7utpSqDRsubKtrhTgWltzOgdZK+2k6EIdByX7EBGTLw6i8weer/PnaPvOltxW4 1o5g== 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=mA9iboiAyXV3dWlM8+BWCGvRgom1QhuQa9XC12KZvSU=; fh=v7tmjTq3HKvG+9Mt1/P693nb5d87+reN5OFh5easFgI=; b=v3pnw4Gbl5lfWECh5La/xu6VvXN4ADHw/H7JKICBEy95wGGJhjELQu+CaxyCHWvanE PblgfpyfL5NEINHZ8a3PFNl0KNrBDoO0JgGQFBGZNKjxjXMDY0FjMksbQAGKbpALniKs D21UViL436Y4R8/ygQpyh6RRNPiVUNDO6aSsLrzhy0j5RAg23R3+LeTM5wGhVGhd79VX G8Ptk2jw0Uoekyz7MUR8R9q44uFRy0RU80SsoUElDUERP7vjJAgBw3cd1HcbufuNAZ6o a0+3n4JJLLYfuAr8i1yL0G/mcCdZGtsQlkeaEMti+cH45HLCKUlmW6ZtpVBjd6HiFvqI yXVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Jwp7lkP0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ca17-20020a056a02069100b005be1ee5b99fsi12883791pgb.526.2023.11.15.23.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 23:11:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Jwp7lkP0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C7C058024AC4; Wed, 15 Nov 2023 23:11:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234273AbjKPHLY (ORCPT + 99 others); Thu, 16 Nov 2023 02:11:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbjKPHLY (ORCPT ); Thu, 16 Nov 2023 02:11:24 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E0D192 for ; Wed, 15 Nov 2023 23:11:16 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2806cbd43b8so335179a91.3 for ; Wed, 15 Nov 2023 23:11:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1700118675; x=1700723475; 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=mA9iboiAyXV3dWlM8+BWCGvRgom1QhuQa9XC12KZvSU=; b=Jwp7lkP0CQFnndyaSvNYJ4BgqjBXkmQPTYYSAsy7E86wA1XUO7OCZWUeL2OU0+CbrD LngKyKKBMAAD8jsUNuOoO/Sdy8kP7tv+/JtNf8aWiNMxMdy/mwkP8D7kKYVlOtnDaniy 9gNWvnUkbYLl8jKqu6QBN7tH1awP+Oz/U7RfohBLya63mYAKxxrnQrS3vJPos4Kt1/j8 tXEWj+Eba7zjU8FMWqwFiLmZWSCmvOV1dHHM50HXvrSDe/d7cc+PAuUmXE4J4XedOTwL EB0FDhQ4th2i7cYMoLXy3y2Cyd/Y4p0FvhMaDairo4ECGCimOBg5bKU8rbA6zZq7A2gA W+lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700118675; x=1700723475; 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=mA9iboiAyXV3dWlM8+BWCGvRgom1QhuQa9XC12KZvSU=; b=WKe3rcQxIfuzjh6cRFS9zioJ7SaY3oRCjcvnsntko4MjqC6txzOfpH8mb4G8rHz+3a S3WCvk5MIqyBRxh2ZUAUOTWX/wUEldPeucDB9K/dYT1tXirbbrP48XX95bZN1EpTsbTi ypGBQBrlwiTpWNBey/GldJ7chX2nAmxS7spaJMgKDSvJbHGCG7unolPpoD4pjaeVQuz6 MCRtI7Tm4BGl/c+TYQeV+Tstahcb8EZ3ZgDahXQpx+NXkKjun7e18S08vckA7vdcT8c9 o4sCHOAZE3BZRCj6TOYby4SqAWyF1SDQOo+zeplzs83Q9sPyVKNK5nvqSwfXJtv6ADX1 dBXg== X-Gm-Message-State: AOJu0YxgYyA956Wugx/Lr63ogfzaWhqSbCY2yDoUeOM+ZBNF4O+LBp8Q CScYLu7xxFQYJ7QGXzF40IvaBQ== X-Received: by 2002:a17:90b:1646:b0:25e:a8ab:9157 with SMTP id il6-20020a17090b164600b0025ea8ab9157mr16165716pjb.22.1700118675452; Wed, 15 Nov 2023 23:11:15 -0800 (PST) Received: from [10.254.46.51] ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id lm14-20020a17090b334e00b002630c9d78aasm934271pjb.5.2023.11.15.23.11.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Nov 2023 23:11:14 -0800 (PST) Message-ID: <7f179261-72a7-41d9-aa79-6ba8cc3c4286@bytedance.com> Date: Thu, 16 Nov 2023 15:11:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Re: [PATCH 1/4] sched/eevdf: Fix vruntime adjustment on reweight Content-Language: en-US To: Yiwei Lin 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> <446aeb22-55c4-4ef6-81cc-1d1d994d5268@gmail.com> From: Abel Wu In-Reply-To: <446aeb22-55c4-4ef6-81cc-1d1d994d5268@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 23:11:34 -0800 (PST) On 11/16/23 2:51 PM, Yiwei Lin Wrote: > > 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? Yes, this is also exactly what I am thinking about. As task placement now adopts lag-based solution which is irrespective of min_vruntime, and also based on the fact that it is only used as a base offset for calculating avg_vruntime (in order to avoid overflow), we probably can update it in a more relaxed way e.g. in ticks. If relaxed update works, there seems still work to be done first: 1) the priority of core pick when core scheduling needs to change to deadline-based solution; 2) need to make sure not overflow in NOHZ_FULL mode Just some first thoughts come into my mind :) Thanks, Abel