Skip to contentSkip to conversation

Add Syscall numbers for io_pgetevents

PATCH Superseded Viresh Kumar 3 participants 7 messages Jan 23, 2020 – Jan 24, 2020

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add Syscall numbers for io_pgetevents

---
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 12 files changed, 12 insertions(+)
include/lapi/syscalls/aarch64.in +1 -0
index 19f3aa4475bd..25e1b27e9867 100644
@@ -269,6 +269,7 @@ pwritev2 287
 pkey_mprotect 288
 pkey_alloc 289
 pkey_free 290
+io_pgetevents 292
 pidfd_send_signal 424
 pidfd_open 434
 _sysctl 1078
include/lapi/syscalls/arm.in +1 -0
index 29538ba50d3b..49be125a755c 100644
@@ -353,5 +353,6 @@ pkey_mprotect (__NR_SYSCALL_BASE+394)
 pkey_alloc (__NR_SYSCALL_BASE+395)
 pkey_free (__NR_SYSCALL_BASE+396)
 statx (__NR_SYSCALL_BASE+397)
+io_pgetevents (__NR_SYSCALL_BASE+399)
 pidfd_send_signal (__NR_SYSCALL_BASE+424)
 pidfd_open (__NR_SYSCALL_BASE+434)
include/lapi/syscalls/hppa.in +1 -0
index b578d886516d..b11c8fbcf71f 100644
@@ -25,5 +25,6 @@ mlock2 345
 copy_file_range 346
 preadv2 347
 pwritev2 348
+io_pgetevents 350
 pidfd_send_signal 424
 pidfd_open 434
include/lapi/syscalls/i386.in +1 -0
index 696563ebba48..40b84ca89f9b 100644
@@ -352,5 +352,6 @@ pkey_mprotect 380
 pkey_alloc 381
 pkey_free 382
 statx 383
+io_pgetevents 385
 pidfd_send_signal 424
 pidfd_open 434
include/lapi/syscalls/ia64.in +1 -0
index 11b236c7c507..675adda18703 100644
@@ -305,6 +305,7 @@ mlock2 1346
 copy_file_range 1347
 preadv2 1348
 pwritev2 1349
+io_pgetevents 1351
 pkey_mprotect 1354
 pkey_alloc 1355
 pkey_free 1356
include/lapi/syscalls/powerpc.in +1 -0
index 293d86ba54c4..88c42924b306 100644
@@ -355,6 +355,7 @@ copy_file_range 379
 preadv2 380
 pwritev2 381
 statx 383
+io_pgetevents 388
 pidfd_send_signal 424
 pidfd_open 434
 pkey_mprotect 386
include/lapi/syscalls/powerpc64.in +1 -0
index 293d86ba54c4..88c42924b306 100644
@@ -355,6 +355,7 @@ copy_file_range 379
 preadv2 380
 pwritev2 381
 statx 383
+io_pgetevents 388
 pidfd_send_signal 424
 pidfd_open 434
 pkey_mprotect 386
include/lapi/syscalls/s390.in +1 -0
index 4f4b2dbed5ef..dbeaea70f59c 100644
@@ -339,6 +339,7 @@ mlock2 374
 copy_file_range 375
 preadv2 376
 pwritev2 377
+io_pgetevents 382
 pkey_mprotect 384
 pkey_alloc 385
 pkey_free 386
include/lapi/syscalls/s390x.in +1 -0
index 673538a7217e..6bacacba1468 100644
@@ -337,6 +337,7 @@ mlock2 374
 copy_file_range 375
 preadv2 376
 pwritev2 377
+io_pgetevents 382
 pkey_mprotect 384
 pkey_alloc 385
 pkey_free 386
include/lapi/syscalls/sparc.in +1 -0
index 2b33c4983088..b5f269222f8b 100644
@@ -344,6 +344,7 @@ mlock2 356
 copy_file_range 357
 preadv2 358
 pwritev2 359
+io_pgetevents 361
 pkey_mprotect 362
 pkey_alloc 363
 pkey_free 364
include/lapi/syscalls/sparc64.in +1 -0
index a6157adef7b3..ea191d4745e1 100644
@@ -319,6 +319,7 @@ mlock2 356
 copy_file_range 357
 preadv2 358
 pwritev2 359
+io_pgetevents 361
 pkey_mprotect 362
 pkey_alloc 363
 pkey_free 364
include/lapi/syscalls/x86_64.in +1 -0
index 8bd6b66d3bef..d9370b9032d1 100644
@@ -319,5 +319,6 @@ pkey_mprotect 329
 pkey_alloc 330
 pkey_free 331
 statx 332
+io_pgetevents 333
 pidfd_send_signal 424
 pidfd_open 434
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#1 lore raw

PATCH 1/2 Add Syscall numbers for io_pgetevents

Cyril,

Quoted 15 lines · Viresh Kumar
---
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 12 files changed, 12 insertions(+)

Is it fine to send patches like this separately from the patches which actually add the tests? Will you merge them alone as well?

Asking as I would be required to resend these patches (which just add syscall number) along with the real tests, while they may never get modified. I can then send such patches for future syscalls I am working on.

Signature · 1 line
viresh
#2 lore raw

PATCH 1/2 Add Syscall numbers for io_pgetevents

Hi!

Quoted 14 lines
Quoted 5 lines
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
Quoted 8 lines
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 12 files changed, 12 insertions(+)
Quoted 7 lines

Is it fine to send patches like this separately from the patches which actually add the tests? Will you merge them alone as well?

Asking as I would be required to resend these patches (which just add syscall number) along with the real tests, while they may never get modified. I can then send such patches for future syscalls I am working on.

We may as well add all the missing syscalls in a single patch and I will commit that right away if you are okay with that.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/2 Add Syscall numbers for io_pgetevents

Quoted 18 lines · Cyril Hrubis

Hi!

Quoted 17 lines
Quoted 5 lines
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
Quoted 8 lines
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 12 files changed, 12 insertions(+)

Is it fine to send patches like this separately from the patches which actually add the tests? Will you merge them alone as well?

Quoted 7 lines
Quoted 4 lines

Asking as I would be required to resend these patches (which just add syscall number) along with the real tests, while they may never get modified. I can then send such patches for future syscalls I am working on.

We may as well add all the missing syscalls in a single patch and I will commit that right away if you are okay with that.

Sure. I will still send my patches as is for now (as they are on the way), and you can just drop the first one which adds the syscall.

Signature · 1 line
viresh
#4 lore raw

PATCH 2/2 syscalls/io_pgetevents

In reply to Viresh Kumar

Add tests to check working of io_pgetevents() syscall.

---
 configure.ac                                  |  1 +
 include/lapi/io_pgetevents.h                  | 49 +++++++++++
 runtest/syscalls                              |  4 +
 .../kernel/syscalls/io_pgetevents/.gitignore  |  2 +
 .../kernel/syscalls/io_pgetevents/Makefile    |  6 ++
 .../syscalls/io_pgetevents/io_pgetevents01.c  | 73 +++++++++++++++++
 .../syscalls/io_pgetevents/io_pgetevents02.c  | 81 +++++++++++++++++++
 7 files changed, 216 insertions(+)
 create mode 100644 include/lapi/io_pgetevents.h
 create mode 100644 testcases/kernel/syscalls/io_pgetevents/.gitignore
 create mode 100644 testcases/kernel/syscalls/io_pgetevents/Makefile
 create mode 100644 testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c
 create mode 100644 testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c
configure.ac +1 -0
index 1bf0911d88ad..c7cdff1c422c 100644
@@ -75,6 +75,7 @@ AC_CHECK_FUNCS([ \
     getdents \
     getdents64 \
     kcmp \
+    io_pgetevents \
     mkdirat \
     mknodat \
     name_to_handle_at \
include/lapi/io_pgetevents.h new file +49 -0

49 lines not on this page · raw message

runtest/syscalls +4 -0
index a2d749d526a8..6d167b800ac7 100644
@@ -554,6 +554,10 @@ ioprio_set03 ioprio_set03
 io_cancel01 io_cancel01
 io_destroy01 io_destroy01
 io_getevents01 io_getevents01
+
+io_pgetevents01 io_pgetevents01
+io_pgetevents02 io_pgetevents02
+
 io_setup01 io_setup01
 io_submit01 io_submit01
 
testcases/kernel/syscalls/io_pgetevents/.gitignore new file +2 -0
new file mode 100644
index 000000000000..ae02077ba44b
@@ -0,0 +1,2 @@
+io_pgetevents01
+io_pgetevents02
testcases/kernel/syscalls/io_pgetevents/Makefile new file +6 -0
new file mode 100644
index 000000000000..5ea7d67db123
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c new file +73 -0

73 lines not on this page · raw message

testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
#5 lore raw

PATCH 2/2 syscalls/io_pgetevents

Hi,

----- Original Message -----

Quoted 11 lines
include/lapi/io_pgetevents.h new file +11 -0
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
+#ifndef HAVE_IO_SETUP
+int io_setup(int nr, io_context_t *ctxp)
+{
+	return syscall(__NR_io_setup, nr, ctxp);
+}
+#endif /* HAVE_IO_SETUP */
+
+#ifndef HAVE_IO_DESTROY

include/lapi/io_pgetevents.h line 35

Quoted 10 lines
include/lapi/io_pgetevents.h new file +10 -0
+int io_destroy(io_context_t ctx)
+{
+	return syscall(__NR_io_destroy, ctx);
+}
+#endif /* HAVE_IO_DESTROY */
+
+#ifndef HAVE_IO_SUBMIT
+int io_submit(io_context_t ctx, long nr, struct iocb **iocbpp)
+{
+	return syscall(__NR_io_submit, ctx, nr, iocbpp);

Can functions above also use ltp_syscall?

<snip>

testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c line 24

Quoted 7 lines
testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c new file +7 -0
+#ifdef HAVE_LIBAIO
+
+static int fd = -1;
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd);

I'd move this to run(). It may get skipped on tst_brk(), but kernel will take care of closing it. But if you run testcase in loop (-i) it won't run out of file descriptors.

<snip>

testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c line 24

Quoted 7 lines
testcases/kernel/syscalls/io_pgetevents/io_pgetevents01.c new file +7 -0
+#ifdef HAVE_LIBAIO
+
+static int fd = -1;
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd);

same here

Quoted 33 lines
testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c new file +33 -0
+}
+
+static void run(void)
+{
+	struct io_event events[1];
+	struct iocb cb, *cbs[1];
+	io_context_t ctx = 0;
+	sigset_t sigmask;
+	char data[4096];
+	int ret;
+
+	sigemptyset(&sigmask);
+
+	fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT);
+
+	ret = io_setup(1, &ctx);
+	if (ret < 0)
+		tst_brk(TBROK | TERRNO, "io_setup() failed");
+
+	io_prep_pwrite(&cb, fd, data, 4096, 0);
+
+	cbs[0] = &cb;
+
+	ret = io_submit(ctx, 1, cbs);
+	if (ret != 1)
+		tst_brk(TBROK | TERRNO, "io_submit() failed");
+
+	/* Invalid Max event count */
+	ret = io_pgetevents(ctx, 1, 0, events, NULL, &sigmask);
+
+	/* Invalid events*/
+	if (ret != 1)
+		ret = io_pgetevents(ctx, 1, 1, NULL, NULL, &sigmask);

testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c line 67

Quoted 10 lines
testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c new file +10 -0
+
+	if (io_destroy(ctx) < 0)
+		tst_brk(TBROK | TERRNO, "io_destroy() failed");
+
+	/* Invalid ctx */
+	if (ret != 1)
+		ret = io_pgetevents(ctx, 1, 1, events, NULL, &sigmask);
+
+	if (ret != 1)
+		tst_res(TPASS, "io_pgetevents() failed as expected");

If this reports FAIL, will we know what test actually failed?

Can you make this more verbose? I mean have each test report PASS/FAIL, not just a one line summary after all tests.

testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c line 69

Quoted 2 lines
testcases/kernel/syscalls/io_pgetevents/io_pgetevents02.c new file +2 -0
+	else
+		tst_brk(TBROK| TERRNO, "io_pgetevents() passed unexpectedly");

TFAIL | TERRNO seems more fitting, since io_pgetevents is subject of the test.

Regards,
Jan

#6 lore raw

PATCH 2/2 syscalls/io_pgetevents

Hi!

Quoted 15 lines
Quoted 15 lines
include/lapi/io_pgetevents.h new file +15 -0
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+
+#ifndef HAVE_IO_SETUP
+int io_setup(int nr, io_context_t *ctxp)
+{
+	return syscall(__NR_io_setup, nr, ctxp);
+}
+#endif /* HAVE_IO_SETUP */
+
+#ifndef HAVE_IO_DESTROY
+int io_destroy(io_context_t ctx)
+{
+	return syscall(__NR_io_destroy, ctx);
+}
Quoted 8 lines

include/lapi/io_pgetevents.h line 35

Quoted 6 lines
include/lapi/io_pgetevents.h new file +6 -0
+#endif /* HAVE_IO_DESTROY */
+
+#ifndef HAVE_IO_SUBMIT
+int io_submit(io_context_t ctx, long nr, struct iocb **iocbpp)
+{
+	return syscall(__NR_io_submit, ctx, nr, iocbpp);

Can functions above also use ltp_syscall?

tst_syscall(), ltp_syscall() is old API.

Signature · 2 lines
Cyril Hrubis
[email protected]