All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing v1 0/5] Remove useless brances in register functions
@ 2022-11-23 12:53 Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 1/5] register: Remove useless branches in {un,}register eventfd Ammar Faizi
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Hi Jens,

This series removes useless branches in register functions:
  - io_uring_register_eventfd()
  - io_uring_unregister_eventfd()
  - io_uring_register_eventfd_async()
  - io_uring_register_buffers()
  - io_uring_unregister_buffers()
  - io_uring_unregister_files()
  - io_uring_register_probe()
  - io_uring_register_restrictions()

There are 5 patches in this series.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---

Ammar Faizi (5):
  register: Remove useless branches in {un,}register eventfd
  register: Remove useless branches in {un,}register buffers
  register: Remove useless branch in unregister files
  register: Remove useless branch in register probe
  register: Remove useless branch in register restrictions

 src/register.c | 60 +++++++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 42 deletions(-)


base-commit: 8fc22e3b3348c0a6384ec926e0b19b6707622e58
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH liburing v1 1/5] register: Remove useless branches in {un,}register eventfd
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
@ 2022-11-23 12:53 ` Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 2/5] register: Remove useless branches in {un,}register buffers Ammar Faizi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

IORING_{UN,}REGISTER_EVENTFD and IORING_REGISTER_EVENTFD_ASYNC don't
return a positive value. These branches are useless. Remove them.

[1]: io_eventfd_register
[2]: io_eventfd_unregister

Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/io_uring.c#L2511-L2547 [1]
Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/io_uring.c#L2549-L2564 [2]
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/register.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/register.c b/src/register.c
index e849825..6cd607e 100644
--- a/src/register.c
+++ b/src/register.c
@@ -208,30 +208,21 @@ int io_uring_unregister_files(struct io_uring *ring)
 
 int io_uring_register_eventfd(struct io_uring *ring, int event_fd)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_EVENTFD,
-				      &event_fd, 1);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_EVENTFD,
+				       &event_fd, 1);
 }
 
 int io_uring_unregister_eventfd(struct io_uring *ring)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_EVENTFD,
-				      NULL, 0);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_EVENTFD,
+				       NULL, 0);
 }
 
 int io_uring_register_eventfd_async(struct io_uring *ring, int event_fd)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd,
-				      IORING_REGISTER_EVENTFD_ASYNC, &event_fd,
-				      1);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd,
+				       IORING_REGISTER_EVENTFD_ASYNC, &event_fd,
+				       1);
 }
 
 int io_uring_register_probe(struct io_uring *ring, struct io_uring_probe *p,
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing v1 2/5] register: Remove useless branches in {un,}register buffers
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 1/5] register: Remove useless branches in {un,}register eventfd Ammar Faizi
@ 2022-11-23 12:53 ` Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 3/5] register: Remove useless branch in unregister files Ammar Faizi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

IORING_REGISTER_BUFFERS and IORING_UNREGISTER_BUFFERS don't return a
positive value. These bracnes are useless. Remove them.

[1]: io_sqe_buffers_register
[2]: io_sqe_buffers_unregister

Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/rsrc.c#L1250-L1307 [1]
Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/rsrc.c#L1036-L1054 [2]
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/register.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/register.c b/src/register.c
index 6cd607e..adb64cc 100644
--- a/src/register.c
+++ b/src/register.c
@@ -54,20 +54,14 @@ int io_uring_register_buffers_sparse(struct io_uring *ring, unsigned nr)
 int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs,
 			      unsigned nr_iovecs)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_BUFFERS,
-				      iovecs, nr_iovecs);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_BUFFERS,
+				       iovecs, nr_iovecs);
 }
 
 int io_uring_unregister_buffers(struct io_uring *ring)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_BUFFERS,
-				      NULL, 0);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_BUFFERS,
+				       NULL, 0);
 }
 
 int io_uring_register_files_update_tag(struct io_uring *ring, unsigned off,
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing v1 3/5] register: Remove useless branch in unregister files
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 1/5] register: Remove useless branches in {un,}register eventfd Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 2/5] register: Remove useless branches in {un,}register buffers Ammar Faizi
@ 2022-11-23 12:53 ` Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 4/5] register: Remove useless branch in register probe Ammar Faizi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

IORING_UNREGISTER_FILES doesn't return a positive value. This branch
is useless. Remove it.

[1]: io_sqe_files_unregister

Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/rsrc.c#L787-L805 [1]
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/register.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/register.c b/src/register.c
index adb64cc..c66f63e 100644
--- a/src/register.c
+++ b/src/register.c
@@ -193,11 +193,8 @@ int io_uring_register_files(struct io_uring *ring, const int *files,
 
 int io_uring_unregister_files(struct io_uring *ring)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_FILES,
-				      NULL, 0);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_UNREGISTER_FILES,
+				       NULL, 0);
 }
 
 int io_uring_register_eventfd(struct io_uring *ring, int event_fd)
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing v1 4/5] register: Remove useless branch in register probe
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
                   ` (2 preceding siblings ...)
  2022-11-23 12:53 ` [PATCH liburing v1 3/5] register: Remove useless branch in unregister files Ammar Faizi
@ 2022-11-23 12:53 ` Ammar Faizi
  2022-11-23 12:53 ` [PATCH liburing v1 5/5] register: Remove useless branch in register restrictions Ammar Faizi
  2022-11-24 13:34 ` [PATCH liburing v1 0/5] Remove useless brances in register functions Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

IORING_REGISTER_PROBE doesn't return a positive value. This branch is
useless. Remove it.

[1]: io_probe

Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/io_uring.c#L3608-L3646 [1]
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/register.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/register.c b/src/register.c
index c66f63e..6075f04 100644
--- a/src/register.c
+++ b/src/register.c
@@ -219,11 +219,8 @@ int io_uring_register_eventfd_async(struct io_uring *ring, int event_fd)
 int io_uring_register_probe(struct io_uring *ring, struct io_uring_probe *p,
 			    unsigned int nr_ops)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_PROBE, p,
-				      nr_ops);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd, IORING_REGISTER_PROBE, p,
+				       nr_ops);
 }
 
 int io_uring_register_personality(struct io_uring *ring)
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing v1 5/5] register: Remove useless branch in register restrictions
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
                   ` (3 preceding siblings ...)
  2022-11-23 12:53 ` [PATCH liburing v1 4/5] register: Remove useless branch in register probe Ammar Faizi
@ 2022-11-23 12:53 ` Ammar Faizi
  2022-11-24 13:34 ` [PATCH liburing v1 0/5] Remove useless brances in register functions Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Ammar Faizi @ 2022-11-23 12:53 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Pavel Begunkov, io-uring Mailing List, GNU/Weeb Mailing List,
	Muhammad Rizki, Alviro Iskandar Setiawan, Gilang Fachrezy,
	kernel, Ammar Faizi

From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

IORING_REGISTER_RESTRICTIONS doesn't return a positive value. This
branch is useless. Remove it.

[1]: io_register_restrictions

Kernel-code-ref: https://github.com/torvalds/linux/blob/v6.1-rc6/io_uring/io_uring.c#L3665-L3733 [1]
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/register.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/register.c b/src/register.c
index 6075f04..5fdc6e5 100644
--- a/src/register.c
+++ b/src/register.c
@@ -239,12 +239,9 @@ int io_uring_register_restrictions(struct io_uring *ring,
 				   struct io_uring_restriction *res,
 				   unsigned int nr_res)
 {
-	int ret;
-
-	ret = __sys_io_uring_register(ring->ring_fd,
-				      IORING_REGISTER_RESTRICTIONS, res,
-				      nr_res);
-	return (ret < 0) ? ret : 0;
+	return __sys_io_uring_register(ring->ring_fd,
+				       IORING_REGISTER_RESTRICTIONS, res,
+				       nr_res);
 }
 
 int io_uring_enable_rings(struct io_uring *ring)
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing v1 0/5] Remove useless brances in register functions
  2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
                   ` (4 preceding siblings ...)
  2022-11-23 12:53 ` [PATCH liburing v1 5/5] register: Remove useless branch in register restrictions Ammar Faizi
@ 2022-11-24 13:34 ` Jens Axboe
  5 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2022-11-24 13:34 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List, Muhammad Rizki,
	kernel, Gilang Fachrezy, io-uring Mailing List, Pavel Begunkov

On Wed, 23 Nov 2022 19:53:12 +0700, Ammar Faizi wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> 
> Hi Jens,
> 
> This series removes useless branches in register functions:
>   - io_uring_register_eventfd()
>   - io_uring_unregister_eventfd()
>   - io_uring_register_eventfd_async()
>   - io_uring_register_buffers()
>   - io_uring_unregister_buffers()
>   - io_uring_unregister_files()
>   - io_uring_register_probe()
>   - io_uring_register_restrictions()
> 
> [...]

Applied, thanks!

[1/5] register: Remove useless branches in {un,}register eventfd
      commit: ed62cc1a3048e9aed33cf5fb8f47655fc5175bb4
[2/5] register: Remove useless branches in {un,}register buffers
      commit: a4ae8662b61bee4b89d6953348944030461f276d
[3/5] register: Remove useless branch in unregister files
      commit: 2ca898e57658b0b7a3506c9b97dd6d2a2238c2a3
[4/5] register: Remove useless branch in register probe
      commit: 3a418e3e95d0406b2868d79414065d8fa04f2238
[5/5] register: Remove useless branch in register restrictions
      commit: 636b6bdaa8d84f1b5318e27d1e4ffa86361ae66d

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-24 13:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 12:53 [PATCH liburing v1 0/5] Remove useless brances in register functions Ammar Faizi
2022-11-23 12:53 ` [PATCH liburing v1 1/5] register: Remove useless branches in {un,}register eventfd Ammar Faizi
2022-11-23 12:53 ` [PATCH liburing v1 2/5] register: Remove useless branches in {un,}register buffers Ammar Faizi
2022-11-23 12:53 ` [PATCH liburing v1 3/5] register: Remove useless branch in unregister files Ammar Faizi
2022-11-23 12:53 ` [PATCH liburing v1 4/5] register: Remove useless branch in register probe Ammar Faizi
2022-11-23 12:53 ` [PATCH liburing v1 5/5] register: Remove useless branch in register restrictions Ammar Faizi
2022-11-24 13:34 ` [PATCH liburing v1 0/5] Remove useless brances in register functions Jens Axboe

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.