Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Dec 2017 04:29:12 +0000
From:      Colin Percival <cperciva@tarsnap.com>
To:        Hans Petter Selasky <hselasky@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r325841 - in head/sys: conf dev/mlx4 dev/mlx4/mlx4_core dev/mlx4/mlx4_en dev/mlx4/mlx4_ib modules/mlx4
Message-ID:  <0100016067e1fe89-1a2d8c5d-b7c3-4abd-80a2-e9fd781bc8c7-000000@email.amazonses.com>
In-Reply-To: <201711151114.vAFBEeUb015030@repo.freebsd.org>
References:  <201711151114.vAFBEeUb015030@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/15/17 03:14, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Wed Nov 15 11:14:39 2017
> New Revision: 325841
> URL: https://svnweb.freebsd.org/changeset/base/325841
> 
> Log:
>   Update the mlx4 core and mlx4en(4) modules towards Linux v4.9.

sys/dev/mlx4/mlx4_core/mlx4_main.c, around line 1170:
> +static ssize_t set_port_type(struct device *dev,
> +			     struct device_attribute *attr,
> +			     const char *buf, size_t count)
> +{
> +	struct mlx4_port_info *info = container_of(attr, struct mlx4_port_info,
> +						   port_attr);
> +	struct mlx4_dev *mdev = info->dev;
> +	enum mlx4_port_type port_type;
> +	static DEFINE_MUTEX(set_port_type_mutex);

I'm not sure this is what you meant to do.  In particular, DEFINE_MUTEX uses
SX_SYSINIT_FLAGS, which creates a SYSINIT and a SYSUNINIT to initialize and
destroy the mutex -- meaning that it's being accessed from outside of the
function scope.  This seems to work because function-scope static variables
are compiled as if they have file scope, but I'm not at all convinced that
it's legal C.

Also, it breaks some work I have in progress for instrumenting SYSINITs.
Would you mind moving the DEFINE_MUTEX line to occur immediately prior to
the set_port_type function, rather than being placed inside it?

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0100016067e1fe89-1a2d8c5d-b7c3-4abd-80a2-e9fd781bc8c7-000000>