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: <063D6719AE5E284EB5DD2968C1650D6DB022A617@AcuExch.aculab.com>
Date:   Mon, 28 Nov 2016 15:28:27 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Tariq Toukan' <tariqt@...lanox.com>,
        "David S. Miller" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Eran Ben Elisha <eranbe@...lanox.com>,
        Tal Alon <talal@...lanox.com>
Subject: RE: [PATCH net-next 06/10] net/mlx4_core: Dynamically allocate
 structs at mlx4_slave_cap

From: Tariq Toukan
> Sent: 27 November 2016 15:51
> From: Eran Ben Elisha <eranbe@...lanox.com>
> 
> In order to avoid temporary large structs on the stack,
> allocate them dynamically.
> 
> Signed-off-by: Eran Ben Elisha <eranbe@...lanox.com>
> Signed-off-by: Tal Alon <talal@...lanox.com>
> Signed-off-by: Tariq Toukan <tariqt@...lanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/main.c | 244 +++++++++++++++++-------------
>  1 file changed, 142 insertions(+), 102 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 4a9497e9778d..65502df9fd96 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -799,40 +799,117 @@ static void slave_adjust_steering_mode(struct mlx4_dev *dev,
...
> +static int mlx4_slave_special_qp_cap(struct mlx4_dev *dev)
> +{
> +	struct mlx4_func_cap *func_cap = NULL;
> +	int i, err = 0;
> +
> +	func_cap = kzalloc(sizeof(*func_cap), GFP_KERNEL);
> +	dev->caps.qp0_qkey = kcalloc(dev->caps.num_ports,
> +				     sizeof(u32), GFP_KERNEL);
> +	dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports,
> +				       sizeof(u32), GFP_KERNEL);
> +	dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports,
> +				      sizeof(u32), GFP_KERNEL);
> +	dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports,
> +				       sizeof(u32), GFP_KERNEL);
> +	dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports,
> +				      sizeof(u32), GFP_KERNEL);
...
It has to be better to allocate a single piece of memory.
Potentially using a structure something like:

struct fubar {
	struct mlx4_func_cap func_cap;
	struct {
		u32	qp0_qkey;
		u32	qp0_tunnel;
		u32	qp0_proxy;
		u32	qp1_tunnel;
		u32	qp1_proxy;
	} port_info[];
};

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ