* [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter @ 2019-02-01 16:07 Eelco Chaudron 2019-02-05 8:40 ` Jens Freimann 2019-02-28 18:50 ` Dumitrescu, Cristian 0 siblings, 2 replies; 5+ messages in thread From: Eelco Chaudron @ 2019-02-01 16:07 UTC (permalink / raw) To: cristian.dumitrescu; +Cc: dev RFC 4115 allows a meter with either cir and/or eir configured. When only one is configured a divide by zero would occur. Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM") Cc: echaudro@redhat.com Signed-off-by: Eelco Chaudron <echaudro@redhat.com> --- v2 - Removed configuration change that got included by accident lib/librte_meter/rte_meter.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h index 005e4eeee..56d85ecf0 100644 --- a/lib/librte_meter/rte_meter.h +++ b/lib/librte_meter/rte_meter.h @@ -597,8 +597,8 @@ rte_meter_trtcm_rfc4115_color_blind_check( /* Bucket update */ time_diff_tc = time - m->time_tc; time_diff_te = time - m->time_te; - n_periods_tc = time_diff_tc / p->cir_period; - n_periods_te = time_diff_te / p->eir_period; + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0; + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0; m->time_tc += n_periods_tc * p->cir_period; m->time_te += n_periods_te * p->eir_period; @@ -641,8 +641,8 @@ rte_meter_trtcm_rfc4115_color_aware_check( /* Bucket update */ time_diff_tc = time - m->time_tc; time_diff_te = time - m->time_te; - n_periods_tc = time_diff_tc / p->cir_period; - n_periods_te = time_diff_te / p->eir_period; + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0; + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0; m->time_tc += n_periods_tc * p->cir_period; m->time_te += n_periods_te * p->eir_period; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter 2019-02-01 16:07 [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron @ 2019-02-05 8:40 ` Jens Freimann 2019-02-28 18:50 ` Dumitrescu, Cristian 1 sibling, 0 replies; 5+ messages in thread From: Jens Freimann @ 2019-02-05 8:40 UTC (permalink / raw) To: Eelco Chaudron; +Cc: cristian.dumitrescu, dev On Fri, Feb 01, 2019 at 04:07:16PM +0000, Eelco Chaudron wrote: >RFC 4115 allows a meter with either cir and/or eir configured. >When only one is configured a divide by zero would occur. > >Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM") >Cc: echaudro@redhat.com > >Signed-off-by: Eelco Chaudron <echaudro@redhat.com> >--- > > v2 - Removed configuration change that got included by accident > > lib/librte_meter/rte_meter.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > Reviewed-by: Jens Freimann <jfreimann@redhat.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter 2019-02-01 16:07 [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron 2019-02-05 8:40 ` Jens Freimann @ 2019-02-28 18:50 ` Dumitrescu, Cristian 2019-03-19 11:00 ` Eelco Chaudron 1 sibling, 1 reply; 5+ messages in thread From: Dumitrescu, Cristian @ 2019-02-28 18:50 UTC (permalink / raw) To: Eelco Chaudron; +Cc: dev Hi Eelco, Sorry for my delayed reply, > -----Original Message----- > From: Eelco Chaudron [mailto:echaudro@redhat.com] > Sent: Friday, February 1, 2019 4:07 PM > To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com> > Cc: dev@dpdk.org > Subject: [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter > > RFC 4115 allows a meter with either cir and/or eir configured. > When only one is configured a divide by zero would occur. > > Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM") > Cc: echaudro@redhat.com > > Signed-off-by: Eelco Chaudron <echaudro@redhat.com> > --- > > v2 - Removed configuration change that got included by accident > > lib/librte_meter/rte_meter.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h > index 005e4eeee..56d85ecf0 100644 > --- a/lib/librte_meter/rte_meter.h > +++ b/lib/librte_meter/rte_meter.h > @@ -597,8 +597,8 @@ rte_meter_trtcm_rfc4115_color_blind_check( > /* Bucket update */ > time_diff_tc = time - m->time_tc; > time_diff_te = time - m->time_te; > - n_periods_tc = time_diff_tc / p->cir_period; > - n_periods_te = time_diff_te / p->eir_period; > + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0; > + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0; > m->time_tc += n_periods_tc * p->cir_period; > m->time_te += n_periods_te * p->eir_period; > > @@ -641,8 +641,8 @@ rte_meter_trtcm_rfc4115_color_aware_check( > /* Bucket update */ > time_diff_tc = time - m->time_tc; > time_diff_te = time - m->time_te; > - n_periods_tc = time_diff_tc / p->cir_period; > - n_periods_te = time_diff_te / p->eir_period; > + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0; > + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0; > m->time_tc += n_periods_tc * p->cir_period; > m->time_te += n_periods_te * p->eir_period; > Yes, this is indeed an issue, good catch! For performance reasons, we'd like to avoid a test on the fast path (rte_meter_xyz_check) and replace it with more work done on the configuration stage (rte_meter_profile_xyz_config), if possible. We can intercept the null CIR or EIR cases very early in rte_meter_trtcm_rfc4115_profile_config() and deal with them separately by setting the CIR/EIR period and bytes_per_period to some neutral values and skipping the call to rte_meter_get_tb_params(): period = RTE_METER_TB_PERIOD_MIN, bytes_per_period = 0. Makes sense? Regards, Cristian ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter 2019-02-28 18:50 ` Dumitrescu, Cristian @ 2019-03-19 11:00 ` Eelco Chaudron 2019-03-19 11:00 ` Eelco Chaudron 0 siblings, 1 reply; 5+ messages in thread From: Eelco Chaudron @ 2019-03-19 11:00 UTC (permalink / raw) To: Dumitrescu, Cristian; +Cc: dev On 28 Feb 2019, at 19:50, Dumitrescu, Cristian wrote: > Hi Eelco, > > Sorry for my delayed reply No problem I was OOO also so hence my late reply ;) >> -----Original Message----- >> From: Eelco Chaudron [mailto:echaudro@redhat.com] >> Sent: Friday, February 1, 2019 4:07 PM >> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com> >> Cc: dev@dpdk.org >> Subject: [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 >> meter >> >> RFC 4115 allows a meter with either cir and/or eir configured. >> When only one is configured a divide by zero would occur. >> >> Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM") >> Cc: echaudro@redhat.com >> >> Signed-off-by: Eelco Chaudron <echaudro@redhat.com> >> --- >> >> v2 - Removed configuration change that got included by accident >> >> lib/librte_meter/rte_meter.h | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/lib/librte_meter/rte_meter.h >> b/lib/librte_meter/rte_meter.h >> index 005e4eeee..56d85ecf0 100644 >> --- a/lib/librte_meter/rte_meter.h >> +++ b/lib/librte_meter/rte_meter.h >> @@ -597,8 +597,8 @@ rte_meter_trtcm_rfc4115_color_blind_check( >> /* Bucket update */ >> time_diff_tc = time - m->time_tc; >> time_diff_te = time - m->time_te; >> - n_periods_tc = time_diff_tc / p->cir_period; >> - n_periods_te = time_diff_te / p->eir_period; >> + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : >> 0; >> + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : >> 0; >> m->time_tc += n_periods_tc * p->cir_period; >> m->time_te += n_periods_te * p->eir_period; >> >> @@ -641,8 +641,8 @@ rte_meter_trtcm_rfc4115_color_aware_check( >> /* Bucket update */ >> time_diff_tc = time - m->time_tc; >> time_diff_te = time - m->time_te; >> - n_periods_tc = time_diff_tc / p->cir_period; >> - n_periods_te = time_diff_te / p->eir_period; >> + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : >> 0; >> + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : >> 0; >> m->time_tc += n_periods_tc * p->cir_period; >> m->time_te += n_periods_te * p->eir_period; >> > > Yes, this is indeed an issue, good catch! > > For performance reasons, we'd like to avoid a test on the fast path > (rte_meter_xyz_check) and replace it with more work done on the > configuration stage (rte_meter_profile_xyz_config), if possible. > > We can intercept the null CIR or EIR cases very early in > rte_meter_trtcm_rfc4115_profile_config() and deal with them separately > by setting the CIR/EIR period and bytes_per_period to some neutral > values and skipping the call to rte_meter_get_tb_params(): period = > RTE_METER_TB_PERIOD_MIN, bytes_per_period = 0. Excellent idea, will sent out a v3 soon, after some testing… //Eelco ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter 2019-03-19 11:00 ` Eelco Chaudron @ 2019-03-19 11:00 ` Eelco Chaudron 0 siblings, 0 replies; 5+ messages in thread From: Eelco Chaudron @ 2019-03-19 11:00 UTC (permalink / raw) To: Dumitrescu, Cristian; +Cc: dev On 28 Feb 2019, at 19:50, Dumitrescu, Cristian wrote: > Hi Eelco, > > Sorry for my delayed reply No problem I was OOO also so hence my late reply ;) >> -----Original Message----- >> From: Eelco Chaudron [mailto:echaudro@redhat.com] >> Sent: Friday, February 1, 2019 4:07 PM >> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com> >> Cc: dev@dpdk.org >> Subject: [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 >> meter >> >> RFC 4115 allows a meter with either cir and/or eir configured. >> When only one is configured a divide by zero would occur. >> >> Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM") >> Cc: echaudro@redhat.com >> >> Signed-off-by: Eelco Chaudron <echaudro@redhat.com> >> --- >> >> v2 - Removed configuration change that got included by accident >> >> lib/librte_meter/rte_meter.h | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/lib/librte_meter/rte_meter.h >> b/lib/librte_meter/rte_meter.h >> index 005e4eeee..56d85ecf0 100644 >> --- a/lib/librte_meter/rte_meter.h >> +++ b/lib/librte_meter/rte_meter.h >> @@ -597,8 +597,8 @@ rte_meter_trtcm_rfc4115_color_blind_check( >> /* Bucket update */ >> time_diff_tc = time - m->time_tc; >> time_diff_te = time - m->time_te; >> - n_periods_tc = time_diff_tc / p->cir_period; >> - n_periods_te = time_diff_te / p->eir_period; >> + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : >> 0; >> + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : >> 0; >> m->time_tc += n_periods_tc * p->cir_period; >> m->time_te += n_periods_te * p->eir_period; >> >> @@ -641,8 +641,8 @@ rte_meter_trtcm_rfc4115_color_aware_check( >> /* Bucket update */ >> time_diff_tc = time - m->time_tc; >> time_diff_te = time - m->time_te; >> - n_periods_tc = time_diff_tc / p->cir_period; >> - n_periods_te = time_diff_te / p->eir_period; >> + n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : >> 0; >> + n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : >> 0; >> m->time_tc += n_periods_tc * p->cir_period; >> m->time_te += n_periods_te * p->eir_period; >> > > Yes, this is indeed an issue, good catch! > > For performance reasons, we'd like to avoid a test on the fast path > (rte_meter_xyz_check) and replace it with more work done on the > configuration stage (rte_meter_profile_xyz_config), if possible. > > We can intercept the null CIR or EIR cases very early in > rte_meter_trtcm_rfc4115_profile_config() and deal with them separately > by setting the CIR/EIR period and bytes_per_period to some neutral > values and skipping the call to rte_meter_get_tb_params(): period = > RTE_METER_TB_PERIOD_MIN, bytes_per_period = 0. Excellent idea, will sent out a v3 soon, after some testing… //Eelco ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-03-19 11:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-02-01 16:07 [dpdk-dev] [PATCH v2] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron 2019-02-05 8:40 ` Jens Freimann 2019-02-28 18:50 ` Dumitrescu, Cristian 2019-03-19 11:00 ` Eelco Chaudron 2019-03-19 11:00 ` Eelco Chaudron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).