public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Caspar Zhang <caspar@casparzhang.com>
To: Zhouping Liu <zliu@redhat.com>
Cc: LTP List <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
Date: Fri, 15 Mar 2013 11:09:33 +0800	[thread overview]
Message-ID: <514290ED.2090300@casparzhang.com> (raw)
In-Reply-To: <1af53e534fc05433ed20488c27d35bbc519af730.1363246555.git.zliu@redhat.com>

On 03/15/2013 12:21 AM, Zhouping Liu wrote:
>
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index 29de64a..a71bc90 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -64,32 +64,17 @@ void oom(int testcase, int mempolicy, int lite)

you've moved all mempolicy check stuff to testoom(), so you can 
completely remove this variable.

>   {
>   	pid_t pid;
>   	int status;
> -#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
> -	&& HAVE_MPOL_CONSTANTS
> -	unsigned long nmask = 0;
> -	unsigned int node;
> -
> -	if (mempolicy)
> -		node = get_a_numa_node(cleanup);
> -	nmask += 1 << node;
> -#endif
>
>   	switch (pid = fork()) {
>   	case -1:
>   		tst_brkm(TBROK | TERRNO, cleanup, "fork");
>   	case 0:
> -#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
> -	&& HAVE_MPOL_CONSTANTS
> -		if (mempolicy)
> -			if (set_mempolicy(MPOL_BIND, &nmask, MAXNODES) == -1)
> -				tst_brkm(TBROK | TERRNO, cleanup,
> -					 "set_mempolicy");
> -#endif
>   		_test_alloc(testcase, lite);
>   		exit(0);
>   	default:
>   		break;
>   	}
> +
>   	tst_resm(TINFO, "expected victim is %d.", pid);
>   	if (waitpid(-1, &status, 0) == -1)
>   		tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
> @@ -107,7 +92,44 @@ void oom(int testcase, int mempolicy, int lite)
>
>   void testoom(int mempolicy, int lite, int numa)
>   {
> -	long nodes[MAXNODES];
> +#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \
> +	&& HAVE_MPOL_CONSTANTS
> +	unsigned long nmask = 0;
> +	unsigned int num_nodes, nodes[MAXNODES];
> +	int ret;
> +
> +	if (mempolicy) {
> +		ret = get_allowed_nodes_arr(NH_MEMS|NH_CPUS, &num_nodes, &nodes);
> +		if (ret != 0)
> +			tst_brkm(TBROK|TERRNO, cleanup,
> +				 "get_allowed_nodes_arr");
> +		if (num_nodes < 2) {
> +			tst_resm(TINFO, "mempolicy need NUMA system support");
> +			return;
> +		}
> +		switch(mempolicy) {
> +		case MPOL_BIND:
> +			/* bind the second node */
> +			nmask = 1 << nodes[1];
> +			break;
> +		case MPOL_INTERLEAVE:
> +		case MPOL_PREFERRED:
> +			if (num_nodes == 2) {
> +				tst_resm(TINFO, "The mempolicy need "
> +					 "more than 2 numa nodes");
> +				return;
> +			} else {
> +				/* Using the 2nd,3rd node */
> +				nmask = (1 << nodes[1]) | (1 << nodes[2]);
> +			}
> +			break;
> +		default:
> +			tst_brkm(TBROK|TERRNO, cleanup, "Bad mempolicy mode");
> +		}
> +		if (set_mempolicy(mempolicy, &nmask, MAXNODES) == -1)
> +			tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy");
> +	}
> +#endif
>
>   	if (numa && !mempolicy)
>   		write_cpusets(get_a_numa_node(cleanup));
>

The remaining concern to me is that, mempolicy set in parent process, 
can it be inherited by child? I see this patch changed the behavior that 
in new test, set_mempolicy happen in parent and oom happen in child.

Caspar

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2013-03-15  3:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 16:21 [LTP] [PATCH 0/5] mm/oom: extend the coverage of OOM Zhouping Liu
2013-03-14 16:21 ` [LTP] [PATCH 1/5] lib/mem: modified _gather_cpus() as _gather_node_cpus() Zhouping Liu
2013-03-14 16:45   ` chrubis
2013-03-14 16:21 ` [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy' Zhouping Liu
2013-03-15  3:09   ` Caspar Zhang [this message]
2013-03-15  3:57     ` Zhouping Liu
2013-03-15  4:33       ` Caspar Zhang
2013-03-14 16:21 ` [LTP] [PATCH 3/5] mm/oom0[3|4]: added 'OOM for CPUSET' and updated 'OOM with MEMCG & numa' Zhouping Liu
2013-03-14 16:51   ` chrubis
     [not found]     ` <507561236.18941341.1363282016883.JavaMail.root@redhat.com>
2013-03-14 18:32       ` chrubis
2013-03-14 16:21 ` [LTP] [PATCH 4/5] lib/mem: updated testoom() and oom() funcs Zhouping Liu
2013-03-14 16:21 ` [LTP] [PATCH 5/5] mm/oom05: new testcase Zhouping Liu

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=514290ED.2090300@casparzhang.com \
    --to=caspar@casparzhang.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=zliu@redhat.com \
    /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