diff mbox series

[1/2] io_uring/rsrc: declare io_find_buf_node() in header file

Message ID 20250301001610.678223-1-csander@purestorage.com (mailing list archive)
State New
Headers show
Series [1/2] io_uring/rsrc: declare io_find_buf_node() in header file | expand

Commit Message

Caleb Sander Mateos March 1, 2025, 12:16 a.m. UTC
Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
other files.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 io_uring/rsrc.c | 4 ++--
 io_uring/rsrc.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Pavel Begunkov March 1, 2025, 1:46 a.m. UTC | #1
On 3/1/25 00:16, Caleb Sander Mateos wrote:
> Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
> other files.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
>   io_uring/rsrc.c | 4 ++--
>   io_uring/rsrc.h | 2 ++
>   2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index 45bfb37bca1e..4c4f57cd77f9 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -1066,12 +1066,12 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
>   	}
>   
>   	return 0;
>   }
>   
> -static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
> -						    unsigned issue_flags)

That's a hot path, an extra function call wouldn't be great,
and it's an internal detail as well. Let's better see what we
can do with the nop situation.

btw, don't forget cover letters for series.
Caleb Sander Mateos March 1, 2025, 2:04 a.m. UTC | #2
On Fri, Feb 28, 2025 at 5:45 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>
> On 3/1/25 00:16, Caleb Sander Mateos wrote:
> > Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
> > other files.
> >
> > Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> > ---
> >   io_uring/rsrc.c | 4 ++--
> >   io_uring/rsrc.h | 2 ++
> >   2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> > index 45bfb37bca1e..4c4f57cd77f9 100644
> > --- a/io_uring/rsrc.c
> > +++ b/io_uring/rsrc.c
> > @@ -1066,12 +1066,12 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
> >       }
> >
> >       return 0;
> >   }
> >
> > -static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
> > -                                                 unsigned issue_flags)
>
> That's a hot path, an extra function call wouldn't be great,
> and it's an internal detail as well. Let's better see what we
> can do with the nop situation.

I can add back inline. With that, there shouldn't be any difference to
the generated instructions for io_import_reg_buf().

>
> btw, don't forget cover letters for series.

Okay, I didn't have much else to add to the brief commit messages. But
sure, I'll add a cover letter in the future.

Best,
Caleb
Jens Axboe March 1, 2025, 2:22 a.m. UTC | #3
On 2/28/25 7:04 PM, Caleb Sander Mateos wrote:
> On Fri, Feb 28, 2025 at 5:45 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>
>> On 3/1/25 00:16, Caleb Sander Mateos wrote:
>>> Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
>>> other files.
>>>
>>> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
>>> ---
>>>   io_uring/rsrc.c | 4 ++--
>>>   io_uring/rsrc.h | 2 ++
>>>   2 files changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
>>> index 45bfb37bca1e..4c4f57cd77f9 100644
>>> --- a/io_uring/rsrc.c
>>> +++ b/io_uring/rsrc.c
>>> @@ -1066,12 +1066,12 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
>>>       }
>>>
>>>       return 0;
>>>   }
>>>
>>> -static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
>>> -                                                 unsigned issue_flags)
>>
>> That's a hot path, an extra function call wouldn't be great,
>> and it's an internal detail as well. Let's better see what we
>> can do with the nop situation.
> 
> I can add back inline. With that, there shouldn't be any difference to
> the generated instructions for io_import_reg_buf().

Yeah, in general I don't like manual inlines, unless it's been proven
that the compiler messes it up for some reason. If it's short enough
it'll be inlined.

>> btw, don't forget cover letters for series.
> 
> Okay, I didn't have much else to add to the brief commit messages. But
> sure, I'll add a cover letter in the future.

Indeed, cover letters are always great to have.
Jens Axboe March 1, 2025, 2:23 a.m. UTC | #4
On Fri, 28 Feb 2025 17:16:07 -0700, Caleb Sander Mateos wrote:
> Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
> other files.
> 
> 

Applied, thanks!

[1/2] io_uring/rsrc: declare io_find_buf_node() in header file
      commit: 98ddbefafecf270d51902cabfe289df10a702cef
[2/2] io_uring/nop: use io_find_buf_node()
      commit: 15d86dd9019c7a97bd8c5b6880870b97e7cc74ea

Best regards,
Pavel Begunkov March 1, 2025, 2:31 a.m. UTC | #5
On 3/1/25 02:22, Jens Axboe wrote:
> On 2/28/25 7:04 PM, Caleb Sander Mateos wrote:
>> On Fri, Feb 28, 2025 at 5:45 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>>
>>> On 3/1/25 00:16, Caleb Sander Mateos wrote:
>>>> Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
>>>> other files.
>>>>
>>>> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
>>>> ---
>>>>    io_uring/rsrc.c | 4 ++--
>>>>    io_uring/rsrc.h | 2 ++
>>>>    2 files changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
>>>> index 45bfb37bca1e..4c4f57cd77f9 100644
>>>> --- a/io_uring/rsrc.c
>>>> +++ b/io_uring/rsrc.c
>>>> @@ -1066,12 +1066,12 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
>>>>        }
>>>>
>>>>        return 0;
>>>>    }
>>>>
>>>> -static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
>>>> -                                                 unsigned issue_flags)
>>>
>>> That's a hot path, an extra function call wouldn't be great,
>>> and it's an internal detail as well. Let's better see what we
>>> can do with the nop situation.
>>
>> I can add back inline. With that, there shouldn't be any difference to
>> the generated instructions for io_import_reg_buf().
> 
> Yeah, in general I don't like manual inlines, unless it's been proven
> that the compiler messes it up for some reason. If it's short enough
> it'll be inlined.

It will _not_ be inlined in this case.
Jens Axboe March 1, 2025, 2:33 a.m. UTC | #6
On 2/28/25 7:31 PM, Pavel Begunkov wrote:
> On 3/1/25 02:22, Jens Axboe wrote:
>> On 2/28/25 7:04 PM, Caleb Sander Mateos wrote:
>>> On Fri, Feb 28, 2025 at 5:45?PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>>>>
>>>> On 3/1/25 00:16, Caleb Sander Mateos wrote:
>>>>> Declare io_find_buf_node() in io_uring/rsrc.h so it can be called from
>>>>> other files.
>>>>>
>>>>> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
>>>>> ---
>>>>>    io_uring/rsrc.c | 4 ++--
>>>>>    io_uring/rsrc.h | 2 ++
>>>>>    2 files changed, 4 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
>>>>> index 45bfb37bca1e..4c4f57cd77f9 100644
>>>>> --- a/io_uring/rsrc.c
>>>>> +++ b/io_uring/rsrc.c
>>>>> @@ -1066,12 +1066,12 @@ static int io_import_fixed(int ddir, struct iov_iter *iter,
>>>>>        }
>>>>>
>>>>>        return 0;
>>>>>    }
>>>>>
>>>>> -static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
>>>>> -                                                 unsigned issue_flags)
>>>>
>>>> That's a hot path, an extra function call wouldn't be great,
>>>> and it's an internal detail as well. Let's better see what we
>>>> can do with the nop situation.
>>>
>>> I can add back inline. With that, there shouldn't be any difference to
>>> the generated instructions for io_import_reg_buf().
>>
>> Yeah, in general I don't like manual inlines, unless it's been proven
>> that the compiler messes it up for some reason. If it's short enough
>> it'll be inlined.
> 
> It will _not_ be inlined in this case.

Hmm ok - I wonder why that is. But if we want to force it to do that,
then we can just re-add the inline for the local definition, that'll be
fine with it still being non-static and available.
diff mbox series

Patch

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 45bfb37bca1e..4c4f57cd77f9 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -1066,12 +1066,12 @@  static int io_import_fixed(int ddir, struct iov_iter *iter,
 	}
 
 	return 0;
 }
 
-static inline struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
-						    unsigned issue_flags)
+struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
+				      unsigned issue_flags)
 {
 	struct io_ring_ctx *ctx = req->ctx;
 	struct io_rsrc_node *node;
 
 	if (req->flags & REQ_F_BUF_NODE)
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 6fe7b9e615bf..8f912aa6bcc9 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -53,10 +53,12 @@  void io_rsrc_cache_free(struct io_ring_ctx *ctx);
 struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx, int type);
 void io_free_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node);
 void io_rsrc_data_free(struct io_ring_ctx *ctx, struct io_rsrc_data *data);
 int io_rsrc_data_alloc(struct io_rsrc_data *data, unsigned nr);
 
+struct io_rsrc_node *io_find_buf_node(struct io_kiocb *req,
+				      unsigned issue_flags);
 int io_import_reg_buf(struct io_kiocb *req, struct iov_iter *iter,
 			u64 buf_addr, size_t len, int ddir,
 			unsigned issue_flags);
 
 int io_register_clone_buffers(struct io_ring_ctx *ctx, void __user *arg);