diff mbox series

[net-next,v3] net: dqs: introduce IFF_NO_BQL private flag for non-BQL drivers

Message ID 20240613023549.15213-1-kerneljasonxing@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] net: dqs: introduce IFF_NO_BQL private flag for non-BQL drivers | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4762 this patch: 4762
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: virtualization@lists.linux.dev
netdev/build_clang success Errors and warnings before: 948 this patch: 948
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 5030 this patch: 5030
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 22 this patch: 22
netdev/source_inline success Was 0 now: 0

Commit Message

Jason Xing June 13, 2024, 2:35 a.m. UTC
From: Jason Xing <kernelxing@tencent.com>

Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
BQL device") limits the non-BQL driver not creating byte_queue_limits
directory, I found there is one exception, namely, virtio-net driver,
which should also be limited in netdev_uses_bql(). Let me give it a
try first.

I decided to introduce a NO_BQL bit because:
1) it can help us limit virtio-net driver for now.
2) if we found another non-BQL driver, we can take it into account.
3) we can replace all the driver meeting those two statements in
netdev_uses_bql() in future.

For now, I would like to make the first step to use this new bit for dqs
use instead of replacing/applying all the non-BQL drivers in one go.

As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
new non-BQL drivers as soon as we find one.

After this patch, there is no byte_queue_limits directory in virtio-net
driver.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v3
Link: https://lore.kernel.org/all/20240611033203.54845-1-kerneljasonxing@gmail.com/
1. revise the comment as suggested by Jakub.

v2
Link: https://lore.kernel.org/all/20240609131732.73156-1-kerneljasonxing@gmail.com/
1. chose to add the new bit into enum netdev_priv_flags() instead of
breaking the room of device feature.
---
 drivers/net/virtio_net.c  | 2 +-
 include/linux/netdevice.h | 3 +++
 net/core/net-sysfs.c      | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

Comments

Jiri Pirko June 13, 2024, 5:38 a.m. UTC | #1
Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
>From: Jason Xing <kernelxing@tencent.com>
>
>Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
>BQL device") limits the non-BQL driver not creating byte_queue_limits
>directory, I found there is one exception, namely, virtio-net driver,
>which should also be limited in netdev_uses_bql(). Let me give it a
>try first.
>
>I decided to introduce a NO_BQL bit because:
>1) it can help us limit virtio-net driver for now.
>2) if we found another non-BQL driver, we can take it into account.
>3) we can replace all the driver meeting those two statements in
>netdev_uses_bql() in future.
>
>For now, I would like to make the first step to use this new bit for dqs
>use instead of replacing/applying all the non-BQL drivers in one go.
>
>As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
>new non-BQL drivers as soon as we find one.
>
>After this patch, there is no byte_queue_limits directory in virtio-net
>driver.

Please note following patch is currently trying to push bql support for
virtio_net:
https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/

When that is merged, this patch is not needed. Could we wait?
Jason Xing June 13, 2024, 6:08 a.m. UTC | #2
On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >From: Jason Xing <kernelxing@tencent.com>
> >
> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >directory, I found there is one exception, namely, virtio-net driver,
> >which should also be limited in netdev_uses_bql(). Let me give it a
> >try first.
> >
> >I decided to introduce a NO_BQL bit because:
> >1) it can help us limit virtio-net driver for now.
> >2) if we found another non-BQL driver, we can take it into account.
> >3) we can replace all the driver meeting those two statements in
> >netdev_uses_bql() in future.
> >
> >For now, I would like to make the first step to use this new bit for dqs
> >use instead of replacing/applying all the non-BQL drivers in one go.
> >
> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >new non-BQL drivers as soon as we find one.
> >
> >After this patch, there is no byte_queue_limits directory in virtio-net
> >driver.
>
> Please note following patch is currently trying to push bql support for
> virtio_net:
> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/

I saw this one this morning and I'm reviewing/testing it.

>
> When that is merged, this patch is not needed. Could we wait?

Please note this patch is not only written for virtio_net driver.
Virtio_net driver is one of possible cases.

After your patch gets merged (I think it will take some time), you
could simply remove that one line in virtio_net.c.

Thanks.
Jiri Pirko June 13, 2024, 7:19 a.m. UTC | #3
Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
>On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>>
>> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
>> >From: Jason Xing <kernelxing@tencent.com>
>> >
>> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
>> >BQL device") limits the non-BQL driver not creating byte_queue_limits
>> >directory, I found there is one exception, namely, virtio-net driver,
>> >which should also be limited in netdev_uses_bql(). Let me give it a
>> >try first.
>> >
>> >I decided to introduce a NO_BQL bit because:
>> >1) it can help us limit virtio-net driver for now.
>> >2) if we found another non-BQL driver, we can take it into account.
>> >3) we can replace all the driver meeting those two statements in
>> >netdev_uses_bql() in future.
>> >
>> >For now, I would like to make the first step to use this new bit for dqs
>> >use instead of replacing/applying all the non-BQL drivers in one go.
>> >
>> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
>> >new non-BQL drivers as soon as we find one.
>> >
>> >After this patch, there is no byte_queue_limits directory in virtio-net
>> >driver.
>>
>> Please note following patch is currently trying to push bql support for
>> virtio_net:
>> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
>
>I saw this one this morning and I'm reviewing/testing it.
>
>>
>> When that is merged, this patch is not needed. Could we wait?
>
>Please note this patch is not only written for virtio_net driver.
>Virtio_net driver is one of possible cases.

Yeah, but without virtio_net, there will be no users. What's the point
of having that in code? I mean, in general, no-user kernel code gets
removed.


>
>After your patch gets merged (I think it will take some time), you
>could simply remove that one line in virtio_net.c.
>
>Thanks.
Jason Xing June 13, 2024, 7:24 a.m. UTC | #4
On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >>
> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >> >From: Jason Xing <kernelxing@tencent.com>
> >> >
> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >> >directory, I found there is one exception, namely, virtio-net driver,
> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> >> >try first.
> >> >
> >> >I decided to introduce a NO_BQL bit because:
> >> >1) it can help us limit virtio-net driver for now.
> >> >2) if we found another non-BQL driver, we can take it into account.
> >> >3) we can replace all the driver meeting those two statements in
> >> >netdev_uses_bql() in future.
> >> >
> >> >For now, I would like to make the first step to use this new bit for dqs
> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> >> >
> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >> >new non-BQL drivers as soon as we find one.
> >> >
> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> >> >driver.
> >>
> >> Please note following patch is currently trying to push bql support for
> >> virtio_net:
> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> >
> >I saw this one this morning and I'm reviewing/testing it.
> >
> >>
> >> When that is merged, this patch is not needed. Could we wait?
> >
> >Please note this patch is not only written for virtio_net driver.
> >Virtio_net driver is one of possible cases.
>
> Yeah, but without virtio_net, there will be no users. What's the point
> of having that in code? I mean, in general, no-user kernel code gets
> removed.

Are you sure netdev_uses_bql() can limit all the non-bql drivers with
those two checks? I haven't investigated this part.

>
>
> >
> >After your patch gets merged (I think it will take some time), you
> >could simply remove that one line in virtio_net.c.
> >
> >Thanks.
Jason Xing June 13, 2024, 7:49 a.m. UTC | #5
On Thu, Jun 13, 2024 at 3:24 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >
> > Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> > >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> > >>
> > >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> > >> >From: Jason Xing <kernelxing@tencent.com>
> > >> >
> > >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> > >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> > >> >directory, I found there is one exception, namely, virtio-net driver,
> > >> >which should also be limited in netdev_uses_bql(). Let me give it a
> > >> >try first.
> > >> >
> > >> >I decided to introduce a NO_BQL bit because:
> > >> >1) it can help us limit virtio-net driver for now.
> > >> >2) if we found another non-BQL driver, we can take it into account.
> > >> >3) we can replace all the driver meeting those two statements in
> > >> >netdev_uses_bql() in future.
> > >> >
> > >> >For now, I would like to make the first step to use this new bit for dqs
> > >> >use instead of replacing/applying all the non-BQL drivers in one go.
> > >> >
> > >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> > >> >new non-BQL drivers as soon as we find one.
> > >> >
> > >> >After this patch, there is no byte_queue_limits directory in virtio-net
> > >> >driver.
> > >>
> > >> Please note following patch is currently trying to push bql support for
> > >> virtio_net:
> > >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> > >
> > >I saw this one this morning and I'm reviewing/testing it.
> > >
> > >>
> > >> When that is merged, this patch is not needed. Could we wait?
> > >
> > >Please note this patch is not only written for virtio_net driver.
> > >Virtio_net driver is one of possible cases.
> >
> > Yeah, but without virtio_net, there will be no users. What's the point
> > of having that in code? I mean, in general, no-user kernel code gets
> > removed.
>
> Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> those two checks? I haven't investigated this part.

I just googled it very quickly and saw the ENA driver which turns off
BQL by default due to the problem of head-of line blocking[1].
IIUC, ENA is not limited by the checks in netdev_uses_bql() but it should.

I run this command: grep -ir -E "NO_QUEUE|NETIF_F_LLTX"
drivers/net/ethernet/amazon/ena

Am I right?

[1]: https://github.com/amzn/amzn-drivers/issues/262

>
> >
> >
> > >
> > >After your patch gets merged (I think it will take some time), you
> > >could simply remove that one line in virtio_net.c.
> > >
> > >Thanks.
Jiri Pirko June 13, 2024, 7:51 a.m. UTC | #6
Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
>On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
>>
>> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
>> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>> >>
>> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
>> >> >From: Jason Xing <kernelxing@tencent.com>
>> >> >
>> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
>> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
>> >> >directory, I found there is one exception, namely, virtio-net driver,
>> >> >which should also be limited in netdev_uses_bql(). Let me give it a
>> >> >try first.
>> >> >
>> >> >I decided to introduce a NO_BQL bit because:
>> >> >1) it can help us limit virtio-net driver for now.
>> >> >2) if we found another non-BQL driver, we can take it into account.
>> >> >3) we can replace all the driver meeting those two statements in
>> >> >netdev_uses_bql() in future.
>> >> >
>> >> >For now, I would like to make the first step to use this new bit for dqs
>> >> >use instead of replacing/applying all the non-BQL drivers in one go.
>> >> >
>> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
>> >> >new non-BQL drivers as soon as we find one.
>> >> >
>> >> >After this patch, there is no byte_queue_limits directory in virtio-net
>> >> >driver.
>> >>
>> >> Please note following patch is currently trying to push bql support for
>> >> virtio_net:
>> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
>> >
>> >I saw this one this morning and I'm reviewing/testing it.
>> >
>> >>
>> >> When that is merged, this patch is not needed. Could we wait?
>> >
>> >Please note this patch is not only written for virtio_net driver.
>> >Virtio_net driver is one of possible cases.
>>
>> Yeah, but without virtio_net, there will be no users. What's the point
>> of having that in code? I mean, in general, no-user kernel code gets
>> removed.
>
>Are you sure netdev_uses_bql() can limit all the non-bql drivers with
>those two checks? I haven't investigated this part.

Nope. What I say is, if there are other users, let's find them and let
them use what you are introducing here. Otherwise don't add unused code.

>
>>
>>
>> >
>> >After your patch gets merged (I think it will take some time), you
>> >could simply remove that one line in virtio_net.c.
>> >
>> >Thanks.
Jason Xing June 13, 2024, 7:52 a.m. UTC | #7
On Thu, Jun 13, 2024 at 3:51 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >>
> >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> >>
> >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >> >> >From: Jason Xing <kernelxing@tencent.com>
> >> >> >
> >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >> >> >directory, I found there is one exception, namely, virtio-net driver,
> >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> >> >> >try first.
> >> >> >
> >> >> >I decided to introduce a NO_BQL bit because:
> >> >> >1) it can help us limit virtio-net driver for now.
> >> >> >2) if we found another non-BQL driver, we can take it into account.
> >> >> >3) we can replace all the driver meeting those two statements in
> >> >> >netdev_uses_bql() in future.
> >> >> >
> >> >> >For now, I would like to make the first step to use this new bit for dqs
> >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> >> >> >
> >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >> >> >new non-BQL drivers as soon as we find one.
> >> >> >
> >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> >> >> >driver.
> >> >>
> >> >> Please note following patch is currently trying to push bql support for
> >> >> virtio_net:
> >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> >> >
> >> >I saw this one this morning and I'm reviewing/testing it.
> >> >
> >> >>
> >> >> When that is merged, this patch is not needed. Could we wait?
> >> >
> >> >Please note this patch is not only written for virtio_net driver.
> >> >Virtio_net driver is one of possible cases.
> >>
> >> Yeah, but without virtio_net, there will be no users. What's the point
> >> of having that in code? I mean, in general, no-user kernel code gets
> >> removed.
> >
> >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> >those two checks? I haven't investigated this part.
>
> Nope. What I say is, if there are other users, let's find them and let
> them use what you are introducing here. Otherwise don't add unused code.

Please take a look at what I just wrote. I found one.

>
> >
> >>
> >>
> >> >
> >> >After your patch gets merged (I think it will take some time), you
> >> >could simply remove that one line in virtio_net.c.
> >> >
> >> >Thanks.
Michael S. Tsirkin June 13, 2024, 7:56 a.m. UTC | #8
On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
> Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >>
> >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> >>
> >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >> >> >From: Jason Xing <kernelxing@tencent.com>
> >> >> >
> >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >> >> >directory, I found there is one exception, namely, virtio-net driver,
> >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> >> >> >try first.
> >> >> >
> >> >> >I decided to introduce a NO_BQL bit because:
> >> >> >1) it can help us limit virtio-net driver for now.
> >> >> >2) if we found another non-BQL driver, we can take it into account.
> >> >> >3) we can replace all the driver meeting those two statements in
> >> >> >netdev_uses_bql() in future.
> >> >> >
> >> >> >For now, I would like to make the first step to use this new bit for dqs
> >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> >> >> >
> >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >> >> >new non-BQL drivers as soon as we find one.
> >> >> >
> >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> >> >> >driver.
> >> >>
> >> >> Please note following patch is currently trying to push bql support for
> >> >> virtio_net:
> >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> >> >
> >> >I saw this one this morning and I'm reviewing/testing it.
> >> >
> >> >>
> >> >> When that is merged, this patch is not needed. Could we wait?
> >> >
> >> >Please note this patch is not only written for virtio_net driver.
> >> >Virtio_net driver is one of possible cases.
> >>
> >> Yeah, but without virtio_net, there will be no users. What's the point
> >> of having that in code? I mean, in general, no-user kernel code gets
> >> removed.
> >
> >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> >those two checks? I haven't investigated this part.
> 
> Nope. What I say is, if there are other users, let's find them and let
> them use what you are introducing here. Otherwise don't add unused code.


Additionally, it looks like virtio is going to become a
"sometimes BQL sometimes no-BQL" driver, so what's the plan -
to set/clear the flag accordingly then? What kind of locking
will be needed?

> >
> >>
> >>
> >> >
> >> >After your patch gets merged (I think it will take some time), you
> >> >could simply remove that one line in virtio_net.c.
> >> >
> >> >Thanks.
Jason Xing June 13, 2024, 9:26 a.m. UTC | #9
On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
> > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> > >>
> > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> > >> >>
> > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> > >> >> >From: Jason Xing <kernelxing@tencent.com>
> > >> >> >
> > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> > >> >> >directory, I found there is one exception, namely, virtio-net driver,
> > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> > >> >> >try first.
> > >> >> >
> > >> >> >I decided to introduce a NO_BQL bit because:
> > >> >> >1) it can help us limit virtio-net driver for now.
> > >> >> >2) if we found another non-BQL driver, we can take it into account.
> > >> >> >3) we can replace all the driver meeting those two statements in
> > >> >> >netdev_uses_bql() in future.
> > >> >> >
> > >> >> >For now, I would like to make the first step to use this new bit for dqs
> > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> > >> >> >
> > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> > >> >> >new non-BQL drivers as soon as we find one.
> > >> >> >
> > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> > >> >> >driver.
> > >> >>
> > >> >> Please note following patch is currently trying to push bql support for
> > >> >> virtio_net:
> > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> > >> >
> > >> >I saw this one this morning and I'm reviewing/testing it.
> > >> >
> > >> >>
> > >> >> When that is merged, this patch is not needed. Could we wait?
> > >> >
> > >> >Please note this patch is not only written for virtio_net driver.
> > >> >Virtio_net driver is one of possible cases.
> > >>
> > >> Yeah, but without virtio_net, there will be no users. What's the point
> > >> of having that in code? I mean, in general, no-user kernel code gets
> > >> removed.
> > >
> > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> > >those two checks? I haven't investigated this part.
> >
> > Nope. What I say is, if there are other users, let's find them and let
> > them use what you are introducing here. Otherwise don't add unused code.
>
>
> Additionally, it looks like virtio is going to become a
> "sometimes BQL sometimes no-BQL" driver, so what's the plan -
> to set/clear the flag accordingly then? What kind of locking
> will be needed?

Could we consider the default mode is BQL, so we can remove that new
IFF_NO_BQL flag? If it's hard to take care of these two situations, I
think we could follow this suggestion from Jakub: "netdev_uses_bql()
is best effort". What do you think?

>
> > >
> > >>
> > >>
> > >> >
> > >> >After your patch gets merged (I think it will take some time), you
> > >> >could simply remove that one line in virtio_net.c.
> > >> >
> > >> >Thanks.
>
Jason Xing June 13, 2024, 1:08 p.m. UTC | #10
On Thu, Jun 13, 2024 at 5:26 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
> > > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> > > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> > > >>
> > > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> > > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> > > >> >>
> > > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> > > >> >> >From: Jason Xing <kernelxing@tencent.com>
> > > >> >> >
> > > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> > > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> > > >> >> >directory, I found there is one exception, namely, virtio-net driver,
> > > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> > > >> >> >try first.
> > > >> >> >
> > > >> >> >I decided to introduce a NO_BQL bit because:
> > > >> >> >1) it can help us limit virtio-net driver for now.
> > > >> >> >2) if we found another non-BQL driver, we can take it into account.
> > > >> >> >3) we can replace all the driver meeting those two statements in
> > > >> >> >netdev_uses_bql() in future.
> > > >> >> >
> > > >> >> >For now, I would like to make the first step to use this new bit for dqs
> > > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> > > >> >> >
> > > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> > > >> >> >new non-BQL drivers as soon as we find one.
> > > >> >> >
> > > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> > > >> >> >driver.
> > > >> >>
> > > >> >> Please note following patch is currently trying to push bql support for
> > > >> >> virtio_net:
> > > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> > > >> >
> > > >> >I saw this one this morning and I'm reviewing/testing it.
> > > >> >
> > > >> >>
> > > >> >> When that is merged, this patch is not needed. Could we wait?
> > > >> >
> > > >> >Please note this patch is not only written for virtio_net driver.
> > > >> >Virtio_net driver is one of possible cases.
> > > >>
> > > >> Yeah, but without virtio_net, there will be no users. What's the point
> > > >> of having that in code? I mean, in general, no-user kernel code gets
> > > >> removed.
> > > >
> > > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> > > >those two checks? I haven't investigated this part.
> > >
> > > Nope. What I say is, if there are other users, let's find them and let
> > > them use what you are introducing here. Otherwise don't add unused code.
> >
> >
> > Additionally, it looks like virtio is going to become a
> > "sometimes BQL sometimes no-BQL" driver, so what's the plan -
> > to set/clear the flag accordingly then? What kind of locking
> > will be needed?
>
> Could we consider the default mode is BQL, so we can remove that new
> IFF_NO_BQL flag? If it's hard to take care of these two situations, I
> think we could follow this suggestion from Jakub: "netdev_uses_bql()
> is best effort". What do you think?

ENA driver faces the same 'problem' because it also has BQL and no-BQL.

Honestly, I don't want to spend too much time on this patch because
it's not worth it. Allow me to set the IFF_NO_BQL flag for the default
mode to try our 'best effort' for virtio_net and ENA driver?

Thanks,
Jason
Jiri Pirko June 13, 2024, 1:17 p.m. UTC | #11
Thu, Jun 13, 2024 at 11:26:05AM CEST, kerneljasonxing@gmail.com wrote:
>On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>>
>> On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
>> > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
>> > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
>> > >>
>> > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
>> > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>> > >> >>
>> > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
>> > >> >> >From: Jason Xing <kernelxing@tencent.com>
>> > >> >> >
>> > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
>> > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
>> > >> >> >directory, I found there is one exception, namely, virtio-net driver,
>> > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
>> > >> >> >try first.
>> > >> >> >
>> > >> >> >I decided to introduce a NO_BQL bit because:
>> > >> >> >1) it can help us limit virtio-net driver for now.
>> > >> >> >2) if we found another non-BQL driver, we can take it into account.
>> > >> >> >3) we can replace all the driver meeting those two statements in
>> > >> >> >netdev_uses_bql() in future.
>> > >> >> >
>> > >> >> >For now, I would like to make the first step to use this new bit for dqs
>> > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
>> > >> >> >
>> > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
>> > >> >> >new non-BQL drivers as soon as we find one.
>> > >> >> >
>> > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
>> > >> >> >driver.
>> > >> >>
>> > >> >> Please note following patch is currently trying to push bql support for
>> > >> >> virtio_net:
>> > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
>> > >> >
>> > >> >I saw this one this morning and I'm reviewing/testing it.
>> > >> >
>> > >> >>
>> > >> >> When that is merged, this patch is not needed. Could we wait?
>> > >> >
>> > >> >Please note this patch is not only written for virtio_net driver.
>> > >> >Virtio_net driver is one of possible cases.
>> > >>
>> > >> Yeah, but without virtio_net, there will be no users. What's the point
>> > >> of having that in code? I mean, in general, no-user kernel code gets
>> > >> removed.
>> > >
>> > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
>> > >those two checks? I haven't investigated this part.
>> >
>> > Nope. What I say is, if there are other users, let's find them and let
>> > them use what you are introducing here. Otherwise don't add unused code.
>>
>>
>> Additionally, it looks like virtio is going to become a
>> "sometimes BQL sometimes no-BQL" driver, so what's the plan -
>> to set/clear the flag accordingly then? What kind of locking
>> will be needed?
>
>Could we consider the default mode is BQL, so we can remove that new
>IFF_NO_BQL flag? If it's hard to take care of these two situations, I
>think we could follow this suggestion from Jakub: "netdev_uses_bql()
>is best effort". What do you think?

Make sense.

Also, note that virtio_net bql utilization is going to be not only
dynamically configured, but also per-queue. It would be hard to expose
that over one device flag :)


>
>>
>> > >
>> > >>
>> > >>
>> > >> >
>> > >> >After your patch gets merged (I think it will take some time), you
>> > >> >could simply remove that one line in virtio_net.c.
>> > >> >
>> > >> >Thanks.
>>
Jason Xing June 13, 2024, 2:11 p.m. UTC | #12
On Thu, Jun 13, 2024 at 9:17 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Thu, Jun 13, 2024 at 11:26:05AM CEST, kerneljasonxing@gmail.com wrote:
> >On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >>
> >> On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
> >> > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> >> > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> > >>
> >> > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> >> > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> > >> >>
> >> > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >> > >> >> >From: Jason Xing <kernelxing@tencent.com>
> >> > >> >> >
> >> > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >> > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >> > >> >> >directory, I found there is one exception, namely, virtio-net driver,
> >> > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> >> > >> >> >try first.
> >> > >> >> >
> >> > >> >> >I decided to introduce a NO_BQL bit because:
> >> > >> >> >1) it can help us limit virtio-net driver for now.
> >> > >> >> >2) if we found another non-BQL driver, we can take it into account.
> >> > >> >> >3) we can replace all the driver meeting those two statements in
> >> > >> >> >netdev_uses_bql() in future.
> >> > >> >> >
> >> > >> >> >For now, I would like to make the first step to use this new bit for dqs
> >> > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> >> > >> >> >
> >> > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >> > >> >> >new non-BQL drivers as soon as we find one.
> >> > >> >> >
> >> > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> >> > >> >> >driver.
> >> > >> >>
> >> > >> >> Please note following patch is currently trying to push bql support for
> >> > >> >> virtio_net:
> >> > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> >> > >> >
> >> > >> >I saw this one this morning and I'm reviewing/testing it.
> >> > >> >
> >> > >> >>
> >> > >> >> When that is merged, this patch is not needed. Could we wait?
> >> > >> >
> >> > >> >Please note this patch is not only written for virtio_net driver.
> >> > >> >Virtio_net driver is one of possible cases.
> >> > >>
> >> > >> Yeah, but without virtio_net, there will be no users. What's the point
> >> > >> of having that in code? I mean, in general, no-user kernel code gets
> >> > >> removed.
> >> > >
> >> > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> >> > >those two checks? I haven't investigated this part.
> >> >
> >> > Nope. What I say is, if there are other users, let's find them and let
> >> > them use what you are introducing here. Otherwise don't add unused code.
> >>
> >>
> >> Additionally, it looks like virtio is going to become a
> >> "sometimes BQL sometimes no-BQL" driver, so what's the plan -
> >> to set/clear the flag accordingly then? What kind of locking
> >> will be needed?
> >
> >Could we consider the default mode is BQL, so we can remove that new
> >IFF_NO_BQL flag? If it's hard to take care of these two situations, I
> >think we could follow this suggestion from Jakub: "netdev_uses_bql()
> >is best effort". What do you think?
>
> Make sense.
>
> Also, note that virtio_net bql utilization is going to be not only
> dynamically configured, but also per-queue. It would be hard to expose
> that over one device flag :)

At that time, I would let virtio_net driver go, that is to say, I
wouldn't take it into consideration in netdev_uses_bql() since it's
too complicated.

BTW, hope to see your per-queue configured feature patchset soon :)

>
>
> >
> >>
> >> > >
> >> > >>
> >> > >>
> >> > >> >
> >> > >> >After your patch gets merged (I think it will take some time), you
> >> > >> >could simply remove that one line in virtio_net.c.
> >> > >> >
> >> > >> >Thanks.
> >>
Jiri Pirko June 13, 2024, 2:34 p.m. UTC | #13
Thu, Jun 13, 2024 at 04:11:12PM CEST, kerneljasonxing@gmail.com wrote:
>On Thu, Jun 13, 2024 at 9:17 PM Jiri Pirko <jiri@resnulli.us> wrote:
>>
>> Thu, Jun 13, 2024 at 11:26:05AM CEST, kerneljasonxing@gmail.com wrote:
>> >On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>> >>
>> >> On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
>> >> > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
>> >> > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
>> >> > >>
>> >> > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
>> >> > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
>> >> > >> >>
>> >> > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
>> >> > >> >> >From: Jason Xing <kernelxing@tencent.com>
>> >> > >> >> >
>> >> > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
>> >> > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
>> >> > >> >> >directory, I found there is one exception, namely, virtio-net driver,
>> >> > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
>> >> > >> >> >try first.
>> >> > >> >> >
>> >> > >> >> >I decided to introduce a NO_BQL bit because:
>> >> > >> >> >1) it can help us limit virtio-net driver for now.
>> >> > >> >> >2) if we found another non-BQL driver, we can take it into account.
>> >> > >> >> >3) we can replace all the driver meeting those two statements in
>> >> > >> >> >netdev_uses_bql() in future.
>> >> > >> >> >
>> >> > >> >> >For now, I would like to make the first step to use this new bit for dqs
>> >> > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
>> >> > >> >> >
>> >> > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
>> >> > >> >> >new non-BQL drivers as soon as we find one.
>> >> > >> >> >
>> >> > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
>> >> > >> >> >driver.
>> >> > >> >>
>> >> > >> >> Please note following patch is currently trying to push bql support for
>> >> > >> >> virtio_net:
>> >> > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
>> >> > >> >
>> >> > >> >I saw this one this morning and I'm reviewing/testing it.
>> >> > >> >
>> >> > >> >>
>> >> > >> >> When that is merged, this patch is not needed. Could we wait?
>> >> > >> >
>> >> > >> >Please note this patch is not only written for virtio_net driver.
>> >> > >> >Virtio_net driver is one of possible cases.
>> >> > >>
>> >> > >> Yeah, but without virtio_net, there will be no users. What's the point
>> >> > >> of having that in code? I mean, in general, no-user kernel code gets
>> >> > >> removed.
>> >> > >
>> >> > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
>> >> > >those two checks? I haven't investigated this part.
>> >> >
>> >> > Nope. What I say is, if there are other users, let's find them and let
>> >> > them use what you are introducing here. Otherwise don't add unused code.
>> >>
>> >>
>> >> Additionally, it looks like virtio is going to become a
>> >> "sometimes BQL sometimes no-BQL" driver, so what's the plan -
>> >> to set/clear the flag accordingly then? What kind of locking
>> >> will be needed?
>> >
>> >Could we consider the default mode is BQL, so we can remove that new
>> >IFF_NO_BQL flag? If it's hard to take care of these two situations, I
>> >think we could follow this suggestion from Jakub: "netdev_uses_bql()
>> >is best effort". What do you think?
>>
>> Make sense.
>>
>> Also, note that virtio_net bql utilization is going to be not only
>> dynamically configured, but also per-queue. It would be hard to expose
>> that over one device flag :)
>
>At that time, I would let virtio_net driver go, that is to say, I
>wouldn't take it into consideration in netdev_uses_bql() since it's
>too complicated.
>
>BTW, hope to see your per-queue configured feature patchset soon :)

It's done already. See virtnet_set_per_queue_coalesce()
if ec->tx_max_coalesced_frames is 0, napi_weight is set to 0 and napi
orphan mode is used.


>
>>
>>
>> >
>> >>
>> >> > >
>> >> > >>
>> >> > >>
>> >> > >> >
>> >> > >> >After your patch gets merged (I think it will take some time), you
>> >> > >> >could simply remove that one line in virtio_net.c.
>> >> > >> >
>> >> > >> >Thanks.
>> >>
Jason Xing June 13, 2024, 2:48 p.m. UTC | #14
On Thu, Jun 13, 2024 at 10:34 PM Jiri Pirko <jiri@resnulli.us> wrote:
>
> Thu, Jun 13, 2024 at 04:11:12PM CEST, kerneljasonxing@gmail.com wrote:
> >On Thu, Jun 13, 2024 at 9:17 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >>
> >> Thu, Jun 13, 2024 at 11:26:05AM CEST, kerneljasonxing@gmail.com wrote:
> >> >On Thu, Jun 13, 2024 at 3:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >> >>
> >> >> On Thu, Jun 13, 2024 at 09:51:00AM +0200, Jiri Pirko wrote:
> >> >> > Thu, Jun 13, 2024 at 09:24:27AM CEST, kerneljasonxing@gmail.com wrote:
> >> >> > >On Thu, Jun 13, 2024 at 3:19 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> >> > >>
> >> >> > >> Thu, Jun 13, 2024 at 08:08:36AM CEST, kerneljasonxing@gmail.com wrote:
> >> >> > >> >On Thu, Jun 13, 2024 at 1:38 PM Jiri Pirko <jiri@resnulli.us> wrote:
> >> >> > >> >>
> >> >> > >> >> Thu, Jun 13, 2024 at 04:35:49AM CEST, kerneljasonxing@gmail.com wrote:
> >> >> > >> >> >From: Jason Xing <kernelxing@tencent.com>
> >> >> > >> >> >
> >> >> > >> >> >Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> >> >> > >> >> >BQL device") limits the non-BQL driver not creating byte_queue_limits
> >> >> > >> >> >directory, I found there is one exception, namely, virtio-net driver,
> >> >> > >> >> >which should also be limited in netdev_uses_bql(). Let me give it a
> >> >> > >> >> >try first.
> >> >> > >> >> >
> >> >> > >> >> >I decided to introduce a NO_BQL bit because:
> >> >> > >> >> >1) it can help us limit virtio-net driver for now.
> >> >> > >> >> >2) if we found another non-BQL driver, we can take it into account.
> >> >> > >> >> >3) we can replace all the driver meeting those two statements in
> >> >> > >> >> >netdev_uses_bql() in future.
> >> >> > >> >> >
> >> >> > >> >> >For now, I would like to make the first step to use this new bit for dqs
> >> >> > >> >> >use instead of replacing/applying all the non-BQL drivers in one go.
> >> >> > >> >> >
> >> >> > >> >> >As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> >> >> > >> >> >new non-BQL drivers as soon as we find one.
> >> >> > >> >> >
> >> >> > >> >> >After this patch, there is no byte_queue_limits directory in virtio-net
> >> >> > >> >> >driver.
> >> >> > >> >>
> >> >> > >> >> Please note following patch is currently trying to push bql support for
> >> >> > >> >> virtio_net:
> >> >> > >> >> https://lore.kernel.org/netdev/20240612170851.1004604-1-jiri@resnulli.us/
> >> >> > >> >
> >> >> > >> >I saw this one this morning and I'm reviewing/testing it.
> >> >> > >> >
> >> >> > >> >>
> >> >> > >> >> When that is merged, this patch is not needed. Could we wait?
> >> >> > >> >
> >> >> > >> >Please note this patch is not only written for virtio_net driver.
> >> >> > >> >Virtio_net driver is one of possible cases.
> >> >> > >>
> >> >> > >> Yeah, but without virtio_net, there will be no users. What's the point
> >> >> > >> of having that in code? I mean, in general, no-user kernel code gets
> >> >> > >> removed.
> >> >> > >
> >> >> > >Are you sure netdev_uses_bql() can limit all the non-bql drivers with
> >> >> > >those two checks? I haven't investigated this part.
> >> >> >
> >> >> > Nope. What I say is, if there are other users, let's find them and let
> >> >> > them use what you are introducing here. Otherwise don't add unused code.
> >> >>
> >> >>
> >> >> Additionally, it looks like virtio is going to become a
> >> >> "sometimes BQL sometimes no-BQL" driver, so what's the plan -
> >> >> to set/clear the flag accordingly then? What kind of locking
> >> >> will be needed?
> >> >
> >> >Could we consider the default mode is BQL, so we can remove that new
> >> >IFF_NO_BQL flag? If it's hard to take care of these two situations, I
> >> >think we could follow this suggestion from Jakub: "netdev_uses_bql()
> >> >is best effort". What do you think?
> >>
> >> Make sense.
> >>
> >> Also, note that virtio_net bql utilization is going to be not only
> >> dynamically configured, but also per-queue. It would be hard to expose
> >> that over one device flag :)
> >
> >At that time, I would let virtio_net driver go, that is to say, I
> >wouldn't take it into consideration in netdev_uses_bql() since it's
> >too complicated.
> >
> >BTW, hope to see your per-queue configured feature patchset soon :)
>
> It's done already. See virtnet_set_per_queue_coalesce()
> if ec->tx_max_coalesced_frames is 0, napi_weight is set to 0 and napi
> orphan mode is used.

Oh right, I missed that... Thanks for reminding me.
Jason Xing June 13, 2024, 2:55 p.m. UTC | #15
On Thu, Jun 13, 2024 at 10:35 AM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> Since commit 74293ea1c4db6 ("net: sysfs: Do not create sysfs for non
> BQL device") limits the non-BQL driver not creating byte_queue_limits
> directory, I found there is one exception, namely, virtio-net driver,
> which should also be limited in netdev_uses_bql(). Let me give it a
> try first.
>
> I decided to introduce a NO_BQL bit because:
> 1) it can help us limit virtio-net driver for now.
> 2) if we found another non-BQL driver, we can take it into account.
> 3) we can replace all the driver meeting those two statements in
> netdev_uses_bql() in future.
>
> For now, I would like to make the first step to use this new bit for dqs
> use instead of replacing/applying all the non-BQL drivers in one go.
>
> As Jakub said, "netdev_uses_bql() is best effort", I think, we can add
> new non-BQL drivers as soon as we find one.
>
> After this patch, there is no byte_queue_limits directory in virtio-net
> driver.
>
> Signed-off-by: Jason Xing <kernelxing@tencent.com>

Hello Jakub,

I wonder why the status of this patch was changed to 'Changes
Requested'? Is there anything else I should adjust?

Thanks,
Jason
Jakub Kicinski June 13, 2024, 3:02 p.m. UTC | #16
On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> I wonder why the status of this patch was changed to 'Changes
> Requested'? Is there anything else I should adjust?

Sorry to flip the question on you, but do you think the patch should 
be merged as is? Given Jiri is adding BQL support to virtio?
Eric Dumazet June 13, 2024, 3:25 p.m. UTC | #17
On Thu, Jun 13, 2024 at 5:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> > I wonder why the status of this patch was changed to 'Changes
> > Requested'? Is there anything else I should adjust?
>
> Sorry to flip the question on you, but do you think the patch should
> be merged as is? Given Jiri is adding BQL support to virtio?

Also what is the rationale for all this discussion ?

Don't we have many sys files that are never used anyway ?
Jason Xing June 13, 2024, 3:31 p.m. UTC | #18
On Thu, Jun 13, 2024 at 11:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> > I wonder why the status of this patch was changed to 'Changes
> > Requested'? Is there anything else I should adjust?
>
> Sorry to flip the question on you, but do you think the patch should
> be merged as is? Given Jiri is adding BQL support to virtio?

I think we should, but you are the maintainer :)

One of the previous emails I wrote: ENA driver also uses no-BQL mode
by default. I believe there are other drivers like this, so the
purpose of this patch aims at those missing drivers.
Jason Xing June 13, 2024, 3:37 p.m. UTC | #19
On Thu, Jun 13, 2024 at 11:26 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, Jun 13, 2024 at 5:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
> >
> > On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> > > I wonder why the status of this patch was changed to 'Changes
> > > Requested'? Is there anything else I should adjust?
> >
> > Sorry to flip the question on you, but do you think the patch should
> > be merged as is? Given Jiri is adding BQL support to virtio?
>
> Also what is the rationale for all this discussion ?
>
> Don't we have many sys files that are never used anyway ?

At the very beginning, I thought the current patch is very simple and
easy to get merged because I just found other non-BQL drivers passing
the checks in netdev_uses_bql(). Also see the commit:
commit 74293ea1c4db62cb969e741fbfd479a34d935024
Author: Breno Leitao <leitao@debian.org>
Date:   Fri Feb 16 01:41:52 2024 -0800

    net: sysfs: Do not create sysfs for non BQL device

    Creation of sysfs entries is expensive, mainly for workloads that
    constantly creates netdev and netns often.

    Do not create BQL sysfs entries for devices that don't need,
    basically those that do not have a real queue, i.e, devices that has
    NETIF_F_LLTX and IFF_NO_QUEUE, such as `lo` interface.

    This will remove the /sys/class/net/eth0/queues/tx-X/byte_queue_limits/
    directory for these devices.

    In the example below, eth0 has the `byte_queue_limits` directory but not
    `lo`.

            # ls /sys/class/net/lo/queues/tx-0/
            traffic_class  tx_maxrate  tx_timeout  xps_cpus  xps_rxqs

            # ls /sys/class/net/eth0/queues/tx-0/byte_queue_limits/
            hold_time  inflight  limit  limit_max  limit_min

    This also removes the #ifdefs, since we can also use netdev_uses_bql() to
    check if the config is enabled. (as suggested by Jakub).

    Suggested-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Breno Leitao <leitao@debian.org>
    Link: https://lore.kernel.org/r/20240216094154.3263843-1-leitao@debian.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

I followed this patch and introduced a flag only.

Actually, it's against my expectations. It involved too many
discussions. As I said again: at the very beginning, I thought it's
very easy to get merged... :(
Eric Dumazet June 13, 2024, 3:48 p.m. UTC | #20
On Thu, Jun 13, 2024 at 5:37 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> On Thu, Jun 13, 2024 at 11:26 PM Eric Dumazet <edumazet@google.com> wrote:
> >
> > On Thu, Jun 13, 2024 at 5:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > >
> > > On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> > > > I wonder why the status of this patch was changed to 'Changes
> > > > Requested'? Is there anything else I should adjust?
> > >
> > > Sorry to flip the question on you, but do you think the patch should
> > > be merged as is? Given Jiri is adding BQL support to virtio?
> >
> > Also what is the rationale for all this discussion ?
> >
> > Don't we have many sys files that are never used anyway ?
>
> At the very beginning, I thought the current patch is very simple and
> easy to get merged because I just found other non-BQL drivers passing
> the checks in netdev_uses_bql(). Also see the commit:

>     Suggested-by: Eric Dumazet <edumazet@google.com>
>     Signed-off-by: Breno Leitao <leitao@debian.org>
>     Link: https://lore.kernel.org/r/20240216094154.3263843-1-leitao@debian.org
>     Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> I followed this patch and introduced a flag only.
>
> Actually, it's against my expectations. It involved too many
> discussions. As I said again: at the very beginning, I thought it's
> very easy to get merged... :(

I think you missed the point of the original suggestion leading to Breno patch.

At Google, we create gazillion of netns per minute, with few virtual
drivers in them (like loopback, ipvlan)

This was pretty easy to avoid /sys/class/net/lo/queues/tx-0/byte_queue_limits/*
creation. cpu savings for little investment.

But when it comes to physical devices, I really do not see the benefit
of being picky about some sysfs files.

So let me repeat my question : Why do you need this ?
Jason Xing June 13, 2024, 4:20 p.m. UTC | #21
On Thu, Jun 13, 2024 at 11:49 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, Jun 13, 2024 at 5:37 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > On Thu, Jun 13, 2024 at 11:26 PM Eric Dumazet <edumazet@google.com> wrote:
> > >
> > > On Thu, Jun 13, 2024 at 5:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
> > > >
> > > > On Thu, 13 Jun 2024 22:55:16 +0800 Jason Xing wrote:
> > > > > I wonder why the status of this patch was changed to 'Changes
> > > > > Requested'? Is there anything else I should adjust?
> > > >
> > > > Sorry to flip the question on you, but do you think the patch should
> > > > be merged as is? Given Jiri is adding BQL support to virtio?
> > >
> > > Also what is the rationale for all this discussion ?
> > >
> > > Don't we have many sys files that are never used anyway ?
> >
> > At the very beginning, I thought the current patch is very simple and
> > easy to get merged because I just found other non-BQL drivers passing
> > the checks in netdev_uses_bql(). Also see the commit:
>
> >     Suggested-by: Eric Dumazet <edumazet@google.com>
> >     Signed-off-by: Breno Leitao <leitao@debian.org>
> >     Link: https://lore.kernel.org/r/20240216094154.3263843-1-leitao@debian.org
> >     Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> >
> > I followed this patch and introduced a flag only.
> >
> > Actually, it's against my expectations. It involved too many
> > discussions. As I said again: at the very beginning, I thought it's
> > very easy to get merged... :(
>
> I think you missed the point of the original suggestion leading to Breno patch.
>
> At Google, we create gazillion of netns per minute, with few virtual
> drivers in them (like loopback, ipvlan)
>
> This was pretty easy to avoid /sys/class/net/lo/queues/tx-0/byte_queue_limits/*
> creation. cpu savings for little investment.
>
> But when it comes to physical devices, I really do not see the benefit
> of being picky about some sysfs files.
>
> So let me repeat my question : Why do you need this ?

Sometimes people can see the sysfs files, sometimes not. They may get
confused. For non-BQL drivers, those sysfs files are totally needless
(not working) with one single flag.

Well, Eric, I don't expect this patch to keep involving more
discussions. If you or Jakub or other maintainers decide to reject
this patch, I'm fine. I can take it. We spend too much time on this
trivial patch. Many patches like this are trivial, not worth spending
you too much precious time on this. As I said, I thought it's very
simple and easy...

Thanks for your explanation.

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 61a57d134544..728f4b9844cc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -5631,7 +5631,7 @@  static int virtnet_probe(struct virtio_device *vdev)
 
 	/* Set up network device as normal. */
 	dev->priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE |
-			   IFF_TX_SKB_NO_LINEAR;
+			   IFF_TX_SKB_NO_LINEAR | IFF_NO_BQL;
 	dev->netdev_ops = &virtnet_netdev;
 	dev->stat_ops = &virtnet_stat_ops;
 	dev->features = NETIF_F_HIGHDMA;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f148a01dd1d1..d371c2b425ca 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1649,6 +1649,8 @@  struct net_device_ops {
  * @IFF_SEE_ALL_HWTSTAMP_REQUESTS: device wants to see calls to
  *	ndo_hwtstamp_set() for all timestamp requests regardless of source,
  *	even if those aren't HWTSTAMP_SOURCE_NETDEV.
+ * @IFF_NO_BQL: driver doesn't support BQL, don't create "byte_queue_limits"
+ *	directories in sysfs.
  */
 enum netdev_priv_flags {
 	IFF_802_1Q_VLAN			= 1<<0,
@@ -1685,6 +1687,7 @@  enum netdev_priv_flags {
 	IFF_TX_SKB_NO_LINEAR		= BIT_ULL(31),
 	IFF_CHANGE_PROTO_DOWN		= BIT_ULL(32),
 	IFF_SEE_ALL_HWTSTAMP_REQUESTS	= BIT_ULL(33),
+	IFF_NO_BQL			= BIT_ULL(34),
 };
 
 #define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 4c27a360c294..7d99fbbad6af 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1765,7 +1765,7 @@  static const struct kobj_type netdev_queue_ktype = {
 static bool netdev_uses_bql(const struct net_device *dev)
 {
 	if (dev->features & NETIF_F_LLTX ||
-	    dev->priv_flags & IFF_NO_QUEUE)
+	    dev->priv_flags & (IFF_NO_QUEUE | IFF_NO_BQL))
 		return false;
 
 	return IS_ENABLED(CONFIG_BQL);