On 2.12.2013, at 21.00, Bodo Stroesser <bstroes...@ts.fujitsu.com> wrote:

> From: Bodo Stroesser <bstroes...@ts.fujitsu.com>
> Date: Mon, 2 Dec 2013 18:52:10 +0100
> Subject: [PATCH 2/3] st.ko: remove unnecessary normalize_buffer
> 
> This patch removes an unnecessary call to normalize_buffer()
> in enlarge_buffer()
> 
> In st_open() always a buffer of one page is allocated.
> When the buffer needs to be enlarged later, it does not make
> sense to free this page unconditionally.
> 

The original reason for this was to make the function to allocate the minimum 
number of segments for maximum efficiency. In some cases it was essential not 
to waste one segment because that would have made the allocation fail.

Now there is another reason to have this “optimization”. Reading the code you 
probably have noticed that nowadays all segments must have the same size. If 
the first segment is only one page, the first allocation may it may not be 
possible to allocate the buffer using single page segments. This leads to 
freeing the pages and trying again. This is not efficient.

So, I think this fragment of code should not be removed.

Thanks,
Kai

> Cc: Kai Makisara <kai.makis...@kolumbus.fi>
> Signed-off-by: Bodo Stroesser <bstroes...@ts.fujitsu.com>
> 
> ---
> 
> --- a/drivers/scsi/st.c       2013-12-02 18:52:10.000000000 +0100
> +++ b/drivers/scsi/st.c       2013-12-02 18:52:10.000000000 +0100
> @@ -3725,9 +3725,6 @@ static int enlarge_buffer(struct st_buff
>       if (new_size <= STbuffer->buffer_size)
>               return 1;
> 
> -     if (STbuffer->buffer_size <= PAGE_SIZE)
> -             normalize_buffer(STbuffer);  /* Avoid extra segment */
> -
>       max_segs = STbuffer->use_sg;
> 
>       priority = GFP_KERNEL | __GFP_NOWARN;

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

Reply via email to