From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id D658D803BB for ; Thu, 12 Nov 2026 04:24:44 +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 6AC4NUhY002618; Thu, 12 Nov 2026 07:23:30 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AC4NUhY002618 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="VNdnjgZc" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AC4NSeg002614 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 12 Nov 2026 07:23:28 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AC4NSeg002614 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-49034831bb3so3257486f8f.1 for ; Wed, 11 Nov 2026 20:23:28 -0800 (PST) X-Gm-Message-State: APuU4Z+dFzktVAyQbA7JlHRhkZFPHkqLAcRJQ8VYmozF5yc50ONYaeyQ HGaPyyMsGA6I+ThLupWL9ZC9knR2Vhwm1d2Sx5O372k69wMMBf5kCl9LffhUsdD2kT+Ljic7Lro OBR87dzaUh3ZKV58hu6sWG2xWWreTQCQGD2IGOUs8Rj+MgtsWF9eoqQ== X-Gm-Gg: AYBFou3QumIIvj+7jMGlk1eguNCKH/8Gk6uMts7PIdn2JYlkHyUPK90maBooSH8KR/m MPFUv0CBLgDKu5YdWfvCS7XYK7ILyjfajsa121ArhhW/EYv+61Kdjzcw2syv4CDII1qA/egcMP2 gtDpItvnakMyXi0ewyLRdTS+4xfZBPozG3HNMXI9aj71znFFj/eyeg5MteZoA8VBQcqNXGWnBSr v9Eo3s+pnBmn6J8avL5RPjnmcfs0TSCGYSZD2sle6OVk9xOF44YopolhvmUoY9jurq4vFlCsi6p 0PBszc6aX1K5/7aIjBLf/FTvzE1OFCB0OQYH4NVmLjvi0ci/pgfYsRHM1PvGHfb8eNWrjv6hpKb qrhlZKT1ugh++wQQxcmRLH1xFVQ== X-Received: by 2002:a05:6000:1843:b0:490:411a:1eed with SMTP id ffacd0b85a97d-499c81d5ec5mr7477814f8f.39.1794457408289; Wed, 11 Nov 2026 20:23:28 -0800 (PST) X-Received: by 2002:a05:6000:1843:b0:490:411a:1eed with SMTP id ffacd0b85a97d-499c81d5ec5mr7477788f8f.39.1794457407829; Wed, 11 Nov 2026 20:23:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794457407; cv=none; d=google.com; s=arc-20260327; b=KVTduEMyDtC04Ku726rAOZ1g0xJBinKPzLXQLe0lVL8VU/fGnKBjppWjMaU2wqNf+W UmXJtufmm8cz8kSwJZaEAIE4l0D1Nr+ZoNUKmmh+E1E3QVjHUFVnw1M44htjlzWNVSB6 S+35wFimar4kDqamOa36MCJ30MTQKaqP2esWa5UKYRcpS5t2sgnlfeLhSKtA1POWqpvO YJGl9vfAcmp+9ktgoe7ErEKGxlE/Tl79zW6DHtYLa3Fuy6rPjD70Bi/PdkznxOjJwjw+ iee33n99cjLwXt2ertbISTULBMT27m/zMIKrQ2D9r9+IQvovYSXL2EuI21aWDzYnJKdy rIIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=OYQKsyfhaPPYeEh2vViThzvZX0jhPbcZ0t1ZMzAZqq8=; fh=WpT6aB7RBAGHZeWZzqAr71yzRFbPTYkPWKsRagLn48Q=; b=gecpiM2dhXjdgNDVRFifl75TbUcuQv/MK6kEax4IYsk3GBERHj+uHKUzT4pkpPpkvZ Q4/Nbuwg6Zu2na4eN/sgVmQiGrccWXjGXTirfXHXAoqg6LIHs6vMvXkQRNLvX7zg+EX8 kV1NEnFKwfVjDmQCseYLrmdIuSGxVKvXa6UCuspWQkHpqeuUUsDanXBaXesQIuZG5EK8 RarXZOiZ/i2FGX3YTSyycciubQ9sIxdtShZOX5lq2RB/DyGehur5+O260Cip95UCh/XG eMHuGb1byM1Mi536PanpPaFxKuv5z0QOImx6L3YGetEvg73t1OBEk2CKYuuJArL1XKj5 PYMw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=VNdnjgZc; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@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-498369a435bsi13727452f8f.285.2026.11.11.20.23.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 20:23:27 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@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=VNdnjgZc; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@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=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=OYQKsyfhaPPYeEh2vViThzvZX0jhPbcZ0t1ZMzAZqq8=; b=VNdnjgZcHvzP IyvBfmjyN4uaCCvBOtTAFUhX/BRqyBKuAEXht8kGLZtM+mHIKTfokw6qD8nuqsm+KyYF2yxoShHbx D3qr6/0EtujN/34ZttbsnjIqHhVLP6sKR7XABDH4K341bXrDpK4M5+7PyC6gwSZb9K0qf7HMW1mxJ LBeWNZiHygit81i0Ek7OcYGZ/r9Z5R+obSEnLzaKBMCEHwgldiMEh84ArYrndj1nOE/NSumhbLgjJ /K85fvegFxj9Kw0rcVq3St/kIKH0EBMKFODh8PtlNus4M7kDtjMSLrRLcSwxPS9vqkt8Qhe78CyUw MUq02ofQehb3IIPsfg6oEQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xRMHG-0074p5-33; Thu, 12 Nov 2026 05:23:25 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com Date: Thu, 12 Nov 2026 06:23:20 +0200 Message-ID: <20261112042325.399633-1-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1] selftests/cgroup: Pin the hogs of test_cpucg_weight_overprovisioned 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 The test runs one hog thread per CPU in each of three cgroups weighted 1:2:3 and expects their CPU time in the same ratio. That holds when each CPU runs one hog of every cgroup. On a NUMA machine the load balancer leaves them less evenly spread, and the heaviest cgroup can fall short of the tolerance. Pin the hogs of each cgroup one per CPU: the test checks the weights, not the load balancer. Fixes: 6376b22cd0a3 ("cgroup: Add test_cpucg_weight_overprovisioned() testcase") https://virtuozzo.atlassian.net/browse/VSTOR-152674 Feature: fix selftests Signed-off-by: Eva Kurchatova --- tools/testing/selftests/cgroup/test_cpu.c | 31 +++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c index a2b50af8e9ee..3385e75eed81 100644 --- a/tools/testing/selftests/cgroup/test_cpu.c +++ b/tools/testing/selftests/cgroup/test_cpu.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ struct cpu_hog_func_param { int nprocs; struct timespec ts; enum hog_clock_type clock_type; + bool pin; }; /* @@ -136,7 +138,13 @@ static int hog_cpus_timed(const char *cgroup, void *arg) struct timespec ts_run = param->ts; struct timespec ts_remaining = ts_run; struct timespec ts_start; - int i, ret; + pthread_attr_t attr; + cpu_set_t cpus, one; + int i, ret, cpu = -1; + /* Unpinned, as before, where the mask does not fit in a cpu_set_t */ + bool pin = param->pin && !sched_getaffinity(0, sizeof(cpus), &cpus); + + pthread_attr_init(&attr); ret = clock_gettime(CLOCK_MONOTONIC, &ts_start); if (ret != 0) @@ -145,7 +153,18 @@ static int hog_cpus_timed(const char *cgroup, void *arg) for (i = 0; i < param->nprocs; i++) { pthread_t tid; - ret = pthread_create(&tid, NULL, &hog_cpu_thread_func, NULL); + /* One hog per allowed CPU, in turn */ + if (pin) { + do { + cpu = (cpu + 1) % CPU_SETSIZE; + } while (!CPU_ISSET(cpu, &cpus)); + CPU_ZERO(&one); + CPU_SET(cpu, &one); + ret = pthread_attr_setaffinity_np(&attr, sizeof(one), &one); + if (ret != 0) + return ret; + } + ret = pthread_create(&tid, &attr, &hog_cpu_thread_func, NULL); if (ret != 0) return ret; } @@ -372,7 +391,8 @@ run_cpucg_weight_test( return ret; } -static pid_t weight_hog_ncpus(const struct cpu_hogger *child, int ncpus) +static pid_t weight_hog_ncpus(const struct cpu_hogger *child, int ncpus, + bool pin) { long usage_seconds = 10; struct cpu_hog_func_param param = { @@ -382,13 +402,14 @@ static pid_t weight_hog_ncpus(const struct cpu_hogger *child, int ncpus) .tv_nsec = 0, }, .clock_type = CPU_HOG_CLOCK_WALL, + .pin = pin, }; return cg_run_nowait(child->cgroup, hog_cpus_timed, (void *)¶m); } static pid_t weight_hog_all_cpus(const struct cpu_hogger *child) { - return weight_hog_ncpus(child, get_nprocs()); + return weight_hog_ncpus(child, get_nprocs(), true); } static int @@ -434,7 +455,7 @@ static int test_cpucg_weight_overprovisioned(const char *root) static pid_t weight_hog_one_cpu(const struct cpu_hogger *child) { - return weight_hog_ncpus(child, 1); + return weight_hog_ncpus(child, 1, false); } static int -- 2.56.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel