diff mbox series

[ovs-dev,v5] dpcls: Change info-get function to fetch dpcls usage stats.

Message ID 20211215041511.4097090-1-kumar.amber@intel.com
State Superseded
Headers show
Series [ovs-dev,v5] dpcls: Change info-get function to fetch dpcls usage stats. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Kumar Amber Dec. 15, 2021, 4:15 a.m. UTC
Modified the dplcs info-get command output to include
the count for different dpcls implementations.

$ovs-appctl dpif-netdev/subtable-lookup-prio-get

Available dpcls implementations:
  autovalidator (Use count: 1, Priority: 5)
  generic (Use count: 0, Priority: 1)
  avx512_gather (Use count: 0, Priority: 3)

Test case to verify changes:
	1021: PMD - dpcls configuration     ok

Signed-off-by: Kumar Amber <kumar.amber@intel.com>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
Co-authored-by: Eelco Chaudron <echaudro@redhat.com>
---
v5:
- change the info-incr and decr APIs.
- Reduce the complexity of dpcls stats APIs.
v4:
- Fix comments on the patch.
- Change API from an overloaded method of counting, to returning the
  old and new subtable structs. This allows the caller to identify the
  modified subtable implementations, and update the statistics accordingly.
v3:
- Fix comments on the patch.
- Function API remains same, see discussion on OVS ML here:
  "https://mail.openvswitch.org/pipermail/ovs-dev/2021-October/388737.html"
v2:
- Dependency merged rebased to master.

---
---
 Documentation/topics/dpdk/bridge.rst | 16 ++---
 lib/dpif-netdev-lookup.c             | 98 +++++++++++++++++++++-------
 lib/dpif-netdev-lookup.h             | 18 ++++-
 lib/dpif-netdev-private-dpcls.h      |  1 +
 lib/dpif-netdev.c                    | 39 ++++++-----
 tests/pmd.at                         | 16 ++---
 6 files changed, 129 insertions(+), 59 deletions(-)

Comments

Eelco Chaudron Dec. 17, 2021, 11:04 a.m. UTC | #1
On 15 Dec 2021, at 5:15, Kumar Amber wrote:

> Modified the dplcs info-get command output to include
> the count for different dpcls implementations.
>
> $ovs-appctl dpif-netdev/subtable-lookup-prio-get
>
> Available dpcls implementations:
>   autovalidator (Use count: 1, Priority: 5)
>   generic (Use count: 0, Priority: 1)
>   avx512_gather (Use count: 0, Priority: 3)
>
> Test case to verify changes:
> 	1021: PMD - dpcls configuration     ok
>
> Signed-off-by: Kumar Amber <kumar.amber@intel.com>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
> Co-authored-by: Eelco Chaudron <echaudro@redhat.com>
> ---

Changes look good to me, and thanks for following this through!!

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Kumar Amber Dec. 17, 2021, 11:10 a.m. UTC | #2
Thanks A lot, Eelco for all those reviews and great comments .

Regards
Amber

> -----Original Message-----
> From: Eelco Chaudron <echaudro@redhat.com>
> Sent: Friday, December 17, 2021 4:35 PM
> To: Amber, Kumar <kumar.amber@intel.com>
> Cc: ovs-dev@openvswitch.org; fbl@sysclose.org; Stokes, Ian
> <ian.stokes@intel.com>; Van Haaren, Harry <harry.van.haaren@intel.com>
> Subject: Re: [PATCH v5] dpcls: Change info-get function to fetch dpcls usage
> stats.
> 
> 
> 
> On 15 Dec 2021, at 5:15, Kumar Amber wrote:
> 
> > Modified the dplcs info-get command output to include the count for
> > different dpcls implementations.
> >
> > $ovs-appctl dpif-netdev/subtable-lookup-prio-get
> >
> > Available dpcls implementations:
> >   autovalidator (Use count: 1, Priority: 5)
> >   generic (Use count: 0, Priority: 1)
> >   avx512_gather (Use count: 0, Priority: 3)
> >
> > Test case to verify changes:
> > 	1021: PMD - dpcls configuration     ok
> >
> > Signed-off-by: Kumar Amber <kumar.amber@intel.com>
> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> > Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> > Co-authored-by: Harry van Haaren <harry.van.haaren@intel.com>
> > Co-authored-by: Eelco Chaudron <echaudro@redhat.com>
> > ---
> 
> Changes look good to me, and thanks for following this through!!
> 
> Acked-by: Eelco Chaudron <echaudro@redhat.com>
Ilya Maximets March 17, 2022, noon UTC | #3
On 12/15/21 05:15, Kumar Amber wrote:
> Modified the dplcs info-get command output to include
> the count for different dpcls implementations.
> 
> $ovs-appctl dpif-netdev/subtable-lookup-prio-get
> 
> Available dpcls implementations:
>   autovalidator (Use count: 1, Priority: 5)
>   generic (Use count: 0, Priority: 1)
>   avx512_gather (Use count: 0, Priority: 3)
> 

Hi, folks.

Sorry for jumping in so late again, but Mike's recent patch gave me
flashbacks of the following discussion of a very similar functionality:
  https://patchwork.ozlabs.org/project/openvswitch/patch/1576855703-125194-1-git-send-email-emma.finn@intel.com/

We wanted to see which miniflow bits are in each subtable, so we ended
up reporting this information alongside the datapath flow information
in the output of dpctl/dump-flows via dp_extra_info.

This new patch is intended to show which subtable lookup implementation
is used.  But this depends only on the miniflow bits and the current
priorities.  And doesn't change in runtime (unless priorities changed
manually).  What I'm saying is that it's extremely similar information
to what we're already printing as part of dp_extra_info.

Maybe instead of introducing extra counters, we could just add lookup
implementation to the extra info?

Something like this:

  recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=no), \
    dp-extra-info:miniflow_bits(5,1),lookup(avx512_gather) \
    actions:hash(sym_l4(0)),recirc(0x1)

I think, this format gives all the same information, because flows are
dumped per-PMD, so can be counted if needed (I'm not sure though how the
value of the counter is actually useful beside being zero or non-zero).
But also we have a visual representation of the actual flow and we can
see which lookup method is used for it.

Implementation should also be simpler, because the infrastructure is
already in place.  'dp_extra_info' pointer can be protected by rcu to
avoid race conditions while re-generating the string on re-probe.
dpcls_subtable_get_best_impl() can be extended to return a name as a
constant string via the 'out' argument.

Thoughts?

Best regards, Ilya Maximets.
Kumar Amber March 21, 2022, 3:03 p.m. UTC | #4
Hi Ilya,

Thanks for the comments.
Replies are inline.

> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Thursday, March 17, 2022 5:30 PM
> To: Amber, Kumar <kumar.amber@intel.com>; ovs-dev@openvswitch.org;
> Stokes, Ian <ian.stokes@intel.com>
> Cc: fbl@sysclose.org; i.maximets@ovn.org; Eelco Chaudron
> <echaudro@redhat.com>; Ferriter, Cian <cian.ferriter@intel.com>
> Subject: Re: [ovs-dev] [PATCH v5] dpcls: Change info-get function to fetch
> dpcls usage stats.
> 
> On 12/15/21 05:15, Kumar Amber wrote:
> > Modified the dplcs info-get command output to include the count for
> > different dpcls implementations.
> >
> > $ovs-appctl dpif-netdev/subtable-lookup-prio-get
> >
> > Available dpcls implementations:
> >   autovalidator (Use count: 1, Priority: 5)
> >   generic (Use count: 0, Priority: 1)
> >   avx512_gather (Use count: 0, Priority: 3)
> >
> 
> Hi, folks.
> 
> Sorry for jumping in so late again, but Mike's recent patch gave me
> flashbacks of the following discussion of a very similar functionality:
>   https://patchwork.ozlabs.org/project/openvswitch/patch/1576855703-
> 125194-1-git-send-email-emma.finn@intel.com/
> 
> We wanted to see which miniflow bits are in each subtable, so we ended up
> reporting this information alongside the datapath flow information in the
> output of dpctl/dump-flows via dp_extra_info.
> 
> This new patch is intended to show which subtable lookup implementation is
> used.  But this depends only on the miniflow bits and the current priorities.
> And doesn't change in runtime (unless priorities changed manually).  What
> I'm saying is that it's extremely similar information to what we're already
> printing as part of dp_extra_info.
> 
> Maybe instead of introducing extra counters, we could just add lookup
> implementation to the extra info?
> 
> Something like this:
> 
> 
> recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=n
> o), \
>     dp-extra-info:miniflow_bits(5,1),lookup(avx512_gather) \
>     actions:hash(sym_l4(0)),recirc(0x1)
> 
> I think, this format gives all the same information, because flows are dumped
> per-PMD, so can be counted if needed (I'm not sure though how the value of
> the counter is actually useful beside being zero or non-zero).
> But also we have a visual representation of the actual flow and we can see
> which lookup method is used for it.
> 
> Implementation should also be simpler, because the infrastructure is already
> in place.  'dp_extra_info' pointer can be protected by rcu to avoid race
> conditions while re-generating the string on re-probe.
> dpcls_subtable_get_best_impl() can be extended to return a name as a
> constant string via the 'out' argument.
> 
> Thoughts?
> 

I have already made a POC based on the Discussion above and will put that patch in few days with the 
'dp_extra_info' showing DPCLS as well.
 As for this Patch is also important as currently the get-command doesn’t show much info and hence this improvement will make things clear for the user through the dpcl-get-command.
Hence request this usability feature to be merged.
I will follow this patch with the 'dp_extra_info' showing DPCLS functions next to give absolute clarity to the user.

Regards
Amber
> Best regards, Ilya Maximets.
Ilya Maximets March 30, 2022, 4:53 p.m. UTC | #5
On 3/21/22 16:03, Amber, Kumar wrote:
> Hi Ilya,
> 
> Thanks for the comments.
> Replies are inline.
> 
>> -----Original Message-----
>> From: Ilya Maximets <i.maximets@ovn.org>
>> Sent: Thursday, March 17, 2022 5:30 PM
>> To: Amber, Kumar <kumar.amber@intel.com>; ovs-dev@openvswitch.org;
>> Stokes, Ian <ian.stokes@intel.com>
>> Cc: fbl@sysclose.org; i.maximets@ovn.org; Eelco Chaudron
>> <echaudro@redhat.com>; Ferriter, Cian <cian.ferriter@intel.com>
>> Subject: Re: [ovs-dev] [PATCH v5] dpcls: Change info-get function to fetch
>> dpcls usage stats.
>>
>> On 12/15/21 05:15, Kumar Amber wrote:
>>> Modified the dplcs info-get command output to include the count for
>>> different dpcls implementations.
>>>
>>> $ovs-appctl dpif-netdev/subtable-lookup-prio-get
>>>
>>> Available dpcls implementations:
>>>   autovalidator (Use count: 1, Priority: 5)
>>>   generic (Use count: 0, Priority: 1)
>>>   avx512_gather (Use count: 0, Priority: 3)
>>>
>>
>> Hi, folks.
>>
>> Sorry for jumping in so late again, but Mike's recent patch gave me
>> flashbacks of the following discussion of a very similar functionality:
>>   https://patchwork.ozlabs.org/project/openvswitch/patch/1576855703-
>> 125194-1-git-send-email-emma.finn@intel.com/
>>
>> We wanted to see which miniflow bits are in each subtable, so we ended up
>> reporting this information alongside the datapath flow information in the
>> output of dpctl/dump-flows via dp_extra_info.
>>
>> This new patch is intended to show which subtable lookup implementation is
>> used.  But this depends only on the miniflow bits and the current priorities.
>> And doesn't change in runtime (unless priorities changed manually).  What
>> I'm saying is that it's extremely similar information to what we're already
>> printing as part of dp_extra_info.
>>
>> Maybe instead of introducing extra counters, we could just add lookup
>> implementation to the extra info?
>>
>> Something like this:
>>
>>
>> recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(frag=n
>> o), \
>>     dp-extra-info:miniflow_bits(5,1),lookup(avx512_gather) \
>>     actions:hash(sym_l4(0)),recirc(0x1)
>>
>> I think, this format gives all the same information, because flows are dumped
>> per-PMD, so can be counted if needed (I'm not sure though how the value of
>> the counter is actually useful beside being zero or non-zero).
>> But also we have a visual representation of the actual flow and we can see
>> which lookup method is used for it.
>>
>> Implementation should also be simpler, because the infrastructure is already
>> in place.  'dp_extra_info' pointer can be protected by rcu to avoid race
>> conditions while re-generating the string on re-probe.
>> dpcls_subtable_get_best_impl() can be extended to return a name as a
>> constant string via the 'out' argument.
>>
>> Thoughts?
>>
> 
> I have already made a POC based on the Discussion above and will put that patch in few days with the 
> 'dp_extra_info' showing DPCLS as well.
>  As for this Patch is also important as currently the get-command doesn’t show much info and hence this improvement will make things clear for the user through the dpcl-get-command.
> Hence request this usability feature to be merged.
> I will follow this patch with the 'dp_extra_info' showing DPCLS functions next to give absolute clarity to the user.

Why the 'subtable-lookup-prio-get' should return anything except
for the priority of subtable lookup implementations?

That doesn't seem straightforward.  Especially if we'll have that
information reported in a different place already without need for
extra infrastructure.

> 
> Regards
> Amber
>> Best regards, Ilya Maximets.
Kumar Amber April 21, 2022, 11:46 a.m. UTC | #6
Hi Ilya,

Please find my replies inline.

> -----Original Message-----
> From: Ilya Maximets <i.maximets@ovn.org>
> Sent: Wednesday, March 30, 2022 10:23 PM
> To: Amber, Kumar <kumar.amber@intel.com>; ovs-dev@openvswitch.org;
> Stokes, Ian <ian.stokes@intel.com>
> Cc: i.maximets@ovn.org; fbl@sysclose.org; Eelco Chaudron
> <echaudro@redhat.com>; Ferriter, Cian <cian.ferriter@intel.com>
> Subject: Re: [ovs-dev] [PATCH v5] dpcls: Change info-get function to fetch
> dpcls usage stats.
> 
> On 3/21/22 16:03, Amber, Kumar wrote:
> > Hi Ilya,
> >
> > Thanks for the comments.
> > Replies are inline.
> >
> >> -----Original Message-----
> >> From: Ilya Maximets <i.maximets@ovn.org>
> >> Sent: Thursday, March 17, 2022 5:30 PM
> >> To: Amber, Kumar <kumar.amber@intel.com>; ovs-
> dev@openvswitch.org;
> >> Stokes, Ian <ian.stokes@intel.com>
> >> Cc: fbl@sysclose.org; i.maximets@ovn.org; Eelco Chaudron
> >> <echaudro@redhat.com>; Ferriter, Cian <cian.ferriter@intel.com>
> >> Subject: Re: [ovs-dev] [PATCH v5] dpcls: Change info-get function to
> >> fetch dpcls usage stats.
> >>
> >> On 12/15/21 05:15, Kumar Amber wrote:
> >>> Modified the dplcs info-get command output to include the count for
> >>> different dpcls implementations.
> >>>
> >>> $ovs-appctl dpif-netdev/subtable-lookup-prio-get
> >>>
> >>> Available dpcls implementations:
> >>>   autovalidator (Use count: 1, Priority: 5)
> >>>   generic (Use count: 0, Priority: 1)
> >>>   avx512_gather (Use count: 0, Priority: 3)
> >>>
> >>
> >> Hi, folks.
> >>
> >> Sorry for jumping in so late again, but Mike's recent patch gave me
> >> flashbacks of the following discussion of a very similar functionality:
> >>   https://patchwork.ozlabs.org/project/openvswitch/patch/1576855703-
> >> 125194-1-git-send-email-emma.finn@intel.com/
> >>
> >> We wanted to see which miniflow bits are in each subtable, so we
> >> ended up reporting this information alongside the datapath flow
> >> information in the output of dpctl/dump-flows via dp_extra_info.
> >>
> >> This new patch is intended to show which subtable lookup
> >> implementation is used.  But this depends only on the miniflow bits and
> the current priorities.
> >> And doesn't change in runtime (unless priorities changed manually).
> >> What I'm saying is that it's extremely similar information to what
> >> we're already printing as part of dp_extra_info.
> >>
> >> Maybe instead of introducing extra counters, we could just add lookup
> >> implementation to the extra info?
> >>
> >> Something like this:
> >>
> >>
> >> recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth_type(0x0800),ipv4(
> >> frag=n
> >> o), \
> >>     dp-extra-info:miniflow_bits(5,1),lookup(avx512_gather) \
> >>     actions:hash(sym_l4(0)),recirc(0x1)
> >>
> >> I think, this format gives all the same information, because flows
> >> are dumped per-PMD, so can be counted if needed (I'm not sure though
> >> how the value of the counter is actually useful beside being zero or non-
> zero).
> >> But also we have a visual representation of the actual flow and we
> >> can see which lookup method is used for it.
> >>
> >> Implementation should also be simpler, because the infrastructure is
> >> already in place.  'dp_extra_info' pointer can be protected by rcu to
> >> avoid race conditions while re-generating the string on re-probe.
> >> dpcls_subtable_get_best_impl() can be extended to return a name as a
> >> constant string via the 'out' argument.
> >>
> >> Thoughts?
> >>
> >
> > I have already made a POC based on the Discussion above and will put
> > that patch in few days with the 'dp_extra_info' showing DPCLS as well.
> >  As for this Patch is also important as currently the get-command doesn’t
> show much info and hence this improvement will make things clear for the
> user through the dpcl-get-command.
> > Hence request this usability feature to be merged.
> > I will follow this patch with the 'dp_extra_info' showing DPCLS functions
> next to give absolute clarity to the user.
> 
> Why the 'subtable-lookup-prio-get' should return anything except for the
> priority of subtable lookup implementations?
> 

We think the DPIF, MFEX and DPCLS commands should all provide the same workflow to the user.
By having "subtable-lookup-prio-get" return the list (including "use count" item) allows the get/set
pair of commands to both modify and check the results of setting the DPCLS implementations.
This patch makes the output and workflow the same as DPIF and MFEX.

> That doesn't seem straightforward.  Especially if we'll have that information
> reported in a different place already without need for extra infrastructure.
> 

The "dump-flows" approach provides information between the flow and the subtable implementaiton
which is also useful, however it does not provide the above workflow like DPIF and MFEX. We are willing
to also accept the "dump-flows" approach, but the "subtable lookup prio get" patch/workflow is required.

Regards
Amber

> >
> > Regards
> > Amber
> >> Best regards, Ilya Maximets.
Stokes, Ian May 4, 2022, 3:50 p.m. UTC | #7
> Hi Ilya,
> 
> Please find my replies inline.

Hi all, this patch seems to have hit a wall, I can see there is a v6 that came after this that has been acked: 
http://patchwork.ozlabs.org/project/openvswitch/patch/20220329101724.3148572-1-kumar.amber@intel.com/

I would like to see this work go in, but think we should finish the discussion on this tread before proceeding. My thoughts below on the discussion.

<snip> 

> > > I have already made a POC based on the Discussion above and will put
> > > that patch in few days with the 'dp_extra_info' showing DPCLS as well.
> > >  As for this Patch is also important as currently the get-command doesn’t
> > show much info and hence this improvement will make things clear for the
> > user through the dpcl-get-command.
> > > Hence request this usability feature to be merged.
> > > I will follow this patch with the 'dp_extra_info' showing DPCLS functions
> > next to give absolute clarity to the user.
> >
> > Why the 'subtable-lookup-prio-get' should return anything except for the
> > priority of subtable lookup implementations?
> >
> 
> We think the DPIF, MFEX and DPCLS commands should all provide the same
> workflow to the user.
> By having "subtable-lookup-prio-get" return the list (including "use count" item)
> allows the get/set
> pair of commands to both modify and check the results of setting the DPCLS
> implementations.
> This patch makes the output and workflow the same as DPIF and MFEX.
> 

I agree with the above sentiment. After testing for the past few days with the various DPIF/MEF functions it seems more natural to me to have the required info here in the dpcls command.

I  tried the approach in the POC posted by Amber to provide the info in the flow dump and while this approach could also have the stats info, I felt there was a disconnect in the sense why would this info not be accessible via a dpcls command?

http://patchwork.ozlabs.org/project/openvswitch/patch/20220411131331.597825-1-kumar.amber@intel.com/

In fairness to the folks from both RH and Intel here who have worked on this over the past few months, reviewing the previous revisions, I can see the reasoning for providing this info in this dpcls command and would agree with the approach so would like to see this approach go ahead.

> > That doesn't seem straightforward.  Especially if we'll have that information
> > reported in a different place already without need for extra infrastructure.
> >
> 
> The "dump-flows" approach provides information between the flow and the
> subtable implementaiton
> which is also useful, however it does not provide the above workflow like DPIF
> and MFEX. We are willing
> to also accept the "dump-flows" approach, but the "subtable lookup prio get"
> patch/workflow is required.

+1, we could also include this approach as a separate merge if that makes things more amenable, it might mean some duplication but it would be a fair compromise for end user intuitiveness.

Thanks
Ian

> 
> Regards
> Amber
> 
> > >
> > > Regards
> > > Amber
> > >> Best regards, Ilya Maximets.
>
Stokes, Ian May 10, 2022, 4:16 p.m. UTC | #8
> > Hi Ilya,
> >
> > Please find my replies inline.
> 
> Hi all, this patch seems to have hit a wall, I can see there is a v6 that came after
> this that has been acked:
> http://patchwork.ozlabs.org/project/openvswitch/patch/20220329101724.3148
> 572-1-kumar.amber@intel.com/
> 
> I would like to see this work go in, but think we should finish the discussion on
> this tread before proceeding. My thoughts below on the discussion.

HI All,

Just a ping on this thread, there doesn't seem to be any response since last week, the technical issues seem to have been resolved in the Acked- v6 . Unless there are any further discussion I was going to merge this tomorrow?

Thanks
Ian

> 
> <snip>
> 
> > > > I have already made a POC based on the Discussion above and will put
> > > > that patch in few days with the 'dp_extra_info' showing DPCLS as well.
> > > >  As for this Patch is also important as currently the get-command doesn’t
> > > show much info and hence this improvement will make things clear for the
> > > user through the dpcl-get-command.
> > > > Hence request this usability feature to be merged.
> > > > I will follow this patch with the 'dp_extra_info' showing DPCLS functions
> > > next to give absolute clarity to the user.
> > >
> > > Why the 'subtable-lookup-prio-get' should return anything except for the
> > > priority of subtable lookup implementations?
> > >
> >
> > We think the DPIF, MFEX and DPCLS commands should all provide the same
> > workflow to the user.
> > By having "subtable-lookup-prio-get" return the list (including "use count"
> item)
> > allows the get/set
> > pair of commands to both modify and check the results of setting the DPCLS
> > implementations.
> > This patch makes the output and workflow the same as DPIF and MFEX.
> >
> 
> I agree with the above sentiment. After testing for the past few days with the
> various DPIF/MEF functions it seems more natural to me to have the required
> info here in the dpcls command.
> 
> I  tried the approach in the POC posted by Amber to provide the info in the flow
> dump and while this approach could also have the stats info, I felt there was a
> disconnect in the sense why would this info not be accessible via a dpcls
> command?
> 
> http://patchwork.ozlabs.org/project/openvswitch/patch/20220411131331.5978
> 25-1-kumar.amber@intel.com/
> 
> In fairness to the folks from both RH and Intel here who have worked on this
> over the past few months, reviewing the previous revisions, I can see the
> reasoning for providing this info in this dpcls command and would agree with the
> approach so would like to see this approach go ahead.
> 
> > > That doesn't seem straightforward.  Especially if we'll have that information
> > > reported in a different place already without need for extra infrastructure.
> > >
> >
> > The "dump-flows" approach provides information between the flow and the
> > subtable implementaiton
> > which is also useful, however it does not provide the above workflow like DPIF
> > and MFEX. We are willing
> > to also accept the "dump-flows" approach, but the "subtable lookup prio get"
> > patch/workflow is required.
> 
> +1, we could also include this approach as a separate merge if that makes things
> more amenable, it might mean some duplication but it would be a fair
> compromise for end user intuitiveness.
> 
> Thanks
> Ian
> 
> >
> > Regards
> > Amber
> >
> > > >
> > > > Regards
> > > > Amber
> > > >> Best regards, Ilya Maximets.
> >
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Ilya Maximets May 10, 2022, 10:51 p.m. UTC | #9
On 5/10/22 18:16, Stokes, Ian wrote:
>>> Hi Ilya,
>>>
>>> Please find my replies inline.
>>
>> Hi all, this patch seems to have hit a wall, I can see there is a v6 that came after
>> this that has been acked:
>> http://patchwork.ozlabs.org/project/openvswitch/patch/20220329101724.3148
>> 572-1-kumar.amber@intel.com/
>>
>> I would like to see this work go in, but think we should finish the discussion on
>> this tread before proceeding. My thoughts below on the discussion.
> 
> HI All,
> 
> Just a ping on this thread, there doesn't seem to be any response since last week, the technical issues seem to have been resolved in the Acked- v6 . Unless there are any further discussion I was going to merge this tomorrow?

Hi.  Sorry, got sidetracked by other issues.

I thought we reached the conclusion on this patch during the patch
review meeting a few weeks ago.  We were discussing it with Cian,
not sure if you were there.  And the conclusion was to not have this
patch as it is a duplication of the same info that can be acquired
in a different way.

However, when I had a chance to run a few tests for hashing patches,
I noticed that it is indeed a gap in a user experience.  So, I guess,
it's OK to have this change.  At the same time, I think, if we're
going to accept this change, the subtable-lookup-prio-get command has
to be re-named, because the name will no longer match with the data
this command shows.

For the dp-extra-info, I'm not sure if we need that patch if we're
going to accept the counters.  The reason is the same - duplicated
functionality.  Once introduced, it's hard to get rid of duplicates.
E.g. we still need to do something with pmd-stats-show and
pmd-perf-show.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst
index f645b9ade..63a54da1c 100644
--- a/Documentation/topics/dpdk/bridge.rst
+++ b/Documentation/topics/dpdk/bridge.rst
@@ -156,10 +156,10 @@  OVS provides multiple implementations of dpcls. The following command enables
 the user to check what implementations are available in a running instance ::
 
     $ ovs-appctl dpif-netdev/subtable-lookup-prio-get
-    Available lookup functions (priority : name)
-            0 : autovalidator
-            1 : generic
-            0 : avx512_gather
+    Available dpcls implementations:
+            autovalidator (Use count: 1, Priority: 5)
+            generic (Use count: 0, Priority: 1)
+            avx512_gather (Use count: 0, Priority: 3)
 
 To set the priority of a lookup function, run the ``prio-set`` command ::
 
@@ -172,10 +172,10 @@  function due to the command being run. To verify the prioritization, re-run the
 get command, note the updated priority of the ``avx512_gather`` function ::
 
     $ ovs-appctl dpif-netdev/subtable-lookup-prio-get
-    Available lookup functions (priority : name)
-            0 : autovalidator
-            1 : generic
-            5 : avx512_gather
+    Available dpcls implementations:
+            autovalidator (Use count: 0, Priority: 0)
+            generic (Use count: 0, Priority: 0)
+            avx512_gather (Use count: 1, Priority: 5)
 
 If two lookup functions have the same priority, the first one in the list is
 chosen, and the 2nd occurance of that priority is not used. Put in logical
diff --git a/lib/dpif-netdev-lookup.c b/lib/dpif-netdev-lookup.c
index bd0a99abe..e641e4028 100644
--- a/lib/dpif-netdev-lookup.c
+++ b/lib/dpif-netdev-lookup.c
@@ -36,18 +36,21 @@  static struct dpcls_subtable_lookup_info_t subtable_lookups[] = {
     { .prio = 0,
 #endif
       .probe = dpcls_subtable_autovalidator_probe,
-      .name = "autovalidator", },
+      .name = "autovalidator",
+      .usage_cnt = ATOMIC_COUNT_INIT(0), },
 
     /* The default scalar C code implementation. */
     { .prio = 1,
       .probe = dpcls_subtable_generic_probe,
-      .name = "generic", },
+      .name = "generic",
+      .usage_cnt = ATOMIC_COUNT_INIT(0), },
 
 #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
     /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */
     { .prio = 0,
       .probe = dpcls_subtable_avx512_gather_probe,
-      .name = "avx512_gather", },
+      .name = "avx512_gather",
+      .usage_cnt = ATOMIC_COUNT_INIT(0), },
 #else
     /* Disabling AVX512 at compile time, as compile time requirements not met.
      * This could be due to a number of reasons:
@@ -64,7 +67,7 @@  static struct dpcls_subtable_lookup_info_t subtable_lookups[] = {
 #endif
 };
 
-int32_t
+int
 dpcls_subtable_lookup_info_get(struct dpcls_subtable_lookup_info_t **out_ptr)
 {
     if (out_ptr == NULL) {
@@ -76,7 +79,7 @@  dpcls_subtable_lookup_info_get(struct dpcls_subtable_lookup_info_t **out_ptr)
 }
 
 /* sets the priority of the lookup function with "name". */
-int32_t
+int
 dpcls_subtable_set_prio(const char *name, uint8_t priority)
 {
     for (int i = 0; i < ARRAY_SIZE(subtable_lookups); i++) {
@@ -93,32 +96,81 @@  dpcls_subtable_set_prio(const char *name, uint8_t priority)
 }
 
 dpcls_subtable_lookup_func
-dpcls_subtable_get_best_impl(uint32_t u0_bit_count, uint32_t u1_bit_count)
+dpcls_subtable_get_best_impl(uint32_t u0_bit_count, uint32_t u1_bit_count,
+                             struct dpcls_subtable_lookup_info_t **info)
 {
-    /* Iter over each subtable impl, and get highest priority one. */
-    int32_t prio = -1;
-    const char *name = NULL;
+    struct dpcls_subtable_lookup_info_t *best_info = NULL;
     dpcls_subtable_lookup_func best_func = NULL;
+    int prio = -1;
 
+    /* Iter over each subtable impl, and get highest priority one. */
     for (int i = 0; i < ARRAY_SIZE(subtable_lookups); i++) {
-        int32_t probed_prio = subtable_lookups[i].prio;
-        if (probed_prio > prio) {
-            dpcls_subtable_lookup_func probed_func;
-            probed_func = subtable_lookups[i].probe(u0_bit_count,
-                                    u1_bit_count);
-            if (probed_func) {
-                best_func = probed_func;
-                prio = probed_prio;
-                name = subtable_lookups[i].name;
-            }
+        struct dpcls_subtable_lookup_info_t *impl_info = &subtable_lookups[i];
+        dpcls_subtable_lookup_func probed_func;
+
+        if (impl_info->prio <= prio) {
+            continue;
         }
-    }
 
-    VLOG_DBG("Subtable lookup function '%s' with units (%d,%d), priority %d\n",
-             name, u0_bit_count, u1_bit_count, prio);
+        probed_func = subtable_lookups[i].probe(u0_bit_count,
+                                                u1_bit_count);
+        if (!probed_func) {
+            continue;
+        }
+
+        best_func = probed_func;
+        best_info = impl_info;
+        prio = impl_info->prio;
+    }
 
     /* Programming error - we must always return a valid func ptr. */
-    ovs_assert(best_func != NULL);
+    ovs_assert(best_func != NULL && best_info != NULL);
 
+    VLOG_DBG("Subtable lookup function '%s' with units (%d,%d), priority %d\n",
+             best_info->name, u0_bit_count, u1_bit_count, prio);
+
+    if (info) {
+        *info = best_info;
+    }
     return best_func;
 }
+
+void
+dpcls_info_inc_usage(struct dpcls_subtable_lookup_info_t *info)
+{
+    if (info) {
+        atomic_count_inc(&info->usage_cnt);
+    }
+}
+
+void
+dpcls_info_dec_usage(struct dpcls_subtable_lookup_info_t *info)
+{
+    if (info) {
+        atomic_count_dec(&info->usage_cnt);
+    }
+}
+
+void
+dpcls_impl_print_stats(struct ds *reply)
+{
+    struct dpcls_subtable_lookup_info_t *lookup_funcs = NULL;
+    int count = dpcls_subtable_lookup_info_get(&lookup_funcs);
+
+    /* Add all DPCLS functions to reply string. */
+    ds_put_cstr(reply, "Available dpcls implementations:\n");
+
+    for (int i = 0; i < count; i++) {
+        ds_put_format(reply, "  %s (Use count: %d, Priority: %d",
+                      lookup_funcs[i].name,
+                      atomic_count_get(&lookup_funcs[i].usage_cnt),
+                      lookup_funcs[i].prio);
+
+        if (ds_last(reply) == ' ') {
+            ds_put_cstr(reply, "none");
+        }
+
+        ds_put_cstr(reply, ")\n");
+    }
+
+}
diff --git a/lib/dpif-netdev-lookup.h b/lib/dpif-netdev-lookup.h
index 59f51faa0..7f124a46e 100644
--- a/lib/dpif-netdev-lookup.h
+++ b/lib/dpif-netdev-lookup.h
@@ -20,6 +20,7 @@ 
 #include <config.h>
 #include "dpif-netdev.h"
 #include "dpif-netdev-private-dpcls.h"
+#include "dpif-netdev-private-thread.h"
 
 /* Function to perform a probe for the subtable bit fingerprint.
  * Returns NULL if not valid, or a valid function pointer to call for this
@@ -62,18 +63,29 @@  struct dpcls_subtable_lookup_info_t {
 
     /* Human readable name, used in setting subtable priority commands */
     const char *name;
+
+    /* Counter which holds the usage count of each implementations. */
+    atomic_count usage_cnt;
 };
 
-int32_t dpcls_subtable_set_prio(const char *name, uint8_t priority);
+int dpcls_subtable_set_prio(const char *name, uint8_t priority);
+void dpcls_info_inc_usage(struct dpcls_subtable_lookup_info_t *info);
+void dpcls_info_dec_usage(struct dpcls_subtable_lookup_info_t *info);
 
+/* Lookup the best subtable lookup implementation for the given u0,u1 count. */
 dpcls_subtable_lookup_func
-dpcls_subtable_get_best_impl(uint32_t u0_bit_count, uint32_t u1_bit_count);
+dpcls_subtable_get_best_impl(uint32_t u0_bit_count, uint32_t u1_bit_count,
+                             struct dpcls_subtable_lookup_info_t **info);
 
 /* Retrieve the array of lookup implementations for iteration.
  * On error, returns a negative number.
  * On success, returns the size of the arrays pointed to by the out parameter.
  */
-int32_t
+int
 dpcls_subtable_lookup_info_get(struct dpcls_subtable_lookup_info_t **out_ptr);
 
+/* Prints dpcls subtables in use for different implementations. */
+void
+dpcls_impl_print_stats(struct ds *reply);
+
 #endif /* dpif-netdev-lookup.h */
diff --git a/lib/dpif-netdev-private-dpcls.h b/lib/dpif-netdev-private-dpcls.h
index 7c4a840cb..06e896bef 100644
--- a/lib/dpif-netdev-private-dpcls.h
+++ b/lib/dpif-netdev-private-dpcls.h
@@ -85,6 +85,7 @@  struct dpcls_subtable {
      * used for the lookup) then this can point at an optimized version of
      * the lookup function for this particular subtable. */
     dpcls_subtable_lookup_func lookup_func;
+    struct dpcls_subtable_lookup_info_t *lookup_func_info;
 
     /* Caches the masks to match a packet to, reducing runtime calculations. */
     uint64_t *mf_masks;
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a790df5fd..f55fd08ff 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -912,21 +912,9 @@  dpif_netdev_subtable_lookup_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
                                 const char *argv[] OVS_UNUSED,
                                 void *aux OVS_UNUSED)
 {
-    /* Get a list of all lookup functions. */
-    struct dpcls_subtable_lookup_info_t *lookup_funcs = NULL;
-    int32_t count = dpcls_subtable_lookup_info_get(&lookup_funcs);
-    if (count < 0) {
-        unixctl_command_reply_error(conn, "error getting lookup names");
-        return;
-    }
-
-    /* Add all lookup functions to reply string. */
     struct ds reply = DS_EMPTY_INITIALIZER;
-    ds_put_cstr(&reply, "Available lookup functions (priority : name)\n");
-    for (int i = 0; i < count; i++) {
-        ds_put_format(&reply, "  %d : %s\n", lookup_funcs[i].prio,
-                      lookup_funcs[i].name);
-    }
+
+    dpcls_impl_print_stats(&reply);
     unixctl_command_reply(conn, ds_cstr(&reply));
     ds_destroy(&reply);
 }
@@ -8972,6 +8960,7 @@  dpcls_destroy_subtable(struct dpcls *cls, struct dpcls_subtable *subtable)
     pvector_remove(&cls->subtables, subtable);
     cmap_remove(&cls->subtables_map, &subtable->cmap_node,
                 subtable->mask.hash);
+    dpcls_info_dec_usage(subtable->lookup_func_info);
     ovsrcu_postpone(dpcls_subtable_destroy_cb, subtable);
 }
 
@@ -9019,7 +9008,9 @@  dpcls_create_subtable(struct dpcls *cls, const struct netdev_flow_key *mask)
      * The function is guaranteed to always return a valid implementation, and
      * possibly an ISA optimized, and/or specialized implementation.
      */
-    subtable->lookup_func = dpcls_subtable_get_best_impl(unit0, unit1);
+    subtable->lookup_func = dpcls_subtable_get_best_impl(
+        unit0, unit1, &subtable->lookup_func_info);
+    dpcls_info_inc_usage(subtable->lookup_func_info);
 
     cmap_insert(&cls->subtables_map, &subtable->cmap_node, mask->hash);
     /* Add the new subtable at the end of the pvector (with no hits yet) */
@@ -9060,8 +9051,22 @@  dpcls_subtable_lookup_reprobe(struct dpcls *cls)
         uint32_t u0_bits = subtable->mf_bits_set_unit0;
         uint32_t u1_bits = subtable->mf_bits_set_unit1;
         void *old_func = subtable->lookup_func;
-        subtable->lookup_func = dpcls_subtable_get_best_impl(u0_bits, u1_bits);
-        subtables_changed += (old_func != subtable->lookup_func);
+        struct dpcls_subtable_lookup_info_t *old_info;
+
+        old_info = subtable->lookup_func_info;
+        subtable->lookup_func = dpcls_subtable_get_best_impl(
+            u0_bits, u1_bits, &subtable->lookup_func_info);
+
+        if (old_func != subtable->lookup_func) {
+            subtables_changed += 1;
+        }
+
+        if (old_info != subtable->lookup_func_info) {
+            /* In theory, functions can be shared between implementations, so
+             * do an explicit check on the function info structures. */
+            dpcls_info_dec_usage(old_info);
+            dpcls_info_inc_usage(subtable->lookup_func_info);
+        }
     }
     pvector_publish(pvec);
 
diff --git a/tests/pmd.at b/tests/pmd.at
index c875a744f..e61bb27d3 100644
--- a/tests/pmd.at
+++ b/tests/pmd.at
@@ -1091,11 +1091,11 @@  AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd])
 
 AT_CHECK([ovs-vsctl show], [], [stdout])
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep generic], [], [dnl
-  1 : generic
+  generic (Use count: 0, Priority: 1)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep autovalidator], [], [dnl
-  0 : autovalidator
+  autovalidator (Use count: 0, Priority: 0)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set autovalidator 3], [0], [dnl
@@ -1103,7 +1103,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep autovalidator], [], [dnl
-  3 : autovalidator
+  autovalidator (Use count: 0, Priority: 3)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set generic 4], [0], [dnl
@@ -1111,7 +1111,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep generic], [], [dnl
-  4 : generic
+  generic (Use count: 0, Priority: 4)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set generic 8], [0], [dnl
@@ -1119,7 +1119,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep generic], [], [dnl
-  8 : generic
+  generic (Use count: 0, Priority: 8)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set autovalidator 8], [0], [dnl
@@ -1127,7 +1127,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep autovalidator], [], [dnl
-  8 : autovalidator
+  autovalidator (Use count: 0, Priority: 8)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set generic 0], [0], [dnl
@@ -1135,7 +1135,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep generic], [], [dnl
-  0 : generic
+  generic (Use count: 0, Priority: 0)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set generic 255], [0], [dnl
@@ -1143,7 +1143,7 @@  Lookup priority change affected 0 dpcls ports and 0 subtables.
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-get | grep generic], [], [dnl
-  255 : generic
+  generic (Use count: 0, Priority: 255)
 ])
 
 AT_CHECK([ovs-appctl dpif-netdev/subtable-lookup-prio-set generic -1], [2],