From patchwork Fri May 22 01:23:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1295795 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; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=C8QVqf9w; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Spff43zlz9sSW for ; Fri, 22 May 2020 11:23:53 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6169F3C2599 for ; Fri, 22 May 2020 03:23:49 +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]) by picard.linux.it (Postfix) with ESMTP id 7D3813C0EC2 for ; Fri, 22 May 2020 03:23:37 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id 870381400E1D for ; Fri, 22 May 2020 03:23:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590110614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vxudY156bGCRdGQZK/MPi1qa0K7X2Wo/ADt6HCYgEjc=; b=C8QVqf9w+tCs2UyxHAyngkK+P9GIf4DUNygzn2d2OYFsuQbKPooHLzEFeDMJM4VFz9sXQm pKz/mCdVUm7RTg7t7cttv1CuUk+aCSCYl/7ygRAGq4HhOek2fFw19UeMqEKHgDQjpAPbiL Gh5DPct6ASemhGl0Po4Fv7Zz82jSH9A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-uWKfyys5NPGyM0vBXng_kQ-1; Thu, 21 May 2020 21:23:31 -0400 X-MC-Unique: uWKfyys5NPGyM0vBXng_kQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 559A618FE889 for ; Fri, 22 May 2020 01:23:30 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A0341C950 for ; Fri, 22 May 2020 01:23:28 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Fri, 22 May 2020 09:23:24 +0800 Message-Id: <20200522012327.18991-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH RFC 1/4] lib: add new cgroup test 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Many of our LTP tests need Control Group in the configuration, this patch makes cgroup unified mounting at setup phase to be possible. The method is extracted from mem.h with the purpose of extendible for further developing, and trying to compatible the current two versions of cgroup, It's hard to make all APIs be strictly consistent because there are many differences between v1 and v2. But it capsulate the detail of cgroup mounting in high-level functions, which will be easier to use cgroup without considering too much technical thing.    Btw, test get passed on RHEL7(x86_64), RHEL8(ppc64le), Fedora32(x86_64). Signed-off-by: Li Wang --- include/tst_cgroup.h | 108 ++++++++++++++++++++ include/tst_test.h | 1 + lib/tst_cgroup.c | 232 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 341 insertions(+) create mode 100644 include/tst_cgroup.h create mode 100644 lib/tst_cgroup.c diff --git a/include/tst_cgroup.h b/include/tst_cgroup.h new file mode 100644 index 000000000..78e646c2e --- /dev/null +++ b/include/tst_cgroup.h @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Red Hat, Inc. + */ + +#ifndef TST_CGROUP_H +#define TST_CGROUP_H + +#define PATH_SYS_CGROUP "/sys/fs/cgroup" + +enum tst_cgroup_ver { + TST_CGROUP_V1 = 1, + TST_CGROUP_V2 = 2, +}; + +static enum tst_cgroup_ver tst_cg_ver; + +enum tst_cgroup_ver tst_cgroup_version(void); + +/* cgroup v1 */ +#define PATH_TMP_CG1_MEM "/tmp/cgroup1_mem" +#define PATH_TMP_CG1_CST "/tmp/cgroup1_cpuset" +#define PATH_CG1_MEM_LTP PATH_TMP_CG1_MEM "/ltp" +#define PATH_CG1_CST_LTP PATH_TMP_CG1_CST "/ltp" +#define PATH_MEMORY_LIMIT PATH_CG1_MEM_LTP "/memory.limit_in_bytes" +#define PATH_MEMORY_SW_LIMIT PATH_CG1_MEM_LTP "/memory.memsw.limit_in_bytes" + +void tst_mount_cgroup1(const char *name, const char *option, + const char *mnt_path, const char *new_path); +void tst_umount_cgroup1(const char *mnt_path, const char *new_path); + +void tst_mount_memcg1(void); +void tst_umount_memcg1(void); +void tst_write_memcg1(long memsz); + +void tst_mount_cpusetcg1(void); +void tst_umount_cpusetcg1(void); +void tst_write_cpusetcg1(void); +/* cgroup v1 */ + +/* cgroup v2 */ +#define PATH_TMP_CGROUP2 "/tmp/cgroup2" /* cgroup v2 has only single hierarchy */ +#define PATH_TMP_CG2_LTP PATH_TMP_CGROUP2 "/ltp" +#define PATH_MEMORY_MAX PATH_TMP_CG2_LTP "/memory.max" +#define PATH_MEMORY_SW_MAX PATH_TMP_CG2_LTP "/memory.swap.max" + +void tst_mount_cgroup2(const char *mnt_path, const char *new_path); +void tst_umount_cgroup2(const char *mnt_path, const char *new_path); + +void tst_mount_memcg2(void); +void tst_umount_memcg2(void); +void tst_write_memcg2(long memsz); + +void tst_mount_cpusetcg2(void); +/* cgroup v2 */ + +static inline void tst_mount_memcg(void) +{ + tst_cg_ver = tst_cgroup_version(); + + if (tst_cg_ver & TST_CGROUP_V1) + tst_mount_memcg1(); + + if (tst_cg_ver & TST_CGROUP_V2) + tst_mount_memcg2(); +} + +static inline void tst_umount_memcg(void) +{ + if (tst_cg_ver & TST_CGROUP_V1) + tst_umount_memcg1(); + + if (tst_cg_ver & TST_CGROUP_V2) + tst_umount_memcg2(); +} + +static inline void tst_write_memcg(long memsz) +{ + if (tst_cg_ver & TST_CGROUP_V1) + tst_write_memcg1(memsz); + + if (tst_cg_ver & TST_CGROUP_V2) + tst_write_memcg2(memsz); +} + +static inline void tst_mount_cpusetcg(void) +{ + tst_cg_ver = tst_cgroup_version(); + + if (tst_cg_ver & TST_CGROUP_V1) + tst_mount_cpusetcg1(); + + if (tst_cg_ver & TST_CGROUP_V2) + tst_mount_cpusetcg2(); +} + +static inline void tst_umount_cpusetcg(void) +{ + if (tst_cg_ver & TST_CGROUP_V1) + tst_umount_cpusetcg1(); +} + +static inline void tst_write_cpusetcg(void) +{ + if (tst_cg_ver & TST_CGROUP_V1) + tst_write_cpusetcg1(); +} +#endif /* TST_CGROUP_H */ diff --git a/include/tst_test.h b/include/tst_test.h index 5bedb4f6f..b84f7b9dd 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -39,6 +39,7 @@ #include "tst_capability.h" #include "tst_hugepage.h" #include "tst_assert.h" +#include "tst_cgroup.h" /* * Reports testcase result. diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c new file mode 100644 index 000000000..88374012f --- /dev/null +++ b/lib/tst_cgroup.c @@ -0,0 +1,232 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Red Hat, Inc. + */ + +#define TST_NO_DEFAULT_MAIN + +#include +#include + +#include "tst_test.h" +#include "tst_safe_macros.h" +#include "tst_safe_stdio.h" +#include "tst_cgroup.h" +#include "tst_device.h" + +static int tst_cgroup_check(const char *cgroup) +{ + char line[PATH_MAX]; + FILE *file; + int cg_check = 0; + + file = SAFE_FOPEN("/proc/filesystems", "r"); + while (fgets(line, sizeof(line), file)) { + if (strstr(line, cgroup) != NULL) { + cg_check = 1; + break; + } + } + SAFE_FCLOSE(file); + + return cg_check; +} + +enum tst_cgroup_ver tst_cgroup_version(void) +{ + if (tst_cgroup_check("cgroup2")) { + if (!tst_is_mounted("cgroup2") && tst_is_mounted("cgroup")) + return TST_CGROUP_V1; + else + return TST_CGROUP_V2; + } + + if (tst_cgroup_check("cgroup")) + return TST_CGROUP_V1; + + tst_brk(TCONF, "Cgroup is not configured"); +} + +/* cgroup v1 */ +void tst_mount_cgroup1(const char *name, const char *option, + const char *mnt_path, const char *new_path) +{ + if (tst_is_mounted(mnt_path)) + goto out; + + SAFE_MKDIR(mnt_path, 0777); + if (mount(name, mnt_path, "cgroup", 0, option) == -1) { + if (errno == ENODEV) { + if (rmdir(mnt_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s failed", mnt_path); + tst_brk(TCONF, + "Cgroup v1 is not configured in kernel"); + } + tst_brk(TBROK | TERRNO, "mount %s", mnt_path); + } + +out: + SAFE_MKDIR(new_path, 0777); + + tst_res(TINFO, "Cgroup(%s) v1 mount at %s success", option, mnt_path); +} + +void tst_umount_cgroup1(const char *mnt_path, const char *new_path) +{ + FILE *fp; + int fd; + char s_new[BUFSIZ], s[BUFSIZ], value[BUFSIZ]; + + if (!tst_is_mounted(mnt_path)) + return; + + /* Move all processes in task to its parent node. */ + sprintf(s, "%s/tasks", mnt_path); + fd = open(s, O_WRONLY); + if (fd == -1) + tst_res(TWARN | TERRNO, "open %s", s); + + snprintf(s_new, BUFSIZ, "%s/tasks", new_path); + fp = fopen(s_new, "r"); + if (fp == NULL) + tst_res(TWARN | TERRNO, "fopen %s", s_new); + if ((fd != -1) && (fp != NULL)) { + while (fgets(value, BUFSIZ, fp) != NULL) + if (write(fd, value, strlen(value) - 1) + != (ssize_t)strlen(value) - 1) + tst_res(TWARN | TERRNO, "write %s", s); + } + if (fd != -1) + close(fd); + if (fp != NULL) + fclose(fp); + if (rmdir(new_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s", new_path); + if (umount(mnt_path) == -1) + tst_res(TWARN | TERRNO, "umount %s", mnt_path); + if (rmdir(mnt_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s", mnt_path); + + tst_res(TINFO, "Cgroup v1 unmount success"); +} + +void tst_mount_memcg1(void) +{ + tst_mount_cgroup1("memcg", "memory", PATH_TMP_CG1_MEM, PATH_CG1_MEM_LTP); +} + +void tst_umount_memcg1(void) +{ + tst_umount_cgroup1(PATH_TMP_CG1_MEM, PATH_CG1_MEM_LTP); +} + +void tst_write_memcg1(long memsz) +{ + SAFE_FILE_PRINTF(PATH_CG1_MEM_LTP "/memory.limit_in_bytes", "%ld", memsz); + + SAFE_FILE_PRINTF(PATH_CG1_MEM_LTP "/tasks", "%d", getpid()); +} + +void tst_mount_cpusetcg1(void) +{ + tst_mount_cgroup1("cpusetcg", "cpuset", PATH_TMP_CG1_CST, PATH_CG1_CST_LTP); +} + +void tst_umount_cpusetcg1(void) +{ + tst_umount_cgroup1(PATH_TMP_CG1_CST, PATH_CG1_CST_LTP); +} + +void tst_write_cpusetcg1(void) +{ + SAFE_FILE_PRINTF(PATH_CG1_CST_LTP "/tasks", "%d", getpid()); +} +/* cgroup v1 */ + +/* cgroup v2 */ +void tst_mount_cgroup2(const char *mnt_path, const char *new_path) +{ + if (tst_is_mounted(mnt_path)) + goto out; + + SAFE_MKDIR(mnt_path, 0777); + if (mount("cgroup2", mnt_path, "cgroup2", 0, NULL) == -1) { + if (errno == ENODEV) { + if (rmdir(mnt_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s failed", + mnt_path); + tst_brk(TCONF, + "Cgroup v2 is not configured in kernel"); + } + tst_brk(TBROK | TERRNO, "mount %s", mnt_path); + } + +out: + SAFE_MKDIR(new_path, 0777); + + tst_res(TINFO, "Cgroup v2 mount at %s success", mnt_path); +} + +void tst_umount_cgroup2(const char *mnt_path, const char *new_path) +{ + FILE *fp; + int fd; + char s_new[BUFSIZ], s[BUFSIZ], value[BUFSIZ]; + + if (!tst_is_mounted(mnt_path)) + return; + + /* Move all processes in cgroup.procs to its parent node. */ + sprintf(s, "%s/cgroup.procs", mnt_path); + fd = open(s, O_WRONLY); + if (fd == -1) + tst_res(TWARN | TERRNO, "open %s", s); + + snprintf(s_new, BUFSIZ, "%s/cgroup.procs", new_path); + fp = fopen(s_new, "r"); + if (fp == NULL) + tst_res(TWARN | TERRNO, "fopen %s", s_new); + if ((fd != -1) && (fp != NULL)) { + while (fgets(value, BUFSIZ, fp) != NULL) + if (write(fd, value, strlen(value) - 1) + != (ssize_t)strlen(value) - 1) + tst_res(TWARN | TERRNO, "write %s", s); + } + if (fd != -1) + close(fd); + if (fp != NULL) + fclose(fp); + if (rmdir(new_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s", new_path); + if (umount(mnt_path) == -1) + tst_res(TWARN | TERRNO, "umount %s", mnt_path); + if (rmdir(mnt_path) == -1) + tst_res(TWARN | TERRNO, "rmdir %s", mnt_path); + + tst_res(TINFO, "Cgroup v2 unmount success"); +} + +void tst_mount_memcg2(void) +{ + tst_mount_cgroup2(PATH_TMP_CGROUP2, PATH_TMP_CG2_LTP); + + SAFE_FILE_PRINTF(PATH_TMP_CGROUP2 "/cgroup.subtree_control", "%s", "+memory"); +} + +void tst_umount_memcg2() +{ + tst_umount_cgroup2(PATH_TMP_CGROUP2, PATH_TMP_CG2_LTP); +} + +void tst_write_memcg2(long memsz) +{ + SAFE_FILE_PRINTF(PATH_TMP_CG2_LTP "/memory.max", "%ld", memsz); + + SAFE_FILE_PRINTF(PATH_TMP_CG2_LTP "/cgroup.procs", "%d", getpid()); +} + +void tst_mount_cpusetcg2(void) +{ + tst_brk(TCONF, "Cgroup v2 hasn't achieve cpuset subsystem"); +} +/* cgroup v2 */ From patchwork Fri May 22 01:23:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1295797 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; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HqLVeTTl; 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 49Spg110wjz9sSW for ; Fri, 22 May 2020 11:24:13 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 77E553C2527 for ; Fri, 22 May 2020 03:24:10 +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 [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id ABEC13C4D38 for ; Fri, 22 May 2020 03:23:39 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id C6D391400E66 for ; Fri, 22 May 2020 03:23:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590110617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WMIuAhZLzz3MGDy8GV/Gv/QwmUm/Gt2CZI+q9p8cclg=; b=HqLVeTTlwq1Q6K314SkLHyE3NVn+3QwC5I7qcCpifv3qGuWukMYYMM+BUn0t3DzQsdWkXC OeYtSWlhGeCtuMVrYoHJiaXTeub40QevwvnlTzRAjUR7y2MvkPlE5JmAW5bQCp4/Ibdz1N zKq7uEQRcPje2qkxLi1YOHlpQhBhtLA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-XrALe1yFOo-upftV3ggsKQ-1; Thu, 21 May 2020 21:23:32 -0400 X-MC-Unique: XrALe1yFOo-upftV3ggsKQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9CAB318FE861 for ; Fri, 22 May 2020 01:23:31 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFF3A99D1 for ; Fri, 22 May 2020 01:23:30 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Fri, 22 May 2020 09:23:25 +0800 Message-Id: <20200522012327.18991-2-liwang@redhat.com> In-Reply-To: <20200522012327.18991-1-liwang@redhat.com> References: <20200522012327.18991-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH RFC 2/4] mem: take use of new cgroup 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" For issue #611: https://github.com/linux-test-project/ltp/issues/611 Signed-off-by: Li Wang --- testcases/kernel/mem/cpuset/cpuset01.c | 19 +++++++++-------- testcases/kernel/mem/include/mem.h | 1 + testcases/kernel/mem/ksm/ksm02.c | 6 ++---- testcases/kernel/mem/ksm/ksm03.c | 11 +++------- testcases/kernel/mem/ksm/ksm04.c | 14 +++++-------- testcases/kernel/mem/lib/mem.c | 8 +++---- testcases/kernel/mem/oom/oom03.c | 20 +++++++++--------- testcases/kernel/mem/oom/oom04.c | 8 +++---- testcases/kernel/mem/oom/oom05.c | 29 ++++++++++++++------------ 9 files changed, 54 insertions(+), 62 deletions(-) diff --git a/testcases/kernel/mem/cpuset/cpuset01.c b/testcases/kernel/mem/cpuset/cpuset01.c index 853f7fe55..0db919121 100644 --- a/testcases/kernel/mem/cpuset/cpuset01.c +++ b/testcases/kernel/mem/cpuset/cpuset01.c @@ -51,11 +51,11 @@ static void test_cpuset(void) unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 }; char mems[BUFSIZ], buf[BUFSIZ]; - read_cpuset_files(CPATH, "cpus", buf); - write_cpuset_files(CPATH_NEW, "cpus", buf); - read_cpuset_files(CPATH, "mems", mems); - write_cpuset_files(CPATH_NEW, "mems", mems); - SAFE_FILE_PRINTF(CPATH_NEW "/tasks", "%d", getpid()); + read_cpuset_files(PATH_TMP_CG1_CST, "cpus", buf); + write_cpuset_files(PATH_CG1_CST_LTP, "cpus", buf); + read_cpuset_files(PATH_TMP_CG1_CST, "mems", mems); + write_cpuset_files(PATH_CG1_CST_LTP, "mems", mems); + SAFE_FILE_PRINTF(PATH_CG1_CST_LTP "/tasks", "%d", getpid()); child = SAFE_FORK(); if (child == 0) { @@ -70,9 +70,9 @@ static void test_cpuset(void) } snprintf(buf, BUFSIZ, "%d", nodes[0]); - write_cpuset_files(CPATH_NEW, "mems", buf); + write_cpuset_files(PATH_CG1_CST_LTP, "mems", buf); snprintf(buf, BUFSIZ, "%d", nodes[1]); - write_cpuset_files(CPATH_NEW, "mems", buf); + write_cpuset_files(PATH_CG1_CST_LTP, "mems", buf); SAFE_WAITPID(child, &status, WUNTRACED | WCONTINUED); if (WEXITSTATUS(status) != 0) { @@ -85,7 +85,7 @@ static void test_cpuset(void) static void setup(void) { - mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); + tst_mount_cpusetcg(); ncpus = count_cpu(); if (get_allowed_nodes_arr(NH_MEMS | NH_CPUS, &nnodes, &nodes) < 0) tst_brk(TBROK | TERRNO, "get_allowed_nodes_arr"); @@ -95,7 +95,7 @@ static void setup(void) static void cleanup(void) { - umount_mem(CPATH, CPATH_NEW); + tst_umount_cpusetcg(); } static void sighandler(int signo LTP_ATTRIBUTE_UNUSED) @@ -183,6 +183,7 @@ static long count_cpu(void) static struct tst_test test = { .needs_root = 1, + .forks_child = 1, .setup = setup, .cleanup = cleanup, .test_all = test_cpuset, diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h index cce9c0497..f553651c2 100644 --- a/testcases/kernel/mem/include/mem.h +++ b/testcases/kernel/mem/include/mem.h @@ -2,6 +2,7 @@ #define _MEM_H #include "config.h" #include "tst_test.h" +#include "tst_cgroup.h" #include "ksm_helper.h" #if defined(__powerpc__) || defined(__powerpc64__) diff --git a/testcases/kernel/mem/ksm/ksm02.c b/testcases/kernel/mem/ksm/ksm02.c index 3d4c19deb..dffafc412 100644 --- a/testcases/kernel/mem/ksm/ksm02.c +++ b/testcases/kernel/mem/ksm/ksm02.c @@ -88,8 +88,7 @@ static void cleanup(void) FILE_PRINTF(PATH_KSM "merge_across_nodes", "%d", merge_across_nodes); - if (cpuset_mounted) - umount_mem(CPATH, CPATH_NEW); + tst_umount_cpusetcg(); } static void setup(void) @@ -105,8 +104,7 @@ static void setup(void) SAFE_FILE_PRINTF(PATH_KSM "merge_across_nodes", "1"); } - mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); - cpuset_mounted = 1; + tst_mount_cpusetcg(); } static struct tst_test test = { diff --git a/testcases/kernel/mem/ksm/ksm03.c b/testcases/kernel/mem/ksm/ksm03.c index 0e5131654..8dd794a75 100644 --- a/testcases/kernel/mem/ksm/ksm03.c +++ b/testcases/kernel/mem/ksm/ksm03.c @@ -59,11 +59,9 @@ #include "mem.h" #include "ksm_common.h" -static int memcg_mounted; - static void verify_ksm(void) { - write_memcg(); + tst_write_memcg(TESTMEM); create_same_memory(size, num, unit); } @@ -79,8 +77,7 @@ static void setup(void) } parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit); - mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW); - memcg_mounted = 1; + tst_mount_memcg(); } static void cleanup(void) @@ -88,9 +85,7 @@ static void cleanup(void) if (access(PATH_KSM "merge_across_nodes", F_OK) == 0) FILE_PRINTF(PATH_KSM "merge_across_nodes", "%d", merge_across_nodes); - - if (memcg_mounted) - umount_mem(MEMCG_PATH, MEMCG_PATH_NEW); + tst_umount_memcg(); } static struct tst_test test = { diff --git a/testcases/kernel/mem/ksm/ksm04.c b/testcases/kernel/mem/ksm/ksm04.c index e393dbd40..0a6fbd8a4 100644 --- a/testcases/kernel/mem/ksm/ksm04.c +++ b/testcases/kernel/mem/ksm/ksm04.c @@ -70,7 +70,7 @@ static void verify_ksm(void) node = get_a_numa_node(); set_node(nmask, node); - write_memcg(); + tst_write_memcg(TESTMEM); if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1) { if (errno != ENOSYS) @@ -91,10 +91,8 @@ static void cleanup(void) FILE_PRINTF(PATH_KSM "merge_across_nodes", "%d", merge_across_nodes); - if (cpuset_mounted) - umount_mem(CPATH, CPATH_NEW); - if (memcg_mounted) - umount_mem(MEMCG_PATH, MEMCG_PATH_NEW); + tst_umount_cpusetcg(); + tst_umount_memcg(); } static void setup(void) @@ -110,10 +108,8 @@ static void setup(void) parse_ksm_options(opt_sizestr, &size, opt_numstr, &num, opt_unitstr, &unit); - mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); - cpuset_mounted = 1; - mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW); - memcg_mounted = 1; + tst_mount_memcg(); + tst_mount_cpusetcg(); } static struct tst_test test = { diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index eca4c61c8..df1baa42a 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -692,7 +692,7 @@ void write_cpusets(long nd) char cpus[BUFSIZ] = ""; snprintf(buf, BUFSIZ, "%ld", nd); - write_cpuset_files(CPATH_NEW, "mems", buf); + write_cpuset_files(PATH_CG1_CST_LTP, "mems", buf); gather_node_cpus(cpus, nd); /* @@ -701,14 +701,14 @@ void write_cpusets(long nd) * the value of cpuset.cpus. */ if (strlen(cpus) != 0) { - write_cpuset_files(CPATH_NEW, "cpus", cpus); + write_cpuset_files(PATH_CG1_CST_LTP, "cpus", cpus); } else { tst_res(TINFO, "No CPUs in the node%ld; " "using only CPU0", nd); - write_cpuset_files(CPATH_NEW, "cpus", "0"); + write_cpuset_files(PATH_CG1_CST_LTP, "cpus", "0"); } - SAFE_FILE_PRINTF(CPATH_NEW "/tasks", "%d", getpid()); + SAFE_FILE_PRINTF(PATH_CG1_CST_LTP "/tasks", "%d", getpid()); } void umount_mem(char *path, char *path_new) diff --git a/testcases/kernel/mem/oom/oom03.c b/testcases/kernel/mem/oom/oom03.c index ce0b34c31..b437952f3 100644 --- a/testcases/kernel/mem/oom/oom03.c +++ b/testcases/kernel/mem/oom/oom03.c @@ -36,27 +36,29 @@ #ifdef HAVE_NUMA_V2 -static int memcg_mounted; - static void verify_oom(void) { #ifdef TST_ABI32 tst_brk(TCONF, "test is not designed for 32-bit system."); #endif - SAFE_FILE_PRINTF(MEMCG_PATH_NEW "/tasks", "%d", getpid()); - SAFE_FILE_PRINTF(MEMCG_LIMIT, "%ld", TESTMEM); + tst_write_memcg(TESTMEM); testoom(0, 0, ENOMEM, 1); - if (access(MEMCG_SW_LIMIT, F_OK) == -1) { + if ((access(PATH_MEMORY_SW_LIMIT, F_OK) == -1) || + (access(PATH_MEMORY_SW_MAX, F_OK) == -1)) { if (errno == ENOENT) tst_res(TCONF, "memcg swap accounting is disabled"); else tst_brk(TBROK | TERRNO, "access"); } else { - SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "%ld", TESTMEM); + if (tst_cg_ver & TST_CGROUP_V1) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_LIMIT, "%ld", TESTMEM); + if (tst_cg_ver & TST_CGROUP_V2) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_MAX, "%ld", TESTMEM); + testoom(0, 1, ENOMEM, 1); } @@ -73,16 +75,14 @@ static void setup(void) { overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); - mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW); - memcg_mounted = 1; + tst_mount_memcg(); } static void cleanup(void) { if (overcommit != -1) set_sys_tune("overcommit_memory", overcommit, 0); - if (memcg_mounted) - umount_mem(MEMCG_PATH, MEMCG_PATH_NEW); + tst_umount_memcg(); } static struct tst_test test = { diff --git a/testcases/kernel/mem/oom/oom04.c b/testcases/kernel/mem/oom/oom04.c index 7185ef973..0ce4c81ae 100644 --- a/testcases/kernel/mem/oom/oom04.c +++ b/testcases/kernel/mem/oom/oom04.c @@ -53,7 +53,7 @@ static void verify_oom(void) * is in charge of cpuset.memory_migrate, we can write * 1 to cpuset.memory_migrate to enable the migration. */ - write_cpuset_files(CPATH_NEW, "memory_migrate", "1"); + write_cpuset_files(PATH_CG1_CST_LTP, "memory_migrate", "1"); tst_res(TINFO, "OOM on CPUSET with mem migrate:"); testoom(0, 0, ENOMEM, 1); } @@ -69,8 +69,7 @@ static void setup(void) overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); - mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); - cpuset_mounted = 1; + tst_mount_cpusetcg(); /* * Some nodes do not contain memory, so use @@ -89,8 +88,7 @@ static void cleanup(void) { if (overcommit != -1) set_sys_tune("overcommit_memory", overcommit, 0); - if (cpuset_mounted) - umount_mem(CPATH, CPATH_NEW); + tst_umount_cpusetcg(); } static struct tst_test test = { diff --git a/testcases/kernel/mem/oom/oom05.c b/testcases/kernel/mem/oom/oom05.c index db24df6de..1ab272655 100644 --- a/testcases/kernel/mem/oom/oom05.c +++ b/testcases/kernel/mem/oom/oom05.c @@ -56,13 +56,14 @@ static void verify_oom(void) * 1 to cpuset.memory_migrate to enable the migration. */ if (is_numa(NULL, NH_MEMS, 2)) { - write_cpuset_files(CPATH_NEW, "memory_migrate", "1"); + write_cpuset_files(PATH_CG1_CST_LTP, "memory_migrate", "1"); tst_res(TINFO, "OOM on CPUSET & MEMCG with " "cpuset.memory_migrate=1"); testoom(0, 0, ENOMEM, 1); } - if (access(MEMCG_SW_LIMIT, F_OK) == -1) { + if ((access(PATH_MEMORY_SW_LIMIT, F_OK) == -1) || + (access(PATH_MEMORY_SW_MAX, F_OK) == -1)) { if (errno == ENOENT) { tst_res(TCONF, "memcg swap accounting is disabled"); swap_acc_on = 0; @@ -73,12 +74,18 @@ static void verify_oom(void) if (swap_acc_on) { tst_res(TINFO, "OOM on CPUSET & MEMCG with " "special memswap limitation:"); - SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "%ld", TESTMEM); + if (tst_cg_ver & TST_CGROUP_V1) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_LIMIT, "%ld", TESTMEM); + if (tst_cg_ver & TST_CGROUP_V2) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_MAX, "%ld", TESTMEM); testoom(0, 0, ENOMEM, 1); tst_res(TINFO, "OOM on CPUSET & MEMCG with " "disabled memswap limitation:"); - SAFE_FILE_PRINTF(MEMCG_SW_LIMIT, "-1"); + if (tst_cg_ver & TST_CGROUP_V1) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_LIMIT, "%ld", -1); + if (tst_cg_ver & TST_CGROUP_V2) + SAFE_FILE_PRINTF(PATH_MEMORY_SW_MAX, "%ld", -1); testoom(0, 0, ENOMEM, 1); } } @@ -93,11 +100,9 @@ void setup(void) overcommit = get_sys_tune("overcommit_memory"); set_sys_tune("overcommit_memory", 1, 1); - mount_mem("memcg", "cgroup", "memory", MEMCG_PATH, MEMCG_PATH_NEW); - memcg_mounted = 1; - mount_mem("cpuset", "cpuset", NULL, CPATH, CPATH_NEW); - cpuset_mounted = 1; - write_memcg(); + tst_mount_memcg(); + tst_mount_cpusetcg(); + tst_write_memcg(TESTMEM); /* * Some nodes do not contain memory, so use @@ -116,10 +121,8 @@ void cleanup(void) { if (overcommit != -1) set_sys_tune("overcommit_memory", overcommit, 0); - if (cpuset_mounted) - umount_mem(CPATH, CPATH_NEW); - if (memcg_mounted) - umount_mem(MEMCG_PATH, MEMCG_PATH_NEW); + tst_umount_cpusetcg(); + tst_umount_memcg(); } static struct tst_test test = { From patchwork Fri May 22 01:23:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1295794 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; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=S3Z8y6UW; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Spff443Vz9sT1 for ; Fri, 22 May 2020 11:23:51 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 847E93C4D35 for ; Fri, 22 May 2020 03:23:39 +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]) by picard.linux.it (Postfix) with ESMTP id D71E13C0EC2 for ; Fri, 22 May 2020 03:23:37 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id 9AEBC201264 for ; Fri, 22 May 2020 03:23:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590110615; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wu0ch1vFE2jTjijqekeuibgIoaWfloqwr6XZ0wGnUAE=; b=S3Z8y6UWYfTUQPCzrNIexcyCRBoen7okkqrMOBn3uIfZocyJxM3ekE+Cv4vjexwbWYrlOy 9gl1tFzT46OLOYS8bjiWEzEGLV5dN75Nukrkjn0EG5SC7ubnklzmDl30MG2olQ17ixREEC 3pgbnwZonvb2xo8KpvTc+dTQPQOGNo8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-XuCZWXXUMAiwG4SfQTHhZA-1; Thu, 21 May 2020 21:23:33 -0400 X-MC-Unique: XuCZWXXUMAiwG4SfQTHhZA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E32938015CF for ; Fri, 22 May 2020 01:23:32 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2291738D for ; Fri, 22 May 2020 01:23:31 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Fri, 22 May 2020 09:23:26 +0800 Message-Id: <20200522012327.18991-3-liwang@redhat.com> In-Reply-To: <20200522012327.18991-2-liwang@redhat.com> References: <20200522012327.18991-1-liwang@redhat.com> <20200522012327.18991-2-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH RFC 3/4] mem: remove the old cgroup 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Li Wang --- testcases/kernel/mem/include/mem.h | 16 +-------- testcases/kernel/mem/lib/mem.c | 58 ------------------------------ 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/testcases/kernel/mem/include/mem.h b/testcases/kernel/mem/include/mem.h index f553651c2..0e089fae2 100644 --- a/testcases/kernel/mem/include/mem.h +++ b/testcases/kernel/mem/include/mem.h @@ -60,24 +60,10 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages); void check_hugepage(void); void write_memcg(void); -/* cpuset/memcg */ - -#define CPATH "/dev/cpuset" -#define CPATH_NEW CPATH "/1" -#define MEMCG_PATH "/dev/cgroup" -#define MEMCG_PATH_NEW MEMCG_PATH "/1" -#define MEMCG_LIMIT MEMCG_PATH_NEW "/memory.limit_in_bytes" -#define MEMCG_SW_LIMIT MEMCG_PATH_NEW "/memory.memsw.limit_in_bytes" -#if HAVE_SYS_EVENTFD_H -#define PATH_OOMCTRL MEMCG_PATH_NEW "/memory.oom_control" -#define PATH_EVTCTRL MEMCG_PATH_NEW "/cgroup.event_control" -#endif - +/* cpuset/memcg - include/tst_cgroup.h */ void read_cpuset_files(char *prefix, char *filename, char *retbuf); void write_cpuset_files(char *prefix, char *filename, char *buf); void write_cpusets(long nd); -void mount_mem(char *name, char *fs, char *options, char *path, char *path_new); -void umount_mem(char *path, char *path_new); /* shared */ unsigned int get_a_numa_node(void); diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index df1baa42a..3ccba142e 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -312,13 +312,6 @@ void check_hugepage(void) tst_brk(TCONF, "Huge page is not supported."); } -void write_memcg(void) -{ - SAFE_FILE_PRINTF(MEMCG_LIMIT, "%ld", TESTMEM); - - SAFE_FILE_PRINTF(MEMCG_PATH_NEW "/tasks", "%d", getpid()); -} - struct ksm_merge_data { char data; unsigned int mergeable_size; @@ -711,57 +704,6 @@ void write_cpusets(long nd) SAFE_FILE_PRINTF(PATH_CG1_CST_LTP "/tasks", "%d", getpid()); } -void umount_mem(char *path, char *path_new) -{ - FILE *fp; - int fd; - char s_new[BUFSIZ], s[BUFSIZ], value[BUFSIZ]; - - /* Move all processes in task to its parent node. */ - sprintf(s, "%s/tasks", path); - fd = open(s, O_WRONLY); - if (fd == -1) - tst_res(TWARN | TERRNO, "open %s", s); - - snprintf(s_new, BUFSIZ, "%s/tasks", path_new); - fp = fopen(s_new, "r"); - if (fp == NULL) - tst_res(TWARN | TERRNO, "fopen %s", s_new); - if ((fd != -1) && (fp != NULL)) { - while (fgets(value, BUFSIZ, fp) != NULL) - if (write(fd, value, strlen(value) - 1) - != (ssize_t)strlen(value) - 1) - tst_res(TWARN | TERRNO, "write %s", s); - } - if (fd != -1) - close(fd); - if (fp != NULL) - fclose(fp); - if (rmdir(path_new) == -1) - tst_res(TWARN | TERRNO, "rmdir %s", path_new); - if (umount(path) == -1) - tst_res(TWARN | TERRNO, "umount %s", path); - if (rmdir(path) == -1) - tst_res(TWARN | TERRNO, "rmdir %s", path); -} - -void mount_mem(char *name, char *fs, char *options, char *path, char *path_new) -{ - SAFE_MKDIR(path, 0777); - if (mount(name, path, fs, 0, options) == -1) { - if (errno == ENODEV) { - if (rmdir(path) == -1) - tst_res(TWARN | TERRNO, "rmdir %s failed", - path); - tst_brk(TCONF, - "file system %s is not configured in kernel", - fs); - } - tst_brk(TBROK | TERRNO, "mount %s", path); - } - SAFE_MKDIR(path_new, 0777); -} - /* shared */ /* Warning: *DO NOT* use this function in child */ From patchwork Fri May 22 01:23:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1295796 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; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UntbO2+N; 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 49Spfr10Qdz9sSW for ; Fri, 22 May 2020 11:24:04 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8E0D53C4D71 for ; Fri, 22 May 2020 03:24:01 +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]) by picard.linux.it (Postfix) with ESMTP id 57FAF3C4D34 for ; Fri, 22 May 2020 03:23:39 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id B5E87201264 for ; Fri, 22 May 2020 03:23:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590110617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UTz+r9ZQtFKCpb8oFl0jewtU8u62a4TUk5koZzTraEw=; b=UntbO2+NcnFI3hhktR3xxnL6iI4qiex5fMV9ypuEbtW7Q/10AvfasT6QQSXUhqEgLLMdgu f1Xk4A6UNqOKf7YdPRbYEkcm8RwNREJRmTWgGHmO3smJACq2eBb4f+WPWof7KTaBizokrk O2siGPxzSDXG0wx3JRtzMLykMQnGuRY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-pSqakvkgMYe1-DjliUypDg-1; Thu, 21 May 2020 21:23:35 -0400 X-MC-Unique: pSqakvkgMYe1-DjliUypDg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36DB6100CCC3 for ; Fri, 22 May 2020 01:23:34 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 697582E19C for ; Fri, 22 May 2020 01:23:33 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Fri, 22 May 2020 09:23:27 +0800 Message-Id: <20200522012327.18991-4-liwang@redhat.com> In-Reply-To: <20200522012327.18991-3-liwang@redhat.com> References: <20200522012327.18991-1-liwang@redhat.com> <20200522012327.18991-2-liwang@redhat.com> <20200522012327.18991-3-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 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,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH RFC 4/4] mm: add cpuset01 to runtest file 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test was moved to stress test since commit ae8fa55a8, but stress runtest has been removed from commit e752f7c19674 :). Here adding back it as a general memory test without '-I 3600'. Signed-off-by: Li Wang --- runtest/mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtest/mm b/runtest/mm index a09f39c1e..612a4d066 100644 --- a/runtest/mm +++ b/runtest/mm @@ -73,6 +73,8 @@ ksm06 ksm06 ksm06_1 ksm06 -n 10 ksm06_2 ksm06 -n 10000 +cpuset01 cpuset01 + oom01 oom01 oom02 oom02 oom03 oom03