public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Dennis Brendel <dbrendel@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] munlockall: add test case that verifies memory has been unlocked
Date: Tue, 5 Mar 2024 22:30:50 +0100	[thread overview]
Message-ID: <20240305213050.GB44833@pevik> (raw)
In-Reply-To: <6dfa210d-1c9a-4888-9408-eccc3068cd2a@redhat.com>

Hi Dennis,

Generally LGTM, thanks!

Reviewed-by: Petr Vorel <pvorel@suse.cz>

you should also add test into .gitignore and to some file in runtest/ (in this
case into runtest/syscalls), if we don't simply replace your test with munlockall01.c
as Cyril suggested (I would also vote for replacing it).

FYI you can have look for what we check:

https://github.com/linux-test-project/ltp/wiki/Maintainer-Patch-Review-Checklist

> Changes to v1:

> - use a docparse comment
> - use tabs for indentation
> - report broken test and exit if any preparation/confirmation fails
>   by using tst_brk(TBROK, ...)
> - fix further violations reported by `make check`

> I did not yet replace munlockall01.c because I am not familiar with
I guess Cyril meant just to replace munlockall01.c with what you wrote.
+1 for this, there is no point to keep original munlockall01.c.
And because you replace, you can delete the original copyright and can use
GPL-2.0-or-later (original test was GPL v2 only).

> that (legacy?) syntax and why uclinux needs special handling.

uclinux is for nommu, we don't support it in new API (and nobody from the
community standup for the support), it can be just deleted.

> ---
>  .../kernel/syscalls/munlockall/munlockall02.c | 51 +++++++++++++++++++
>  1 file changed, 51 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/munlockall/munlockall02.c

> diff --git a/testcases/kernel/syscalls/munlockall/munlockall02.c b/testcases/kernel/syscalls/munlockall/munlockall02.c
> new file mode 100644
> index 000000000..06f781d86
> --- /dev/null
> +++ b/testcases/kernel/syscalls/munlockall/munlockall02.c
> @@ -0,0 +1,51 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright Red Hat
> + * Author: Dennis Brendel <dbrendel@redhat.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Verify that munlockall(2) unlocks all previously locked memory
> + */
> +
> +#include <sys/mman.h>
> +
> +#include "tst_test.h"
> +
> +static void verify_munlockall(void)
> +{
> +	size_t size = 0;
> +
> +	SAFE_FILE_LINES_SCANF("/proc/self/status", "VmLck: %ld", &size);
> +
> +	if (size != 0UL)
> +		tst_brk(TBROK, "Locked memory after init should be 0 but is "
> +			       "%ld", size);
nit: I would not split string (kernel source code also relaxed to 100 chars
instead of 8O).

> +
> +	if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
> +		tst_brk(TBROK, "Could not lock memory using mlockall()");
Maybe use tst_brk(TBROK | TERRNO, to get errno printed?
> +
> +	SAFE_FILE_LINES_SCANF("/proc/self/status", "VmLck: %ld", &size);
> +
> +	if (size == 0UL)
> +		tst_brk(TBROK, "Locked memory after mlockall() should be "
> +			       "greater than 0, but is %ld", size);
I suppose < 0 really means no memory locked, thus really safe to quit before
munlockall(), right?
> +
> +	if (munlockall() != 0)
> +		tst_brk(TBROK, "Could not unlock memory using munlockall()");
Also here use TBROK | TERRNO ?
> +
> +	SAFE_FILE_LINES_SCANF("/proc/self/status", "VmLck: %ld", &size);
> +
> +	if (size != 0UL) {
> +		tst_res(TFAIL, "Locked memory after munlockall() should be 0 "
> +			       "but is %ld", size);
nit: also here I would join string to single line (still below 100 chars).
> +	} else {
> +		tst_res(TPASS, "Test passed");
nit maybe:
		tst_res(TPASS, "Memory successfully locked and unlocked");

Kind regards,
Petr

> +	}
> +}
> +
> +static struct tst_test test = {
> +	.test_all = verify_munlockall,
> +};

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2024-03-05 21:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 17:26 [LTP] [PATCH v2] munlockall: add test case that verifies memory has been unlocked Dennis Brendel
2024-03-05 21:30 ` Petr Vorel [this message]
2024-03-06  8:49   ` Dennis Brendel
2024-03-06  9:00   ` Dennis Brendel
2024-03-06 10:07     ` Petr Vorel

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=20240305213050.GB44833@pevik \
    --to=pvorel@suse.cz \
    --cc=dbrendel@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