From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 2977580726 for ; Wed, 14 Oct 2026 11:18:05 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69EBGl3a031149; Wed, 14 Oct 2026 14:16:48 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69EBGl3a031149 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="rOU2FBKU" Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69EBGaGE031121 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 14 Oct 2026 14:16:36 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69EBGaGE031121 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48b008137d8so3659702f8f.0 for ; Wed, 14 Oct 2026 04:16:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxcGTHXnJjR3GfC4iXreU/Ti5AbCiydCUUjZHaIqzbNhf/X+9lX4U+jX8IPWsul/L93e0D7Fw==@openvz.org X-Gm-Message-State: AFq9FYK8UN4Eif33HkQH0TY40yWDb7L70tmUM8CNHw8sJC616eA8+/Xb lnwMsQoLGstPBezVEc3jpnVgkT7FVXFTQJ7KEGfadsk3sVS6YXhwDbCFjieiVyQ8jzkfYB7aCAW qRcGpqWORaIjLiTMl/E/muQgFAoiDjS8uwMOZrhod0HqkNXs8PcIjNQ== X-Gm-Gg: AYBFou2gmauGgIwoIyHSLnWEYPhvFnmliyzhmfj27sczx72kgtTAvlIaE+wiz3EJ+Ql WZbp5VqoWP5gb7wdO25o4QOA6j+oIYRR3ubQVT1+wCx7Fle6ptiGs/xoCOgBOiHeRjiDWWO748L swwuHSPGGxznRzFjgSc7WB0gOslSBAvuWRDdLrEGazUUtFwRRx4wmf9/MRYt5T5y9hK3b8+JUAd or7lWMN+kvZ8tSs/GYwD7RZPcIz/KA2uhyIp4t8KpKSwBqNreYML+AHV+/IW19Yg0JKMytdGu8R Ys/D9GKBknDgi7njn+QJePEPO8IRtM/zbmEjv4vCZcCNSe8dWOefTup4MgY+V02gErfFo3/LbW4 /sv6JDFbmreX5bgKTyDCC9TarOLA6Kik= X-Received: by 2002:adf:f9cc:0:b0:48d:e005:860a with SMTP id ffacd0b85a97d-48de00588e3mr9913803f8f.28.1791976596332; Wed, 14 Oct 2026 04:16:36 -0700 (PDT) X-Received: by 2002:adf:f9cc:0:b0:48d:e005:860a with SMTP id ffacd0b85a97d-48de00588e3mr9913726f8f.28.1791976595594; Wed, 14 Oct 2026 04:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791976595; cv=none; d=google.com; s=arc-20260327; b=pkftkIjwq8/HQvfDarsyMGe+CriEcUz1vdUCfPxYq3v1LURCQQyB7u3ViaH/uTRJPd lRXc24ek8Ov9m8/Vn8J5ckzetnoqoy4UWrlSQuyM7xncGe/vnk64hXuxown5gov1e7rd K4mEPkMWbmjjDZJAzocD5vTpU4pizFXeHqH4Ymb3FZLLDRHjpy7MHRMYtZNR6grXl2mr aGGdeKLGT12b9GhoXg//On36s21Iw1Ern8KUpu6haGzsL6H55mL1L3lSJLONSqlhxS4k 6z8nhz9Lwp5W7Kn6BFqsVX+3e1VWwV+beEDXZvW2fg2kfW2XrSWIqXT1k5/4jT3n9sks hIYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=4NyzuPE+E0e6caPPaCt+lXQbSRYZ2JATFay7y9b2XtI=; fh=YUVjC/9FtpTN0Is9ifTJrOsbz/J/onroleA8inR1Ce8=; b=RWMIo0BmYIBIla7QxWlJCZzUTwN8R+kQAmfLkpbcSODGwIqTFgw01KFR47xNFZGo47 0aBAHYkVJpij38t4C102ezxT2xB3T20A8ehvYoFBCMftKTwzx01hx7b2gMW5O3fJbK44 ydmldcmk8v/XLaXTEEep5oYTcKaeQo/TYzxieH84rRcrFN5vZy6bYkHUerGvZQDys/MP mUX421DKynBceQhLoqXSCG1pX5ggBWc5imOPyhfNKK4yFdngJgepU9uoFNRKQtk+e5HI sszPjPNxftZaApt2BH4K//HfEyC+kdVwgnLff+EvAdvIfK54VSMv/cQeIQkPec7TK7R3 d2bA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=rOU2FBKU; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48de33ab7ebsi9713854f8f.328.2026.10.14.04.16.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2026 04:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=rOU2FBKU; spf=pass (google.com: domain of vasileios.almpanis@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vasileios.almpanis@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=4NyzuPE+E0e6caPPaCt+lXQbSRYZ2JATFay7y9b2XtI=; b=rOU2FBKUOoiWDn/BojW a04SRMtV/Kv8Zf6Po1420hjYCLq0HmAn422zMAvmO57pbMnT5zAun/ZamLpNqQeQY0BR2TOLTavPD 4TMT/zAT3YvUrE+oQvvNn09Gfmi1yY4BRlx1s3qVzCx5gAp1+voBfoD57VAuEydayv/hYVOQoiFrl NtlNqfcf9D2EJ2yuIxT/OLFzasgPBJfZoRXEQdxELU52vLK4k+xjhFdPeI4k+Tyo5QixsSiF6oZox 09VEa81De/G8xB/QGqdW3HhxADIh+ezgleY5swMWbNRMRoS/voYneYT7P/43og06sY025RCDx3Cde wBDcQJk9EKfb0rg==; Received: from [130.117.225.5] (helo=dev010.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xGwus-001CVN-1X; Wed, 14 Oct 2026 13:16:34 +0200 From: Vasileios Almpanis Date: Wed, 14 Oct 2026 11:16:26 +0000 MIME-Version: 1.0 Message-Id: <20261014-ct-iowait-v1-3-9d65fe37cf89@virtuozzo.com> References: <20261014-ct-iowait-v1-0-9d65fe37cf89@virtuozzo.com> In-Reply-To: <20261014-ct-iowait-v1-0-9d65fe37cf89@virtuozzo.com> To: Konstantin Khorenko , Pavel Tikhomirov X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791976595; l=3905; i=vasileios.almpanis@virtuozzo.com; s=20260812; h=from:subject:message-id; bh=5m1RSbAiNcINUyKBNDd5o5CFg+JcP3VLwoabL/MXvvo=; b=OnUpU6OFcmPZvlIy6F+uhBtVpSG1litRyaiC93CqpAoMaUg3hb40Hc1yRiO5qLFOsznuCLSfn S9GIFflgXApC/UINPgfP6YvhKmsVjJqbVxP2GbwPtM38eYF1HMOWMrZ X-Developer-Key: i=vasileios.almpanis@virtuozzo.com; a=ed25519; pk=HhuHDXAcPva9A8zccWEMRsb36reu+y4IVbBjXKxNUjw= X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 3/4] sched: account sleep and block time of a task group entity X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org CT idle and iowait in cpu.proc.stat come from the schedstats of the group entity: cpu_cgroup_update_stat() reads iowait_sum and sum_sleep_runtime. But only tasks get sleep_start/block_start, so for a group both stay 0 and the CT shows 0 idle and 0 iowait. fixup_vcpustat_delta() then gives all idle time of the CT's /proc/stat to IDLE, so iowait there is always 0 too. vz7 dequeue_sleeper() had a branch for group entities that was lost when porting to newer kernels. Restore it in update_stats_dequeue_fair(): when a group entity is dequeued on sleep, start a block period if its cfs_rq has iowait sleepers and a sleep period otherwise. The existing enqueue path closes it. Like on vz7, skip throttled groups, they are not idle, just waiting for bandwidth. If a group has nothing to run when it is unthrottled, tg_unthrottle_up() doesn't enqueue it, so start its period there. https://virtuozzo.atlassian.net/browse/VSTOR-147823 Fixes: 095994c57b84 ("ve/sched/stat: Introduce functions to calculate vcpustat data") Signed-off-by: Vasileios Almpanis Feature: sched: emulate virtual cpus for Containers --- kernel/sched/fair.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index df296edb828d..2df5a9b47480 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1332,6 +1332,21 @@ update_stats_enqueue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int fl update_stats_enqueue_sleeper_fair(cfs_rq, se); } +static inline int throttled_hierarchy(struct cfs_rq *cfs_rq); + +/* The group goes idle, blocked if it has iowait sleepers */ +static inline void +update_stats_group_sleep_start(struct cfs_rq *cfs_rq, struct sched_entity *se) +{ + struct sched_statistics *stats; + + stats = __schedstats_from_se(se); + if (group_cfs_rq(se)->nr_iowait) + __schedstat_set(stats->block_start, rq_clock(rq_of(cfs_rq))); + else + __schedstat_set(stats->sleep_start, rq_clock(rq_of(cfs_rq))); +} + static inline void update_stats_dequeue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) { @@ -1358,6 +1373,9 @@ update_stats_dequeue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int fl if (state & TASK_UNINTERRUPTIBLE) __schedstat_set(tsk->stats.block_start, rq_clock(rq_of(cfs_rq))); + } else if ((flags & DEQUEUE_SLEEP) && + !throttled_hierarchy(group_cfs_rq(se))) { + update_stats_group_sleep_start(cfs_rq, se); } } @@ -3825,8 +3843,6 @@ static void reweight_task_fair(struct rq *rq, struct task_struct *p, load->inv_weight = lw->inv_weight; } -static inline int throttled_hierarchy(struct cfs_rq *cfs_rq); - #ifdef CONFIG_FAIR_GROUP_SCHED /* * All this does is approximate the hierarchical proportion which includes that @@ -5904,6 +5920,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) { struct rq *rq = data; struct cfs_rq *cfs_rq = tg->cfs_rq[cpu_of(rq)]; + struct sched_entity *se = tg->se[cpu_of(rq)]; struct task_struct *p, *tmp; if (--cfs_rq->throttle_count) @@ -5933,6 +5950,15 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) enqueue_task_fair(rq_of(cfs_rq), p, ENQUEUE_WAKEUP); } + /* + * The group may have gone idle while throttled, when no sleep or + * block period is started for it. Start it now if nothing runs. + */ + if (schedstat_enabled() && se && !se->on_rq && !cfs_rq->nr_queued && + !schedstat_val(__schedstats_from_se(se)->sleep_start) && + !schedstat_val(__schedstats_from_se(se)->block_start)) + update_stats_group_sleep_start(cfs_rq_of(se), se); + /* Add cfs_rq with load or one or more already running entities to the list */ if (!cfs_rq_is_decayed(cfs_rq)) list_add_leaf_cfs_rq(cfs_rq); -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel