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: <d9cd401a-b5fe-65ea-21c4-6d4c037fd641@nvidia.com>
Date:   Tue, 28 Sep 2021 17:03:24 +0800
From:   Mark Zhang <markzhang@...dia.com>
To:     Jason Gunthorpe <jgg@...dia.com>, Leon Romanovsky <leon@...nel.org>
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>,
        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 05/11] RDMA/counter: Add optional counter
 support

On 9/28/2021 1:03 AM, Jason Gunthorpe wrote:
> On Wed, Sep 15, 2021 at 02:07:24AM +0300, Leon Romanovsky wrote:
>>   
>> +int rdma_counter_modify(struct ib_device *dev, u32 port, int index, bool enable)
>> +{
>> +	struct rdma_hw_stats *stats;
>> +	int ret;
>> +
>> +	if (!dev->ops.modify_hw_stat)
>> +		return -EOPNOTSUPP;
>> +
>> +	stats = ib_get_hw_stats_port(dev, port);
>> +	if (!stats)
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&stats->lock);
>> +	ret = dev->ops.modify_hw_stat(dev, port, index, enable);
>> +	if (!ret)
>> +		enable ? clear_bit(index, stats->is_disabled) :
>> +			set_bit(index, stats->is_disabled);
> 
> This is not a kernel coding style write out the if, use success
> oriented flow
> 
> Also, shouldn't this logic protect the driver from being called on
> non-optional counters?

We leave it to driver, driver would return failure if modify is not 
supported. Is it good?

>>   	for (i = 0; i < data->stats->num_counters; i++) {
>> -		attr = &data->attrs[i];
>> +		if (data->stats->descs[i].flags & IB_STAT_FLAG_OPTIONAL)
>> +			continue;
>> +		attr = &data->attrs[pos];
>>   		sysfs_attr_init(&attr->attr.attr);
>>   		attr->attr.attr.name = data->stats->descs[i].name;
>>   		attr->attr.attr.mode = 0444;
>>   		attr->attr.show = hw_stat_device_show;
>>   		attr->show = show_hw_stats;
>> -		data->group.attrs[i] = &attr->attr.attr;
>> +		data->group.attrs[pos] = &attr->attr.attr;
>> +		pos++;
>>   	}
> 
> This isn't OK, the hw_stat_device_show() computes the stat index like
> this:
> 
> 	return stat_attr->show(ibdev, ibdev->hw_stats_data->stats,
> 			       stat_attr - ibdev->hw_stats_data->attrs, 0, buf);
> 
> Which assumes the stats are packed contiguously. This only works
> because mlx5 is always putting the optional stats at the end.

Yes you are right, thanks. Maybe we can add an "index" field in struct 
hw_stats_device/port_attribute, then set it in setup and use it in show.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ