public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Zhouping Liu <zliu@redhat.com>
To: Caspar Zhang <caspar@casparzhang.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: Thu, 14 Mar 2013 23:57:04 -0400 (EDT)	[thread overview]
Message-ID: <2046829337.8696311.1363319824336.JavaMail.root@redhat.com> (raw)
In-Reply-To: <514290ED.2090300@casparzhang.com>



----- Original Message -----
> From: "Caspar Zhang" <caspar@casparzhang.com>
> To: "Zhouping Liu" <zliu@redhat.com>
> Cc: "LTP List" <ltp-list@lists.sourceforge.net>
> Sent: Friday, March 15, 2013 11:09:33 AM
> Subject: Re: [LTP] [PATCH 2/5] mm/oom02: modified 'OOM for NUMA' as 'OOM for mempolicy'
> 
> 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.

I'm not sure which variable you mean, pid and status variable? but they are needed.

> 
> >   {
> >   	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.

The following words from the manual page can tell us the child inherit the father's mempolicy:

SET_MEMPOLICY(2)
...
The process memory policy is preserved across an execve(2), and is inherited by child processes created using fork(2) or clone(2).
...

-- 
Thanks,
Zhouping

------------------------------------------------------------------------------
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:57 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
2013-03-15  3:57     ` Zhouping Liu [this message]
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=2046829337.8696311.1363319824336.JavaMail.root@redhat.com \
    --to=zliu@redhat.com \
    --cc=caspar@casparzhang.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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