lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YVRbu37xbRgEXTlX@unreal>
Date:   Wed, 29 Sep 2021 15:27:39 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     Doug Ledford <dledford@...hat.com>,
        Aharon Landau <aharonl@...dia.com>,
        "David S. Miller" <davem@...emloft.net>,
        Dennis Dalessandro <dennis.dalessandro@...nelisnetworks.com>,
        Gal Pressman <galpress@...zon.com>,
        Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org,
        linux-rdma@...r.kernel.org, Maor Gottlieb <maorg@...dia.com>,
        Mark Zhang <markzhang@...dia.com>,
        Mike Marciniszyn <mike.marciniszyn@...nelisnetworks.com>,
        Mustafa Ismail <mustafa.ismail@...el.com>,
        Naresh Kumar PBS <nareshkumar.pbs@...adcom.com>,
        Neta Ostrovsky <netao@...dia.com>, netdev@...r.kernel.org,
        Potnuri Bharat Teja <bharat@...lsio.com>,
        Saeed Mahameed <saeedm@...dia.com>,
        Selvin Xavier <selvin.xavier@...adcom.com>,
        Shiraz Saleem <shiraz.saleem@...el.com>,
        Yishai Hadas <yishaih@...dia.com>,
        Zhu Yanjun <zyjzyj2000@...il.com>
Subject: Re: [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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ