lkml.org 
[lkml]   [2021]   [Sep]   [27]   [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 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?

Jason

\
 
 \ /
  Last update: 2021-09-27 19:37    [W:0.086 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site