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] [day] [month] [year] [list]
Date:   Fri, 18 Feb 2022 12:35:07 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Oleksij Rempel <o.rempel@...gutronix.de>
Cc:     Woojung Huh <woojung.huh@...rochip.com>,
        UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vivien Didelot <vivien.didelot@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, kernel@...gutronix.de,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/1] net: dsa: microchip: ksz9477: export HW
 stats over stats64 interface

On Fri, Feb 18, 2022 at 09:55:54AM +0100, Oleksij Rempel wrote:
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 7e33ec73f803..16fade9a088b 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -111,6 +111,9 @@ static void ksz_mib_read_work(struct work_struct *work)
>  		port_r_cnt(dev, i);
>  		p->read = false;
>  		mutex_unlock(&mib->cnt_mutex);
> +
> +		if (dev->dev_ops->r_mib_stat64)
> +			dev->dev_ops->r_mib_stat64(dev, i);

Why not call dev->dev_ops->r_mib_stat64() under &mib->cnt_mutex here?
You grab the mutex in that function anyway. It's not a problem if the
&mib->stats64_lock spinlock is a sub-lock of the cnt_mutex. It's only a
problem if you're taking the mutex in the atomic path.

>  	}
>  
>  	schedule_delayed_work(&dev->mib_read, dev->mib_read_interval);
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index 3db63f62f0a1..c6fa487fb006 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
> @@ -22,6 +22,8 @@ struct ksz_port_mib {
>  	struct mutex cnt_mutex;		/* structure access */
>  	u8 cnt_ptr;
>  	u64 *counters;
> +	struct rtnl_link_stats64 stats64;
> +	struct spinlock stats64_lock;
>  };
>  
>  struct ksz_port {
> @@ -128,6 +130,7 @@ struct ksz_dev_ops {
>  			  u64 *cnt);
>  	void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr,
>  			  u64 *dropped, u64 *cnt);
> +	void (*r_mib_stat64)(struct ksz_device *dev, int port);
>  	void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze);
>  	void (*port_init_cnt)(struct ksz_device *dev, int port);
>  	int (*shutdown)(struct ksz_device *dev);
> -- 
> 2.30.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ