Re: [PATCH 2/4] gdth: reuse dma coherent allocation in gdth_show_info

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

 



On Thu, 18 Oct 2018, Christoph Hellwig wrote:

> gdth_show_info currently allocs and frees a dma buffer four times,
> which isn't very efficient. Reuse a single allocation instead.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  drivers/scsi/gdth_proc.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
> index 3a9751a80225..63d851398e38 100644
> --- a/drivers/scsi/gdth_proc.c
> +++ b/drivers/scsi/gdth_proc.c
> @@ -226,11 +226,13 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>  #endif
>  
>      if (ha->more_proc) {
> +        size_t size = max(GDTH_SCRATCH, sizeof(gdth_hget_str));
> +
>          /* more information: 2. about physical devices */
>          seq_puts(m, "\nPhysical Devices:");
>          flag = FALSE;
>              
> -        buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
> +        buf = gdth_ioctl_alloc(ha, size, FALSE, &paddr);
>          if (!buf) 
>              goto stop_output;
>          for (i = 0; i < ha->bus_cnt; ++i) {
> @@ -323,7 +325,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>                  }
>              }
>          }
> -        gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
>  
>          if (!flag)
>              seq_puts(m, "\n --\n");
> @@ -332,7 +333,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>          seq_puts(m, "\nLogical Drives:");
>          flag = FALSE;
>  
> -        buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
>          if (!buf) 
>              goto stop_output;

I think this !buf test is redundant.

-- 

>          for (i = 0; i < MAX_LDRIVES; ++i) {
> @@ -408,7 +408,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>              seq_printf(m,
>                             " To Array Drv.:\t%s\n", hrec);
>          }       
> -        gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
>          
>          if (!flag)
>              seq_puts(m, "\n --\n");
> @@ -417,9 +416,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>          seq_puts(m, "\nArray Drives:");
>          flag = FALSE;
>  
> -        buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
> -        if (!buf) 
> -            goto stop_output;
>          for (i = 0; i < MAX_LDRIVES; ++i) {
>              if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
>                  continue;
> @@ -468,8 +464,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>                                 hrec);
>              }
>          }
> -        gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
> -        
> +
>          if (!flag)
>              seq_puts(m, "\n --\n");
>  
> @@ -477,9 +472,6 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>          seq_puts(m, "\nHost Drives:");
>          flag = FALSE;
>  
> -        buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
> -        if (!buf) 
> -            goto stop_output;
>          for (i = 0; i < MAX_LDRIVES; ++i) {
>              if (!ha->hdr[i].is_logdrv || 
>                  (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
> @@ -510,7 +502,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
>                  }
>              }
>          }
> -        gdth_ioctl_free(ha, sizeof(gdth_hget_str), buf, paddr);
> +        gdth_ioctl_free(ha, size, buf, paddr);
>  
>          for (i = 0; i < MAX_HDRIVES; ++i) {
>              if (!(ha->hdr[i].present))
> 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux