public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH V5] syscall: Add io_uring related tests
Date: Tue, 26 May 2020 10:48:37 +0200	[thread overview]
Message-ID: <20200526084837.GA10775@dell5510> (raw)
In-Reply-To: <20200526063555.25006-1-vikas.kumar2@arm.com>

Hi Vikas,

not a complete review, just a few notes.

...
> +/*
> + * Check whether the ioring related system calls are supported on
> + * the current kernel. These system calls are enabled by default
> + * on kernel version 5.1.0 or higher. But they also might have
> + * been backported as well.
> + */
IMHO the function name is obvious, so please shorten the comment :).
> +void io_uring_setup_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 1, 0)) < 0) {
> +		TEST(syscall(__NR_io_uring_setup, NULL, 0));
> +		if (TST_RET != -1)
> +			SAFE_CLOSE(TST_RET);
> +		else if (TST_ERR == ENOSYS)
> +			tst_brk(TCONF,
> +				"Test not supported on kernel version < v5.1");
> +	}
> +}
> +
> +void io_uring_register_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 1, 0)) < 0) {
> +		TEST(syscall(__NR_io_uring_register, NULL, 0));
> +		if (TST_RET != -1)
> +			SAFE_CLOSE(TST_RET);
> +		else if (TST_ERR == ENOSYS)
> +			tst_brk(TCONF,
> +				"Test not supported on kernel version < v5.1");
> +	}
> +}
> +
> +void io_uring_enter_supported_by_kernel(void)
> +{
> +	if ((tst_kvercmp(5, 1, 0)) < 0) {
> +		TEST(syscall(__NR_io_uring_enter, NULL, 0));
> +		if (TST_RET != -1)
> +			SAFE_CLOSE(TST_RET);
> +		else if (TST_ERR == ENOSYS)
> +			tst_brk(TCONF,
> +				"Test not supported on kernel version < v5.1");
> +	}
> +}
IMHO It's unlikely that somebody would backport just some syscalls, not all 3.
I'd be just for testing io_uring_setup().
Then no setup function is needed (use .setup =
io_uring_setup_supported_by_kernel in struct tst_test).

And according to man pages only io_uring_setup() returns a file descriptor. The
other two takes it as a parameter, so SAFE_CLOSE(TST_RET) is wrong.
https://www.mankier.com/2/io_uring_setup
https://www.mankier.com/2/io_uring_register
https://www.mankier.com/2/io_uring_enter
> +
> +static void run(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +	int ret = 0;
> +
> +	s = SAFE_MALLOC(sizeof(*s));
> +	if (!s)
> +		return;
All SAFE_* macros (and safe_* functions which use them) are here to avoid these
checks in the code. They exit executing via tst_brk(TCONF, "..."), therefore use
just
s = SAFE_MALLOC(sizeof(*s));
(drop the check).

> +
> +	memset(s, 0, sizeof(*s));
> +	ret = setup_io_uring_test(s, tc);
> +	if (ret)
> +		tst_res(TFAIL | TTERRNO, "io_uring_setup error");
> +
> +	ret = submit_to_uring_sq(s, tc);
> +	if (ret)
> +		tst_res(TFAIL | TTERRNO, "io_uring_submit error");
> +	else
> +		tst_res(TPASS, "functionality of io_uring API is correct");

nit: we prefer return in if instead of else:

if (submit_to_uring_sq(s, tc)) {
	tst_res(TFAIL | TTERRNO, "io_uring_submit error");
	return;
}

tst_res(TPASS, "functionality of io_uring API is correct");

Kind regards,
Petr

      reply	other threads:[~2020-05-26  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26  6:35 [LTP] [PATCH V5] syscall: Add io_uring related tests Vikas Kumar
2020-05-26  8:48 ` Petr Vorel [this message]

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=20200526084837.GA10775@dell5510 \
    --to=pvorel@suse.cz \
    --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