From: chrubis@suse.cz
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] mem/oom: check for multiple outcomes if overcommit_memory is 0 or 1
Date: Tue, 29 Jul 2014 10:43:06 +0200 [thread overview]
Message-ID: <20140729084306.GA15240@rei> (raw)
In-Reply-To: <24aca741786196af9ca38705970289a66b12ab9b.1406622527.git.jstancek@redhat.com>
Hi!
> +/* oom/testoom outcomes */
> +#define EXIT_FLAG 0x100
> +#define SIGNAL_FLAG 0x200
> +#define OUTCOME_MASK 0xff
> +#define EXITED(n) (EXIT_FLAG + (n & OUTCOME_MASK))
> +#define SIGNALLED(n) (SIGNAL_FLAG + (n & OUTCOME_MASK))
> +
> +extern int EXITED_ENOMEM[];
> +extern int ENOMEM_OR_SIGKILL[];
This machinery looks a bit too generic to me. IMHO simple bit flag for
oom() that would allow/disallow the child being killed as a PASS result
would suffice.
Or do you expect that we will need (many) more possible cases to add?
> long overcommit;
> -void oom(int testcase, int lite);
> -void testoom(int mempolicy, int lite);
> +void oom(int testcase, int lite, int outcome[]);
> +void testoom(int mempolicy, int lite, int outcome[]);
>
> /* KSM */
>
> diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c
> index c7910db..f207c58 100644
> --- a/testcases/kernel/mem/lib/mem.c
> +++ b/testcases/kernel/mem/lib/mem.c
> @@ -25,52 +25,73 @@
> #include "numa_helper.h"
>
> /* OOM */
> +int EXITED_ENOMEM[] = { EXITED(ENOMEM), 0 };
> +int ENOMEM_OR_SIGKILL[] = { EXITED(ENOMEM), SIGNALLED(SIGKILL), 0 };
>
> static int alloc_mem(long int length, int testcase)
> {
> - void *s;
> + char *s;
> + long i;
> + int pagesz = getpagesize();
>
> tst_resm(TINFO, "allocating %ld bytes.", length);
> +
> s = mmap(NULL, length, PROT_READ | PROT_WRITE,
> MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
> - if (s == MAP_FAILED) {
> - if (testcase == OVERCOMMIT && errno == ENOMEM)
> - return 1;
> - else
> - tst_brkm(TBROK | TERRNO, cleanup, "mmap");
> - }
> + if (s == MAP_FAILED)
> + return errno;
> +
> if (testcase == MLOCK && mlock(s, length) == -1)
> - tst_brkm(TBROK | TERRNO, cleanup, "mlock");
> + return errno;
> #ifdef HAVE_MADV_MERGEABLE
> if (testcase == KSM && madvise(s, length, MADV_MERGEABLE) == -1)
> - tst_brkm(TBROK | TERRNO, cleanup, "madvise");
> + return errno;
> #endif
> - memset(s, '\a', length);
> + for (i = 0; i < length; i += pagesz)
> + s[i] = '\a';
This is good optimalization but should be either mentioned in the commit
message or ideally commited separately.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2014-07-29 8:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 8:31 [LTP] [PATCH] mem/oom: check for multiple outcomes if overcommit_memory is 0 or 1 Jan Stancek
2014-07-29 8:43 ` chrubis [this message]
[not found] ` <1706184967.16286722.1406624646852.JavaMail.zimbra@redhat.com>
2014-07-29 10:10 ` chrubis
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=20140729084306.GA15240@rei \
--to=chrubis@suse.cz \
--cc=jstancek@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.