From: Tao Liu <thomas.liu@ucloud.cn>
To: Leon Romanovsky <leonro@nvidia.com>
Cc: linux-rdma@vger.kernel.org, saeedm@nvidia.com, talgi@nvidia.com,
mgurtovoy@nvidia.com, jgg@nvidia.com, yaminf@nvidia.com
Subject: Re: [PATCH RFC net] linux/dim: Fix divide 0 in RDMA DIM.
Date: Mon, 27 Jun 2022 18:23:03 +0800 [thread overview]
Message-ID: <YrmFB2sNH8p/CqVU@FVFF87CCQ6LR.local> (raw)
In-Reply-To: <Yrlw+j8dnvCUVa1y@unreal>
On Mon, Jun 27, 2022 at 11:57:30AM +0300, Leon Romanovsky wrote:
> On Mon, Jun 27, 2022 at 04:45:14PM +0800, Tao Liu wrote:
> > On Mon, Jun 27, 2022 at 10:42:02AM +0300, Leon Romanovsky wrote:
> > > On Thu, Jun 23, 2022 at 04:58:58PM +0800, Tao Liu wrote:
> > > > We hit a divide 0 error in ofed 5.1.2.3.7.1. But dim.c and
> > > > rdma_dim.c seem same as upstream.
>
> <...>
>
> > > > Fixes: f4915455dcf0 ("linux/dim: Implement RDMA adaptive moderation (DIM)")
> > > > Signed-off-by: Tao Liu <thomas.liu@ucloud.cn>
> > > > ---
> > > > lib/dim/rdma_dim.c | 3 +++
> > > > 1 file changed, 3 insertions(+)
> > >
> > > I think that this change will be better as it won't change
> > > decision order in rdma_dim_stats_compare()
> > >
> > > diff --git a/include/linux/dim.h b/include/linux/dim.h
> > > index b698266d0035..69ae238ec2dc 100644
> > > --- a/include/linux/dim.h
> > > +++ b/include/linux/dim.h
> > > @@ -21,7 +21,7 @@
> > > * We consider 10% difference as significant.
> > > */
> > > #define IS_SIGNIFICANT_DIFF(val, ref) \
> > > - (((100UL * abs((val) - (ref))) / (ref)) > 10)
> > > + (ref && (((100UL * abs((val) - (ref))) / (ref)) > 10))
> > >
> > > /*
> > > * Calculate the gap between two values.
> > >
> > >
> > Reviewed code in net_dim_stats_compare() and rdma_dim_stats_compare(), the
> > crash point is the only place not covered 0 condition. So it maybe not
> > need to change the macro.
>
> Change in the macro ensures that we check cqe_ratio only when it is
> needed.
>
> Can you please resubmit?
>
Yes, I will. Thanks for your comment.
> Thanks
>
> >
> > But I am not familiar with the algorithm, and not sure what is the right
> > return value.
> > > >
> > > > diff --git a/lib/dim/rdma_dim.c b/lib/dim/rdma_dim.c
> > > > index 15462d54758d..a657b106343c 100644
> > > > --- a/lib/dim/rdma_dim.c
> > > > +++ b/lib/dim/rdma_dim.c
> > > > @@ -34,6 +34,9 @@ static int rdma_dim_stats_compare(struct dim_stats *curr,
> > > > return (curr->cpms > prev->cpms) ? DIM_STATS_BETTER :
> > > > DIM_STATS_WORSE;
> > > >
> > > > + if (!prev->cpe_ratio)
> > > > + return DIM_STATS_SAME;
> > > > +
> > > > if (IS_SIGNIFICANT_DIFF(curr->cpe_ratio, prev->cpe_ratio))
> > > > return (curr->cpe_ratio > prev->cpe_ratio) ? DIM_STATS_BETTER :
> > > > DIM_STATS_WORSE;
> > > > --
> > > > 2.30.1 (Apple Git-130)
> > > >
> > >
>
prev parent reply other threads:[~2022-06-27 10:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-23 8:58 [PATCH RFC net] linux/dim: Fix divide 0 in RDMA DIM Tao Liu
2022-06-27 3:32 ` Tao Liu
2022-06-27 7:42 ` Leon Romanovsky
2022-06-27 8:45 ` Tao Liu
2022-06-27 8:57 ` Leon Romanovsky
2022-06-27 10:23 ` Tao Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YrmFB2sNH8p/CqVU@FVFF87CCQ6LR.local \
--to=thomas.liu@ucloud.cn \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=talgi@nvidia.com \
--cc=yaminf@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox