lkml.org 
[lkml]   [2021]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH rdma-next v1 07/11] RDMA/nldev: Allow optional-counter status configuration through RDMA netlink
On Mon, Sep 27, 2021 at 02:20:06PM -0300, Jason Gunthorpe wrote:
> On Wed, Sep 15, 2021 at 02:07:26AM +0300, Leon Romanovsky wrote:
> > - return -EINVAL;
> > + need_enable = false;
> > + disabled = test_bit(i, stats->is_disabled);
> > + nla_for_each_nested(entry_attr,
> > + tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], rem) {
> > + index = nla_get_u32(entry_attr);
> > + if (index >= stats->num_counters)
> > + return -EINVAL;
> > + if (i == index) {
> > + need_enable = true;
> > + break;
> > + }
> > + }
> >
> > - port = nla_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
> > - if (!rdma_is_port_valid(device, port)) {
> > - ret = -EINVAL;
> > - goto err;
> > + if (disabled && need_enable)
> > + ret = rdma_counter_modify(device, port, i, true);
> > + else if (!disabled && !need_enable)
> > + ret = rdma_counter_modify(device, port, i, false);
>
> This disabled check looks racy, I would do the no-change optimization inside
> rdma_counter_modify()
>
> Also, this is a O(N^2) algorithm, why not do it in one pass with a
> small memory allocation for the target state bitmap?

We don't have many counters. Is this optimization really worth it?

Thanks

>
> Jason

\
 
 \ /
  Last update: 2021-09-29 14:29    [W:0.049 / U:0.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site