public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] add another helper for probing existing opcodes
@ 2020-01-31 15:00 Glauber Costa
  2020-01-31 15:24 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Glauber Costa @ 2020-01-31 15:00 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, Glauber Costa

There are situations where one does not have a ring initialized yet, and
yet they may want to know which opcodes are supported before doing so.

We have recently introduced io_uring_get_probe(io_uring*) to do a
similar task when the ring already exists. Because this was committed
recently and this hasn't seen a release, I thought I would just go ahead
and change that to io_uring_get_probe_ring(io_uring*), because I suck at
finding another meaningful name for this case (io_uring_get_probe_noring
sounded way too ugly to me)

A minimal ring is initialized and torn down inside the function.

Signed-off-by: Glauber Costa <[email protected]>
---
 src/include/liburing.h |  4 +++-
 src/liburing.map       |  1 +
 src/setup.c            | 15 ++++++++++++++-
 test/probe.c           |  2 +-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 39db902..aa11282 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -77,7 +77,9 @@ struct io_uring {
  * return an allocated io_uring_probe structure, or NULL if probe fails (for
  * example, if it is not available). The caller is responsible for freeing it
  */
-extern struct io_uring_probe *io_uring_get_probe(struct io_uring *ring);
+extern struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring);
+/* same as io_uring_get_probe_ring, but takes care of ring init and teardown */
+extern struct io_uring_probe *io_uring_get_probe();
 
 static inline int io_uring_opcode_supported(struct io_uring_probe *p, int op)
 {
diff --git a/src/liburing.map b/src/liburing.map
index ac8288a..8daa432 100644
--- a/src/liburing.map
+++ b/src/liburing.map
@@ -73,4 +73,5 @@ LIBURING_0.4 {
 		io_uring_register_personality;
 		io_uring_unregister_personality;
 		io_uring_get_probe;
+		io_uring_get_probe_ring;
 } LIBURING_0.3;
diff --git a/src/setup.c b/src/setup.c
index c03274c..4fc35ea 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -169,7 +169,7 @@ void io_uring_queue_exit(struct io_uring *ring)
 	close(ring->ring_fd);
 }
 
-struct io_uring_probe *io_uring_get_probe(struct io_uring *ring)
+struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring)
 {
 	struct io_uring_probe *probe;
 	int r;
@@ -186,3 +186,16 @@ fail:
 	free(probe);
 	return NULL;
 }
+
+struct io_uring_probe *io_uring_get_probe() {
+	struct io_uring ring;
+	struct io_uring_probe* probe = NULL;
+
+	int r = io_uring_queue_init(2, &ring, 0);
+	if (r < 0)
+		return NULL;
+
+	probe = io_uring_get_probe_ring(&ring);
+	io_uring_queue_exit(&ring);
+	return probe;
+}
diff --git a/test/probe.c b/test/probe.c
index 34f2028..b85b089 100644
--- a/test/probe.c
+++ b/test/probe.c
@@ -45,7 +45,7 @@ static int test_probe_helper(struct io_uring *ring)
 {
 	struct io_uring_probe *p;
 
-	p = io_uring_get_probe(ring);
+	p = io_uring_get_probe_ring(ring);
 	if (!p) {
 		fprintf(stderr, "Failed getting probe data\n");
 		return 1;
-- 
2.20.1


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

* Re: [PATCH liburing] add another helper for probing existing opcodes
  2020-01-31 15:00 [PATCH liburing] add another helper for probing existing opcodes Glauber Costa
@ 2020-01-31 15:24 ` Jens Axboe
  2020-01-31 15:28   ` Glauber Costa
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-01-31 15:24 UTC (permalink / raw)
  To: Glauber Costa, io-uring

On 1/31/20 8:00 AM, Glauber Costa wrote:
> There are situations where one does not have a ring initialized yet, and
> yet they may want to know which opcodes are supported before doing so.
> 
> We have recently introduced io_uring_get_probe(io_uring*) to do a
> similar task when the ring already exists. Because this was committed
> recently and this hasn't seen a release, I thought I would just go ahead
> and change that to io_uring_get_probe_ring(io_uring*), because I suck at
> finding another meaningful name for this case (io_uring_get_probe_noring
> sounded way too ugly to me)
> 
> A minimal ring is initialized and torn down inside the function.
> 
> Signed-off-by: Glauber Costa <[email protected]>
> ---
>  src/include/liburing.h |  4 +++-
>  src/liburing.map       |  1 +
>  src/setup.c            | 15 ++++++++++++++-
>  test/probe.c           |  2 +-
>  4 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/src/include/liburing.h b/src/include/liburing.h
> index 39db902..aa11282 100644
> --- a/src/include/liburing.h
> +++ b/src/include/liburing.h
> @@ -77,7 +77,9 @@ struct io_uring {
>   * return an allocated io_uring_probe structure, or NULL if probe fails (for
>   * example, if it is not available). The caller is responsible for freeing it
>   */
> -extern struct io_uring_probe *io_uring_get_probe(struct io_uring *ring);
> +extern struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring);
> +/* same as io_uring_get_probe_ring, but takes care of ring init and teardown */
> +extern struct io_uring_probe *io_uring_get_probe();

Include 'void' for no parameter.

> @@ -186,3 +186,16 @@ fail:
>  	free(probe);
>  	return NULL;
>  }
> +
> +struct io_uring_probe *io_uring_get_probe() {

void here as well, and new line before the opening bracket.

Minor stuff, rest looks fine to me.

-- 
Jens Axboe


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

* Re: [PATCH liburing] add another helper for probing existing opcodes
  2020-01-31 15:24 ` Jens Axboe
@ 2020-01-31 15:28   ` Glauber Costa
  0 siblings, 0 replies; 3+ messages in thread
From: Glauber Costa @ 2020-01-31 15:28 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring

On Fri, Jan 31, 2020 at 10:24 AM Jens Axboe <[email protected]> wrote:
>
> On 1/31/20 8:00 AM, Glauber Costa wrote:
> > There are situations where one does not have a ring initialized yet, and
> > yet they may want to know which opcodes are supported before doing so.
> >
> > We have recently introduced io_uring_get_probe(io_uring*) to do a
> > similar task when the ring already exists. Because this was committed
> > recently and this hasn't seen a release, I thought I would just go ahead
> > and change that to io_uring_get_probe_ring(io_uring*), because I suck at
> > finding another meaningful name for this case (io_uring_get_probe_noring
> > sounded way too ugly to me)
> >
> > A minimal ring is initialized and torn down inside the function.
> >
> > Signed-off-by: Glauber Costa <[email protected]>
> > ---
> >  src/include/liburing.h |  4 +++-
> >  src/liburing.map       |  1 +
> >  src/setup.c            | 15 ++++++++++++++-
> >  test/probe.c           |  2 +-
> >  4 files changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/include/liburing.h b/src/include/liburing.h
> > index 39db902..aa11282 100644
> > --- a/src/include/liburing.h
> > +++ b/src/include/liburing.h
> > @@ -77,7 +77,9 @@ struct io_uring {
> >   * return an allocated io_uring_probe structure, or NULL if probe fails (for
> >   * example, if it is not available). The caller is responsible for freeing it
> >   */
> > -extern struct io_uring_probe *io_uring_get_probe(struct io_uring *ring);
> > +extern struct io_uring_probe *io_uring_get_probe_ring(struct io_uring *ring);
> > +/* same as io_uring_get_probe_ring, but takes care of ring init and teardown */
> > +extern struct io_uring_probe *io_uring_get_probe();
>
> Include 'void' for no parameter.
>
> > @@ -186,3 +186,16 @@ fail:
> >       free(probe);
> >       return NULL;
> >  }
> > +
> > +struct io_uring_probe *io_uring_get_probe() {
>
> void here as well, and new line before the opening bracket.
>
> Minor stuff, rest looks fine to me.

What's next? tabs instead of spaces?
You monsters.

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

end of thread, other threads:[~2020-01-31 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-31 15:00 [PATCH liburing] add another helper for probing existing opcodes Glauber Costa
2020-01-31 15:24 ` Jens Axboe
2020-01-31 15:28   ` Glauber Costa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox