public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3] controllers/memcg_test_3: Add new regression test
Date: Wed, 14 Jun 2017 14:10:49 +0800	[thread overview]
Message-ID: <5940D369.3040203@cn.fujitsu.com> (raw)
In-Reply-To: <1496654625-14821-1-git-send-email-fenggw-fnst@cn.fujitsu.com>

Hi!

I just remembered that if we only check for memcg support, we should use the min_kver in tst_test struct instead of tst_kvercmp(), sorry, please ignore this one, I will send a v4.

Best Regards,
Guangwen Feng

On 06/05/2017 05:23 PM, Guangwen Feng wrote:
> This kernel bug is about RHEL6 BZ1168185 and has been fixed in:
> 
> [PATCH RHEL6] [mm] memcg: fix crash in re-entrant cgroup_clear_css_refs()
> 
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=1168185
> Patch: ftp://partners.redhat.com/1c5d859a/de6aafa8185ed8fd934f2debc72b79eb/kernel-individual-patch/rhel6/v2.6.32-to-kernel-2.6.32-536.el6.tar.bz2
>        35944-mm-memcg-fix-crash-in-re-entrant-cgroup_clear_css_r.patch
> 
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> ---
>  runtest/controllers                                |   1 +
>  testcases/kernel/controllers/memcg/.gitignore      |   1 +
>  .../controllers/memcg/regression/memcg_test_3.c    | 117 +++++++++++++++++++++
>  3 files changed, 119 insertions(+)
>  create mode 100644 testcases/kernel/controllers/memcg/regression/memcg_test_3.c
> 
> diff --git a/runtest/controllers b/runtest/controllers
> index b904e05..2c43d0b 100644
> --- a/runtest/controllers
> +++ b/runtest/controllers
> @@ -1,6 +1,7 @@
>  #DESCRIPTION:Resource Management testing
>  cgroup		cgroup_regression_test.sh
>  memcg_regression	memcg_regression_test.sh
> +memcg_test_3	memcg_test_3
>  memcg_failcnt memcg_failcnt.sh
>  memcg_force_empty memcg_force_empty.sh
>  memcg_limit_in_bytes memcg_limit_in_bytes.sh
> diff --git a/testcases/kernel/controllers/memcg/.gitignore b/testcases/kernel/controllers/memcg/.gitignore
> index 8730251..c0b6d07 100644
> --- a/testcases/kernel/controllers/memcg/.gitignore
> +++ b/testcases/kernel/controllers/memcg/.gitignore
> @@ -2,5 +2,6 @@
>  /functional/memcg_process
>  /regression/memcg_test_1
>  /regression/memcg_test_2
> +/regression/memcg_test_3
>  /regression/memcg_test_4
>  /stress/memcg_process_stress
> diff --git a/testcases/kernel/controllers/memcg/regression/memcg_test_3.c b/testcases/kernel/controllers/memcg/regression/memcg_test_3.c
> new file mode 100644
> index 0000000..c698c12
> --- /dev/null
> +++ b/testcases/kernel/controllers/memcg/regression/memcg_test_3.c
> @@ -0,0 +1,117 @@
> +/*
> + * Copyright (c) 2017 Fujitsu Ltd.
> + *  Author: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program, if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +/*
> + * This is a regression test for a crash caused by memcg function
> + * reentrant on RHEL6.  When doing rmdir(), a pending signal can
> + * interrupt the execution and lead to cgroup_clear_css_refs()
> + * being entered repeatedly, this results in a BUG_ON().
> + *
> + * This bug was introduced by following RHEL6 patch on 2.6.32-488.el6:
> + *
> + *  [mm] memcg: fix race condition between memcg teardown and swapin
> + *  Link: https://bugzilla.redhat.com/show_bug.cgi?id=1001197
> + *  Patch: ftp://partners.redhat.com/1c5d859a/de6aafa8185ed8fd934f2debc72b79eb/kernel-individual-patch/rhel6/v2.6.32-to-kernel-2.6.32-488.el6.tar.bz2
> + *         31675-mm-memcg-fix-race-condition-between-memcg-teardown-.patch
> + *
> + * This test can crash the buggy kernel on RHEL6.6GA, and the bug
> + * was fixed by following patch on 2.6.32-536.el6:
> + *
> + *  [mm] memcg: fix crash in re-entrant cgroup_clear_css_refs()
> + *  Link: https://bugzilla.redhat.com/show_bug.cgi?id=1168185
> + *  Patch: ftp://partners.redhat.com/1c5d859a/de6aafa8185ed8fd934f2debc72b79eb/kernel-individual-patch/rhel6/v2.6.32-to-kernel-2.6.32-536.el6.tar.bz2
> + *         35944-mm-memcg-fix-crash-in-re-entrant-cgroup_clear_css_r.patch
> + */
> +
> +#include <errno.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <sys/types.h>
> +#include "tst_test.h"
> +
> +#define MNTPOINT	"memcg"
> +#define SUBDIR	"memcg/testdir"
> +
> +static int mount_flag;
> +static volatile int sigcounter;
> +
> +static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
> +{
> +	sigcounter++;
> +}
> +
> +static void do_child(void)
> +{
> +	while (1)
> +		SAFE_KILL(getppid(), SIGUSR1);
> +
> +	exit(0);
> +}
> +
> +static void do_test(void)
> +{
> +	pid_t cpid = -1;
> +
> +	SAFE_SIGNAL(SIGUSR1, sighandler);
> +
> +	cpid = SAFE_FORK();
> +	if (cpid == 0)
> +		do_child();
> +
> +	while (sigcounter < 50000) {
> +		if (access(SUBDIR, F_OK))
> +			SAFE_MKDIR(SUBDIR, 0644);
> +		rmdir(SUBDIR);
> +	}
> +
> +	SAFE_KILL(cpid, SIGKILL);
> +	SAFE_WAIT(NULL);
> +
> +	tst_res(TPASS, "Bug not reproduced");
> +}
> +
> +static void setup(void)
> +{
> +	if (tst_kvercmp(2, 6, 24) < 0)
> +		tst_brk(TCONF, "This test can only run on kernels "
> +			"that are 2.6.24 or higher");
> +
> +	SAFE_MKDIR(MNTPOINT, 0644);
> +
> +	SAFE_MOUNT("memcg", MNTPOINT, "cgroup", 0, "memory");
> +	mount_flag = 1;
> +}
> +
> +static void cleanup(void)
> +{
> +	if (!access(SUBDIR, F_OK))
> +		SAFE_RMDIR(SUBDIR);
> +
> +	if (mount_flag)
> +		tst_umount(MNTPOINT);
> +}
> +
> +static struct tst_test test = {
> +	.tid = "memcg_test_3",
> +	.needs_root = 1,
> +	.needs_tmpdir = 1,
> +	.forks_child = 1,
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.test_all = do_test,
> +};
> 



  reply	other threads:[~2017-06-14  6:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 10:05 [LTP] [PATCH 1/2] SAFE_MACROS: Add SAFE_UNAME() Guangwen Feng
2017-05-09 10:05 ` [LTP] [PATCH 2/2] controllers/memcg_test_3: Add new regression test Guangwen Feng
2017-05-09 11:15   ` Guangwen Feng
2017-05-09 11:21     ` [LTP] [PATCH v2 " Guangwen Feng
2017-05-30 13:02       ` Cyril Hrubis
2017-06-05  9:20         ` Guangwen Feng
2017-06-05  9:23           ` [LTP] [PATCH v3] " Guangwen Feng
2017-06-14  6:10             ` Guangwen Feng [this message]
2017-06-14  6:12               ` [LTP] [PATCH v4] " Guangwen Feng
2017-06-21 10:44                 ` Guangwen Feng
2017-06-22  9:27                 ` Cyril Hrubis
2017-06-22  9:43                   ` Guangwen Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5940D369.3040203@cn.fujitsu.com \
    --to=fenggw-fnst@cn.fujitsu.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox