From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 3/4] syscalls/mlock201: Add new testcase
Date: Thu, 30 Aug 2018 08:41:22 -0400 (EDT) [thread overview]
Message-ID: <176741503.43672692.1535632882334.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1535699602-28185-1-git-send-email-yangx.jy@cn.fujitsu.com>
----- Original Message -----
> 1) Add SAFE_MINCORE() macro
> 2) Check the basic functionality of mlock2(2).
>
> Note:
> 1) We use tst_syscall() to check if mlock2() is supported.
> 2) since kernel v2.6.9, the limits and permissions of mlock2()
> changed, so we just check mlock2() since the version.
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Looks good to me, some nits below (no need to re-post)
> +#include <errno.h>
> +#include <unistd.h>
> +#include <string.h>
> +#include <stdlib.h>
> +#include <sys/mman.h>
> +#include <linux/mman.h>
> +
> +#include "tst_test.h"
> +#include "lapi/syscalls.h"
> +#include "lapi/mlock2.h"
> +
> +#define PAGES 8
> +#define HPAGES (PAGES / 2)
> +
> +static size_t pgsz;
> +static unsigned char *vec;
> +
> +static struct tcase {
> + size_t pop_pgs;
> + size_t lock_pgs;
> + size_t offset;
> + size_t exp_vmlcks;
> + size_t exp_pgs;
Some of these could be more descriptive or have comments.
<snip>
> +static void setup(void)
> +{
> + pgsz = getpagesize();
> + vec = SAFE_MALLOC((PAGES * pgsz + pgsz - 1) / pgsz);
This value is known at compile time, so malloc isn't needed.
> +}
> +
> +static void cleanup(void)
> +{
> + if (vec)
> + free(vec);
> +}
> +
> +static struct tst_test test = {
> + .tcnt = ARRAY_SIZE(tcases),
> + .test = verify_mlock2,
> + .setup = setup,
> + .cleanup = cleanup,
> + .needs_root = 1,
> + .min_kver = "2.6.9",
Ok, "syscall can be backported to older kernels" is valid argument.
Thanks,
Jan
next prev parent reply other threads:[~2018-08-30 12:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 9:38 [LTP] [PATCH 1/4] lapi/syscalls: Add syscall numbers for mlock2 Xiao Yang
2018-08-21 9:38 ` [LTP] [PATCH 2/4] safe_macros: Add SAFE_MLOCK() and SAFE_MUNLOCK() macros Xiao Yang
2018-08-29 12:11 ` Jan Stancek
2018-08-21 9:38 ` [LTP] [PATCH 3/4] syscalls/mlock201: Add new testcase Xiao Yang
2018-08-29 12:19 ` Jan Stancek
2018-08-29 12:42 ` Jan Stancek
2018-08-30 1:17 ` Xiao Yang
2018-08-31 7:13 ` [LTP] [PATCH v2 " Xiao Yang
2018-08-30 12:41 ` Jan Stancek [this message]
2018-08-31 7:13 ` [LTP] [PATCH v2 4/4] syscalls/mlock202: " Xiao Yang
2018-08-30 12:43 ` Jan Stancek
2018-09-04 8:10 ` Jan Stancek
2018-08-21 9:38 ` [LTP] [PATCH " Xiao Yang
2018-08-29 12:44 ` Jan Stancek
2018-08-30 7:41 ` Xiao Yang
2018-08-29 12:11 ` [LTP] [PATCH 1/4] lapi/syscalls: Add syscall numbers for mlock2 Jan Stancek
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=176741503.43672692.1535632882334.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.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