From patchwork Tue Jun 1 10:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=lHKXJTdr; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTbW62WTz9sWD for ; Tue, 1 Jun 2021 20:55:51 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B250C3C8042 for ; Tue, 1 Jun 2021 12:55:49 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 66E653C59F3 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 087C71A0081C for ; Tue, 1 Jun 2021 12:55:46 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 76167218AB; Tue, 1 Jun 2021 10:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BBqdIf6/rWTlzlofsOzqAtSgW+m2+A/eyi30HEUylR4=; b=lHKXJTdrCGciNNoC8LB+n3CJC9tje20hTcrXhvdbB0TXjwbfYe7RrUoOnR9xDVjQKmAO5E Z7fxo7HgCSAaJvfwKOuGNrTXFXWOs4kUg1jXjiX00JK7rN160kvLn73EWNSAGLActozo6r FWJosTDFWL1m2kWzwX2ZAewoGqxQ1ek= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 3B114A3B84; Tue, 1 Jun 2021 10:55:46 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:16 +0100 Message-Id: <20210601105521.27459-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v3 1/6] API/cgroups: Allow fetching of CGroup name X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Lets the test author get the name of a CGroup. Signed-off-by: Richard Palethorpe --- include/tst_cgroup.h | 4 ++++ lib/tst_cgroup.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/tst_cgroup.h b/include/tst_cgroup.h index d4c93db79..de72645bc 100644 --- a/include/tst_cgroup.h +++ b/include/tst_cgroup.h @@ -133,6 +133,10 @@ struct tst_cgroup_group * tst_cgroup_group_mk(const struct tst_cgroup_group *const parent, const char *const group_name) __attribute__ ((nonnull, warn_unused_result)); +const char * +tst_cgroup_group_name(const struct tst_cgroup_group *const cg) + __attribute__ ((nonnull, warn_unused_result)); + /* Remove a descendant CGroup */ struct tst_cgroup_group * tst_cgroup_group_rm(struct tst_cgroup_group *const cg) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 1e036d3c3..793a712e1 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -855,6 +855,11 @@ tst_cgroup_group_mk(const struct tst_cgroup_group *const parent, return cg; } +const char *tst_cgroup_group_name(const struct tst_cgroup_group *const cg) +{ + return cg->group_name; +} + struct tst_cgroup_group *tst_cgroup_group_rm(struct tst_cgroup_group *const cg) { struct cgroup_dir **dir; From patchwork Tue Jun 1 10:55:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Wol7yzrS; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTbk00vMz9sWD for ; Tue, 1 Jun 2021 20:56:01 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id F02A83C903F for ; Tue, 1 Jun 2021 12:55:58 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 92C3B3C59F3 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 49DB8601179 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id BEA021FD30; Tue, 1 Jun 2021 10:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tEuabypM/jI6lWtPQlMMDUndgZgELkmqHOeKI9yztME=; b=Wol7yzrSFMkfxwue+WU0X1aRdworlHQWCVi8h+zz8Q83zHunBfqmTToTYMp3CPNydiwnps ofDl88FXvGN/GvTL73JADzJLXLoCfjwIrO+dJ+xaOlvYFWrF9MU2zmTCClGoZvMUyMuljI Bc7huNs4wTLebBSK9a7cgUGAkWm2v+8= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 87162A3B85; Tue, 1 Jun 2021 10:55:46 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:17 +0100 Message-Id: <20210601105521.27459-3-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v3 2/6] API/cgroups: Remove obsolete function in API X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- lib/tst_cgroup.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 793a712e1..8fd5ab288 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -225,12 +225,6 @@ static void add_ctrl(uint32_t *const ctrl_field, *ctrl_field |= 1 << ctrl->ctrl_indx; } -__attribute__ ((warn_unused_result)) -struct cgroup_root *tst_cgroup_root_get(void) -{ - return roots[0].ver ? roots : roots + 1; -} - static int cgroup_v2_mounted(void) { return !!roots[0].ver; From patchwork Tue Jun 1 10:55:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Gk4Lwelt; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTcH4B6Zz9sWD for ; Tue, 1 Jun 2021 20:56:31 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 16B303C775E for ; Tue, 1 Jun 2021 12:56:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 5674A3C7732 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 58B021400BDE for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0BCB02191B; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0zM+HobvJNnE264XfvlMMaKVDUsAVzyTEB9iorQ6Fn0=; b=Gk4LweltIsMCq4jYEipelTL1HUE8FWtrIRltoNuVhZO/88Z/cpzArVtXz+T0UQCX5Bxwpl HE9GBf7tg438e8CDyFf5bqrXHNpeQx5Qvjvg17whWOnbycQrZmFdA8lekubP3G2XzVOfwS CfVV/oEfsw3cYOOkce/n7zUWSJSbyqc= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id D1EF2A3B84; Tue, 1 Jun 2021 10:55:46 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:18 +0100 Message-Id: <20210601105521.27459-4-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v3 3/6] API/cgroups: Add cpu controller X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- lib/tst_cgroup.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 8fd5ab288..0b71d4eed 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -82,7 +82,8 @@ struct cgroup_root { /* Controller sub-systems */ enum cgroup_ctrl_indx { CTRL_MEMORY = 1, - CTRL_CPUSET = 2, + CTRL_CPU, + CTRL_CPUSET, }; #define CTRLS_MAX CTRL_CPUSET @@ -162,6 +163,18 @@ static const files_t memory_ctrl_files = { { } }; +static const files_t cpu_ctrl_files = { + /* The V1 quota and period files were combined in the V2 max + * file. The quota is in the first column and if we just print + * a single value to the file, it will be treated as the + * quota. To get or set the period we need to branch on the + * API version. + */ + { "cpu.max", "cpu.cfs_quota_us", CTRL_CPU }, + { "cpu.cfs_period_us", "cpu.cfs_period_us", CTRL_CPU }, + { } +}; + static const files_t cpuset_ctrl_files = { { "cpuset.cpus", "cpuset.cpus", CTRL_CPUSET }, { "cpuset.mems", "cpuset.mems", CTRL_CPUSET }, @@ -174,6 +187,9 @@ static struct cgroup_ctrl controllers[] = { [CTRL_MEMORY] = { "memory", memory_ctrl_files, CTRL_MEMORY, NULL, 0 }, + [CTRL_CPU] = { + "cpu", cpu_ctrl_files, CTRL_CPU, NULL, 0 + }, [CTRL_CPUSET] = { "cpuset", cpuset_ctrl_files, CTRL_CPUSET, NULL, 0 }, From patchwork Tue Jun 1 10:55:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Uv5cjdK2; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTbw25Dvz9sWD for ; Tue, 1 Jun 2021 20:56:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EED153C8016 for ; Tue, 1 Jun 2021 12:56:07 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id E4B463C59F3 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 91464601164 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 505402191F; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=whd9QU1lS/BOFEUDGkVbr1xgFdm8fBdfuFyzrcpUqLI=; b=Uv5cjdK2XhSNutDBpA7P026F9CbU1XaD2DqN1PKMjMvnDKSZU6LrqCvVtgx5ZoMmVG7aBT CSZxRMdc597N8SoCHHVSso80Bbh8Af+3ME6s//Yg50rxqXp39Y9lNTZeISyLc15nGsy1F0 OiP7JcauAMU6FhM7802xW9rWGxB2dkA= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 1CCC4A3B84; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:19 +0100 Message-Id: <20210601105521.27459-5-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v3 4/6] API/cgroups: Auto add controllers to subtree_control in new subgroup X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This is what we have always wanted so far. If we do not want to do it on a new test then a new config option can be added during require. Signed-off-by: Richard Palethorpe --- lib/tst_cgroup.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 0b71d4eed..74746f13e 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -826,19 +826,28 @@ static void cgroup_group_init(struct tst_cgroup_group *const cg, strcpy(cg->group_name, group_name); } -__attribute__ ((nonnull)) -static void cgroup_group_add_dir(struct tst_cgroup_group *const cg, +__attribute__((nonnull (2, 3))) +static void cgroup_group_add_dir(const struct tst_cgroup_group *const parent, + struct tst_cgroup_group *const cg, struct cgroup_dir *const dir) { const struct cgroup_ctrl *ctrl; int i; - if (dir->dir_root->ver == TST_CGROUP_V2) + if (dir->dir_root->ver != TST_CGROUP_V1) cg->dirs_by_ctrl[0] = dir; for_each_ctrl(ctrl) { - if (has_ctrl(dir->ctrl_field, ctrl)) - cg->dirs_by_ctrl[ctrl->ctrl_indx] = dir; + if (!has_ctrl(dir->ctrl_field, ctrl)) + continue; + + cg->dirs_by_ctrl[ctrl->ctrl_indx] = dir; + + if (!parent || dir->dir_root->ver == TST_CGROUP_V1) + continue; + + SAFE_CGROUP_PRINTF(parent, "cgroup.subtree_control", + "+%s", ctrl->ctrl_name); } for (i = 0; cg->dirs[i]; i++); @@ -859,7 +868,7 @@ tst_cgroup_group_mk(const struct tst_cgroup_group *const parent, for_each_dir(parent, 0, dir) { new_dir = SAFE_MALLOC(sizeof(*new_dir)); cgroup_dir_mk(*dir, group_name, new_dir); - cgroup_group_add_dir(cg, new_dir); + cgroup_group_add_dir(parent, cg, new_dir); } return cg; @@ -1023,7 +1032,7 @@ static struct tst_cgroup_group *cgroup_group_from_roots(const size_t tree_off) dir = (typeof(dir))(((char *)root) + tree_off); if (dir->ctrl_field) - cgroup_group_add_dir(cg, dir); + cgroup_group_add_dir(NULL, cg, dir); } if (cg->dirs[0]) { From patchwork Tue Jun 1 10:55:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=GK6orrcJ; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTc64yQTz9sWD for ; Tue, 1 Jun 2021 20:56:22 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1F2703C904D for ; Tue, 1 Jun 2021 12:56:20 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 468973C59F3 for ; Tue, 1 Jun 2021 12:55:48 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id F0954600875 for ; Tue, 1 Jun 2021 12:55:47 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 94E9F218AB; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gDfv1L6CKuthNuWMKsrgN6515I1q0S0k7K8LV+de7I0=; b=GK6orrcJyE+oveL0inNG2fXvi1wTMod2N3fGPAUYm3Zg0/dZ4A/p+jumfqVCHwBa9b/OIn FA0gqlG9bi0538KhMSJiLIoPumXdoDIxBY/vzx/eby2hjXQkkqAw4ulGES3/Eif8HGmI1T eOmnsiGZI5Ye62KaZyuHM8hJYknGCRc= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 5D874A3B84; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:20 +0100 Message-Id: <20210601105521.27459-6-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v3 5/6] API/cgroups: tst_require fail gracefully with unknown controller X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- lib/tst_cgroup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c index 74746f13e..6d94ea41c 100644 --- a/lib/tst_cgroup.c +++ b/lib/tst_cgroup.c @@ -599,6 +599,12 @@ void tst_cgroup_require(const char *const ctrl_name, struct cgroup_ctrl *const ctrl = cgroup_find_ctrl(ctrl_name); struct cgroup_root *root; + if (!ctrl) { + tst_brk(TBROK, "'%s' controller is unknown to LTP", ctrl_name); + tst_brk(TBROK, "Calling %s in cleanup?", __func__); + return; + } + if (!options) options = &default_opts; From patchwork Tue Jun 1 10:55:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1485957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=oB5SXNW4; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FvTcS4GFDz9sWD for ; Tue, 1 Jun 2021 20:56:40 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0695F3C7732 for ; Tue, 1 Jun 2021 12:56:38 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id C7D033C59F3 for ; Tue, 1 Jun 2021 12:55:48 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 3C4FF200C68 for ; Tue, 1 Jun 2021 12:55:48 +0200 (CEST) Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E229021922; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1622544947; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KoQ/a2aENSSjs0stqX+VNt4FQm4epemjJUoa/hGyhCY=; b=oB5SXNW4hGcHaT5crUJYlJgDq+nic9JMfJogwKxA9J116ngNpFa1a5duwBvkH8eynFcfYk rxdw/QSbSYlfcruP3aHLHa0Q5VtBUdkTjbps0xwWS+HJwrb5+HtQ+g5ApL8b4bMTIYBJLH lco2EWh28hmLR56IcyW4KSlvLtEhRsM= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id A663EA3B84; Tue, 1 Jun 2021 10:55:47 +0000 (UTC) To: ltp@lists.linux.it Date: Tue, 1 Jun 2021 11:55:21 +0100 Message-Id: <20210601105521.27459-7-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210601105521.27459-1-rpalethorpe@suse.com> References: <20210601105521.27459-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v3 6/6] sched/cgroup: Add cfs_bandwidth01 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe Reviewed-by: Li Wang --- runtest/sched | 1 + .../kernel/sched/cfs-scheduler/.gitignore | 1 + testcases/kernel/sched/cfs-scheduler/Makefile | 4 +- .../sched/cfs-scheduler/cfs_bandwidth01.c | 184 ++++++++++++++++++ 4 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c diff --git a/runtest/sched b/runtest/sched index bfc4f2711..592898723 100644 --- a/runtest/sched +++ b/runtest/sched @@ -6,6 +6,7 @@ pth_str03 pth_str03 time-schedule01 time-schedule trace_sched01 trace_sched -c 1 +cfs_bandwidth01 cfs_bandwidth01 -i 5 hackbench01 hackbench 50 process 1000 hackbench02 hackbench 20 thread 1000 diff --git a/testcases/kernel/sched/cfs-scheduler/.gitignore b/testcases/kernel/sched/cfs-scheduler/.gitignore index db2759e4f..c5dacd6ef 100644 --- a/testcases/kernel/sched/cfs-scheduler/.gitignore +++ b/testcases/kernel/sched/cfs-scheduler/.gitignore @@ -1 +1,2 @@ /hackbench +cfs_bandwidth01 diff --git a/testcases/kernel/sched/cfs-scheduler/Makefile b/testcases/kernel/sched/cfs-scheduler/Makefile index aa3bf8459..2ffe1f7f9 100644 --- a/testcases/kernel/sched/cfs-scheduler/Makefile +++ b/testcases/kernel/sched/cfs-scheduler/Makefile @@ -18,8 +18,8 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lpthread +hackbench: LDLIBS += -lpthread include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c b/testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c new file mode 100644 index 000000000..b06cede16 --- /dev/null +++ b/testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c @@ -0,0 +1,184 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (c) 2021 SUSE LLC */ +/*\ + * + * [Description] + * + * Creates a multi-level CGroup hierarchy with the cpu controller + * enabled. The leaf groups are populated with "busy" processes which + * simulate intermittent cpu load. They spin for some time then sleep + * then repeat. + * + * Both the trunk and leaf groups are set cpu bandwidth limits. The + * busy processes will intermittently exceed these limits. Causing + * them to be throttled. When they begin sleeping this will then cause + * them to be unthrottle. + * + * The test is known to reproduce an issue with an update to + * SLE-15-SP1 (kernel 4.12.14-197.64, bsc#1179093). + */ + +#include + +#include "tst_test.h" +#include "tst_cgroup.h" +#include "tst_timer.h" + +static const struct tst_cgroup_group *cg_test; +static struct tst_cgroup_group *cg_level2, *cg_level3a, *cg_level3b; +static struct tst_cgroup_group *cg_workers[3]; +static int may_have_waiters = 0; + +static void set_cpu_quota(const struct tst_cgroup_group *const cg, + const float quota_percent) +{ + const unsigned int period_us = 10000; + const unsigned int quota_us = (quota_percent / 100) * (float)period_us; + + if (TST_CGROUP_VER(cg, "cpu") != TST_CGROUP_V1) { + SAFE_CGROUP_PRINTF(cg, "cpu.max", + "%u %u", quota_us, period_us); + } else { + SAFE_CGROUP_PRINTF(cg, "cpu.cfs_period_us", + "%u", period_us); + SAFE_CGROUP_PRINTF(cg, "cpu.max", + "%u", quota_us); + } + + tst_res(TINFO, "Set '%s/cpu.max' = '%d %d'", + tst_cgroup_group_name(cg), quota_us, period_us); +} + +static struct tst_cgroup_group * +mk_cpu_cgroup(const struct tst_cgroup_group *const cg_parent, + const char *const cg_child_name, + const float quota_percent) +{ + struct tst_cgroup_group *const cg = + tst_cgroup_group_mk(cg_parent, cg_child_name); + + set_cpu_quota(cg, quota_percent); + + return cg; +} + +static void busy_loop(const unsigned int sleep_ms) +{ + for (;;) { + tst_timer_start(CLOCK_MONOTONIC_RAW); + while (!tst_timer_expired_ms(20)) + ; + + const int ret = tst_checkpoint_wait(0, sleep_ms); + + if (!ret) + exit(0); + + if (errno != ETIMEDOUT) + tst_brk(TBROK | TERRNO, "tst_checkpoint_wait"); + } +} + +static void fork_busy_procs_in_cgroup(const struct tst_cgroup_group *const cg) +{ + const unsigned int sleeps_ms[] = {3000, 1000, 10}; + const pid_t worker_pid = SAFE_FORK(); + size_t i; + + if (worker_pid) + return; + + for (i = 0; i < ARRAY_SIZE(sleeps_ms); i++) { + const pid_t busy_pid = SAFE_FORK(); + + if (!busy_pid) + busy_loop(sleeps_ms[i]); + + SAFE_CGROUP_PRINTF(cg, "cgroup.procs", "%d", busy_pid); + } + + tst_reap_children(); + + exit(0); +} + +static void do_test(void) +{ + size_t i; + + may_have_waiters = 1; + for (i = 0; i < ARRAY_SIZE(cg_workers); i++) + fork_busy_procs_in_cgroup(cg_workers[i]); + + tst_res(TPASS, "Scheduled bandwidth constrained workers"); + + sleep(1); + + set_cpu_quota(cg_level2, 50); + + sleep(2); + + TST_CHECKPOINT_WAKE2(0, 3 * 3); + tst_reap_children(); + may_have_waiters = 0; + + tst_res(TPASS, "Workers exited"); +} + +static void setup(void) +{ + tst_cgroup_require("cpu", NULL); + + cg_test = tst_cgroup_get_test_group(); + + cg_level2 = tst_cgroup_group_mk(cg_test, "level2"); + + cg_level3a = tst_cgroup_group_mk(cg_level2, "level3a"); + cg_workers[0] = mk_cpu_cgroup(cg_level3a, "worker1", 30); + cg_workers[1] = mk_cpu_cgroup(cg_level3a, "worker2", 20); + + cg_level3b = tst_cgroup_group_mk(cg_level2, "level3b"); + cg_workers[2] = mk_cpu_cgroup(cg_level3b, "worker3", 30); +} + +static void cleanup(void) +{ + size_t i; + + if (may_have_waiters) { + TST_CHECKPOINT_WAKE2(0, 3 * 3); + tst_reap_children(); + may_have_waiters = 0; + } + + for (i = 0; i < ARRAY_SIZE(cg_workers); i++) { + if (cg_workers[i]) + cg_workers[i] = tst_cgroup_group_rm(cg_workers[i]); + } + + if (cg_level3a) + cg_level3a = tst_cgroup_group_rm(cg_level3a); + if (cg_level3b) + cg_level3b = tst_cgroup_group_rm(cg_level3b); + if (cg_level2) + cg_level2 = tst_cgroup_group_rm(cg_level2); + + tst_cgroup_cleanup(); +} + +static struct tst_test test = { + .test_all = do_test, + .setup = setup, + .cleanup = cleanup, + .forks_child = 1, + .needs_checkpoints = 1, + .taint_check = TST_TAINT_W | TST_TAINT_D, + .tags = (const struct tst_tag[]) { + {"linux-git", "39f23ce07b93"}, + {"linux-git", "b34cb07dde7c"}, + {"linux-git", "fe61468b2cbc"}, + {"linux-git", "5ab297bab984"}, + {"linux-git", "6d4d22468dae"}, + { } + } +};