Re: Pagecache zeroing: zero_user_segment, zero_user_segments and zero_user

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

 



On Tue, 15 May 2007 20:00:18 -0700 (PDT) Christoph Lameter <[email protected]> wrote:

> Simplify page cache zeroing of segments of pages through 3 functions
> 
> 
> zero_user_segments(page, start1, end1, start2, end2)
> 
> 	Zeros two segments of the page. It takes the position where to
> 	start and end the zeroing which avoids length calculations.
> 
> zero_user_segment(page, start, end)
> 
> 	Same for a single segment.
> 
> zero_user(page, start, length)
> 
> 	Length variant for the case where we know the length.
> 
> 
> 
> We remove the zero_user_page macro. Issues:
> 
> 1. Its a macro. Inline functions are preferable.
> 
> 2. It has a useless parameter specifying the kmap slot.
>    The functions above default to KM_USER0 which is also always used when
>    zero_user_page was called except in one single case. We open code that
>    single case to draw attention to the spot.
> 

Dunno.  fwiw, we decided to _not_ embed KM_USER0 in the callee: we have had
some pretty ghastly bugs in the past due to misuse of kmap slots so the
idea was to shove the decision into the caller's face, make them think
about what they're doing

> +static inline void zero_user_segments(struct page *page,
> +	unsigned start1, unsigned end1,
> +	unsigned start2, unsigned end2)
> +{
> +	void *kaddr = kmap_atomic(page, KM_USER0);
> +
> +	BUG_ON(end1 > PAGE_SIZE ||
> +		end2 > PAGE_SIZE);
> +
> +	if (end1 > start1)
> +		memset(kaddr + start1, 0, end1 - start1);
> +
> +	if (end2 > start2)
> +		memset(kaddr + start2, 0, end2 - start2);
> +
> +	flush_dcache_page(page);
> +	kunmap_atomic(kaddr, KM_USER0);
> +}

For some reason we've always done the flush_dcache_page() while holding the
kmap.  There's no reason for doing it this way and it just serves to worsen
scheduling latency a tiny bit.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux