Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58E7EC61DA4 for ; Thu, 9 Mar 2023 09:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbjCIJaT (ORCPT ); Thu, 9 Mar 2023 04:30:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjCIJaJ (ORCPT ); Thu, 9 Mar 2023 04:30:09 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7919E526 for ; Thu, 9 Mar 2023 01:30:08 -0800 (PST) Received: from dggpeml500018.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PXP5W0pKBzrSFQ; Thu, 9 Mar 2023 17:29:19 +0800 (CST) Received: from [10.67.111.186] (10.67.111.186) by dggpeml500018.china.huawei.com (7.185.36.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 9 Mar 2023 17:30:06 +0800 Message-ID: <6a45bb5c-d851-d48d-44b1-cf533293a6d8@huawei.com> Date: Thu, 9 Mar 2023 17:30:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH v2] sched/fair: sanitize vruntime of entity being migrated To: Dietmar Eggemann , Vincent Guittot CC: , , , , , , , , , References: <20230306132418.50389-1-zhangqiao22@huawei.com> <07c692fd-fe59-1bd4-a6d0-e84bee6dbb3b@huawei.com> <5250a0fc-3470-b313-0810-5d7a68c7cf50@arm.com> From: Zhang Qiao In-Reply-To: <5250a0fc-3470-b313-0810-5d7a68c7cf50@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.111.186] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500018.china.huawei.com (7.185.36.186) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2023/3/9 17:09, Dietmar Eggemann 写道: > On 09/03/2023 09:37, Zhang Qiao wrote: >> >> 在 2023/3/8 20:55, Vincent Guittot 写道: >>> Le mercredi 08 mars 2023 à 09:01:05 (+0100), Vincent Guittot a écrit : >>>> On Tue, 7 Mar 2023 at 14:41, Zhang Qiao wrote: > > [...] > >>>>> 在 2023/3/7 18:26, Vincent Guittot 写道: >>>>>> On Mon, 6 Mar 2023 at 14:53, Vincent Guittot wrote: >>>>>>> >>>>>>> On Mon, 6 Mar 2023 at 13:57, Zhang Qiao wrote: > > [...] > >>> +static inline bool migrate_long_sleeper(struct sched_entity *se) >>> +{ >>> + struct cfs_rq *cfs_rq; >>> + u64 sleep_time; >>> + >>> + if (se->exec_start == 0) >> >> How about use `se->avg.last_update_time == 0` here? > > IMHO, both checks are not needed here since we're still dealing with the > originating CPU of the migration. Both of them are set to 0 only at the > end of migrate_task_rq_fair(). Yes, if place_entity() don't call migrate_long_sleeper(), the check can remove. > > >>> + return false; >>> + >>> + cfs_rq = cfs_rq_of(se); >>> + /* >>> + * If the entity slept for a long time, don't even try to normalize its >>> + * vruntime with the base as it may be too far off and might generate >>> + * wrong decision because of s64 overflow. >>> + * We estimate its sleep duration with the last update of se's pelt. >>> + * The last update happened before sleeping. The cfs' pelt is not >>> + * always updated when cfs is idle but this is not a problem because >>> + * its min_vruntime is not updated too, so the situation can't get >>> + * worse. >>> + */ >>> + sleep_time = cfs_rq_last_update_time(cfs_rq) - se->avg.last_update_time; > > Looks like this doesn't work for asymmetric CPU capacity systems since > we specifically do a sync_entity_load_avg() in select_task_rq_fair() > (find_energy_efficient_cpu() for EAS and select_idle_sibling() for CAS) > to sync cfs_rq and se (including their last_update_time). > > [...] > > . >