Re: [PATCH 1/3] target/configfs: allocate pointers instead of full struct for default_groups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-11-27 at 18:54 +0100, Sebastian Andrzej Siewior wrote:
> default_groups is defined as struct config_group **default_groups so
> we don't need to allocate a whole struct but only enough space for a
> pointer that points there.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/target/iscsi/iscsi_target_configfs.c |    4 ++--
>  drivers/target/target_core_configfs.c        |   16 ++++++++--------
>  drivers/target/target_core_fabric_configfs.c |    6 +++---
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 

Very nice eye to spot this long-standing waste of memory within
virtually every config_group->default_groups[] allocation in device
backend + fabric independent core, and two more in iscsi-target to boot.
Seriously, nice catch Sebastian.

Applied to target-pending/for-next with some minor fuzz against current
for-3.8 code.

I'm tempted to apply this with a CC to stable now, but unfortunately it
will only break at this point given the other changes.  This is a
primate candidate for v3.7.1 code as a separate patch.  :)

Thank you,

--nab

> diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
> index ff6fd4f..7c4243e 100644
> --- a/drivers/target/iscsi/iscsi_target_configfs.c
> +++ b/drivers/target/iscsi/iscsi_target_configfs.c
> @@ -803,7 +803,7 @@ static struct se_node_acl *lio_target_make_nodeacl(
>  	acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
>  	stats_cg = &se_nacl->acl_fabric_stat_group;
>  
> -	stats_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	stats_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!stats_cg->default_groups) {
>  		pr_err("Unable to allocate memory for"
> @@ -1268,7 +1268,7 @@ static struct se_wwn *lio_target_call_coreaddtiqn(
>  	 */
>  	stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
>  
> -	stats_cg->default_groups = kzalloc(sizeof(struct config_group) * 6,
> +	stats_cg->default_groups = kzalloc(sizeof(struct config_group *) * 6,
>  				GFP_KERNEL);
>  	if (!stats_cg->default_groups) {
>  		pr_err("Unable to allocate memory for"
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index c123327..82a5af3 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -2760,7 +2760,7 @@ static struct config_group *target_core_make_subdev(
>  	se_dev->se_dev_hba = hba;
>  	dev_cg = &se_dev->se_dev_group;
>  
> -	dev_cg->default_groups = kzalloc(sizeof(struct config_group) * 7,
> +	dev_cg->default_groups = kzalloc(sizeof(struct config_group *) * 7,
>  			GFP_KERNEL);
>  	if (!dev_cg->default_groups)
>  		goto out;
> @@ -2806,7 +2806,7 @@ static struct config_group *target_core_make_subdev(
>  		goto out;
>  
>  	tg_pt_gp_cg = &se_dev->t10_alua.alua_tg_pt_gps_group;
> -	tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!tg_pt_gp_cg->default_groups) {
>  		pr_err("Unable to allocate tg_pt_gp_cg->"
> @@ -2823,8 +2823,8 @@ static struct config_group *target_core_make_subdev(
>  	 * Add core/$HBA/$DEV/statistics/ default groups
>  	 */
>  	dev_stat_grp = &se_dev->dev_stat_grps.stat_group;
> -	dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 4,
> -				GFP_KERNEL);
> +	dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) *
> +			4, GFP_KERNEL);
>  	if (!dev_stat_grp->default_groups) {
>  		pr_err("Unable to allocate dev_stat_grp->default_groups\n");
>  		goto out;
> @@ -3120,7 +3120,7 @@ static int __init target_core_init_configfs(void)
>  	 * and ALUA Logical Unit Group and Target Port Group infrastructure.
>  	 */
>  	target_cg = &subsys->su_group;
> -	target_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	target_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!target_cg->default_groups) {
>  		pr_err("Unable to allocate target_cg->default_groups\n");
> @@ -3136,7 +3136,7 @@ static int __init target_core_init_configfs(void)
>  	 * Create ALUA infrastructure under /sys/kernel/config/target/core/alua/
>  	 */
>  	hba_cg = &target_core_hbagroup;
> -	hba_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	hba_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!hba_cg->default_groups) {
>  		pr_err("Unable to allocate hba_cg->default_groups\n");
> @@ -3152,7 +3152,7 @@ static int __init target_core_init_configfs(void)
>  	 * groups under /sys/kernel/config/target/core/alua/
>  	 */
>  	alua_cg = &alua_group;
> -	alua_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	alua_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  			GFP_KERNEL);
>  	if (!alua_cg->default_groups) {
>  		pr_err("Unable to allocate alua_cg->default_groups\n");
> @@ -3174,7 +3174,7 @@ static int __init target_core_init_configfs(void)
>  	}
>  
>  	lu_gp_cg = &alua_lu_gps_group;
> -	lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  			GFP_KERNEL);
>  	if (!lu_gp_cg->default_groups) {
>  		pr_err("Unable to allocate lu_gp_cg->default_groups\n");
> diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
> index bca737b..c17d60c 100644
> --- a/drivers/target/target_core_fabric_configfs.c
> +++ b/drivers/target/target_core_fabric_configfs.c
> @@ -358,7 +358,7 @@ static struct config_group *target_fabric_make_mappedlun(
>  	}
>  
>  	lacl_cg = &lacl->se_lun_group;
> -	lacl_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	lacl_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!lacl_cg->default_groups) {
>  		pr_err("Unable to allocate lacl_cg->default_groups\n");
> @@ -374,7 +374,7 @@ static struct config_group *target_fabric_make_mappedlun(
>  	lacl_cg->default_groups[1] = NULL;
>  
>  	ml_stat_grp = &lacl->ml_stat_grps.stat_group;
> -	ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group) * 3,
> +	ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 3,
>  				GFP_KERNEL);
>  	if (!ml_stat_grp->default_groups) {
>  		pr_err("Unable to allocate ml_stat_grp->default_groups\n");
> @@ -869,7 +869,7 @@ static struct config_group *target_fabric_make_lun(
>  		return ERR_PTR(-EINVAL);
>  
>  	lun_cg = &lun->lun_group;
> -	lun_cg->default_groups = kzalloc(sizeof(struct config_group) * 2,
> +	lun_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
>  				GFP_KERNEL);
>  	if (!lun_cg->default_groups) {
>  		pr_err("Unable to allocate lun_cg->default_groups\n");


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux