diff mbox series

[ovs-dev,RESEND,v2,2/3] dpif-netdev: Add the burst size to buckets.

Message ID 20210224122150.57551-3-xiangxia.m.yue@gmail.com
State Changes Requested
Headers show
Series dpif-netdev meter overflow fixes | expand

Commit Message

Tonghao Zhang Feb. 24, 2021, 12:21 p.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

For now, the meter of the userspace datapath, don't include
the bucket burst size to buckets. This patch includes it now.

$ ovs-ofctl -O OpenFlow13 add-meter br0 \
	'meter=1 pktps burst stats bands=type=drop rate=10000 burst_size=2000'

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/dpif-netdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Ilya Maximets Feb. 25, 2021, 8:32 p.m. UTC | #1
On 2/24/21 1:21 PM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> For now, the meter of the userspace datapath, don't include
> the bucket burst size to buckets.

Well, it was used before the patch 1/3 of this series. :)
The problem seems to be that 'rate' was not used for bucket calculation.

And yes, despite the fact that burst_size was in use before the
patch 1/3 it was used in a very strange way.
You will, probably, want to squash this particular change into the
patch #2 that I suggested to split out from the patch 1/3.

Best regards, Ilya Maximets.

> This patch includes it now.
> 
> $ ovs-ofctl -O OpenFlow13 add-meter br0 \
> 	'meter=1 pktps burst stats bands=type=drop rate=10000 burst_size=2000'
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  lib/dpif-netdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 614f6fef6b77..94632b85b375 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -6209,7 +6209,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
>  
>          band = &meter->bands[m];
>          /* Update band's bucket. */
> -        max_bucket_size = band->rate * 1000ULL;
> +        max_bucket_size = (band->burst_size + band->rate) * 1000ULL;
>          band->bucket += (uint64_t)delta_t * band->rate;
>          if (band->bucket > max_bucket_size) {
>              band->bucket = max_bucket_size;
> @@ -6332,7 +6332,8 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id meter_id,
>          meter->bands[i].rate = config->bands[i].rate;
>          meter->bands[i].burst_size = config->bands[i].burst_size;
>          /* Start with a full bucket. */
> -        meter->bands[i].bucket = meter->bands[i].rate * 1000ULL;
> +        meter->bands[i].bucket =
> +            (meter->bands[i].burst_size + meter->bands[i].rate) * 1000ULL;
>  
>          /* Figure out max delta_t that is enough to fill any bucket. */
>          band_max_delta_t
>
Tonghao Zhang March 2, 2021, 1:35 p.m. UTC | #2
On Fri, Feb 26, 2021 at 4:32 AM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> On 2/24/21 1:21 PM, xiangxia.m.yue@gmail.com wrote:
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > For now, the meter of the userspace datapath, don't include
> > the bucket burst size to buckets.
>
> Well, it was used before the patch 1/3 of this series. :)
> The problem seems to be that 'rate' was not used for bucket calculation.
>
> And yes, despite the fact that burst_size was in use before the
> patch 1/3 it was used in a very strange way.
> You will, probably, want to squash this particular change into the
> patch #2 that I suggested to split out from the patch 1/3.
Ok
patch 1, fix the meter overflow
patch 2: refactor the buckets calculation
patch 3: add burst_size to buckets
patch 4: don't set burst_size to rate if burst_size not specified.(if
not any comment)

and every patch will update the test case.

> Best regards, Ilya Maximets.
>
> > This patch includes it now.
> >
> > $ ovs-ofctl -O OpenFlow13 add-meter br0 \
> >       'meter=1 pktps burst stats bands=type=drop rate=10000 burst_size=2000'
> >
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > ---
> >  lib/dpif-netdev.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> > index 614f6fef6b77..94632b85b375 100644
> > --- a/lib/dpif-netdev.c
> > +++ b/lib/dpif-netdev.c
> > @@ -6209,7 +6209,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
> >
> >          band = &meter->bands[m];
> >          /* Update band's bucket. */
> > -        max_bucket_size = band->rate * 1000ULL;
> > +        max_bucket_size = (band->burst_size + band->rate) * 1000ULL;
> >          band->bucket += (uint64_t)delta_t * band->rate;
> >          if (band->bucket > max_bucket_size) {
> >              band->bucket = max_bucket_size;
> > @@ -6332,7 +6332,8 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id meter_id,
> >          meter->bands[i].rate = config->bands[i].rate;
> >          meter->bands[i].burst_size = config->bands[i].burst_size;
> >          /* Start with a full bucket. */
> > -        meter->bands[i].bucket = meter->bands[i].rate * 1000ULL;
> > +        meter->bands[i].bucket =
> > +            (meter->bands[i].burst_size + meter->bands[i].rate) * 1000ULL;
> >
> >          /* Figure out max delta_t that is enough to fill any bucket. */
> >          band_max_delta_t
> >
>
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 614f6fef6b77..94632b85b375 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -6209,7 +6209,7 @@  dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
 
         band = &meter->bands[m];
         /* Update band's bucket. */
-        max_bucket_size = band->rate * 1000ULL;
+        max_bucket_size = (band->burst_size + band->rate) * 1000ULL;
         band->bucket += (uint64_t)delta_t * band->rate;
         if (band->bucket > max_bucket_size) {
             band->bucket = max_bucket_size;
@@ -6332,7 +6332,8 @@  dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id meter_id,
         meter->bands[i].rate = config->bands[i].rate;
         meter->bands[i].burst_size = config->bands[i].burst_size;
         /* Start with a full bucket. */
-        meter->bands[i].bucket = meter->bands[i].rate * 1000ULL;
+        meter->bands[i].bucket =
+            (meter->bands[i].burst_size + meter->bands[i].rate) * 1000ULL;
 
         /* Figure out max delta_t that is enough to fill any bucket. */
         band_max_delta_t