Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573184

Re: [PATCH] mm: extend zero pages to same element pages for zram

From Matthew Wilcox <willy@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] mm: extend zero pages to same element pages for zram
Date 2017-02-03 16:50 +0100
Message-ID <t6Ohz-3Ax-7@gated-at.bofh.it> (permalink)
References <sWynM-7EX-21@gated-at.bofh.it> <t6HJ7-7Js-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Feb 03, 2017 at 04:42:27PM +0800, zhouxianrong@huawei.com wrote:
> +static inline void zram_fill_page_partial(char *ptr, unsigned int size,
> +		unsigned long value)
> +{
> +	int i;
> +	unsigned long *page;
> +
> +	if (likely(value == 0)) {
> +		memset(ptr, 0, size);
> +		return;
> +	}
> +
> +	i = ((unsigned long)ptr) % sizeof(*page);
> +	if (i) {
> +		while (i < sizeof(*page)) {
> +			*ptr++ = (value >> (i * 8)) & 0xff;
> +			--size;
> +			++i;
> +		}
> +	}
> +
> +	for (i = size / sizeof(*page); i > 0; --i) {
> +		page = (unsigned long *)ptr;
> +		*page = value;
> +		ptr += sizeof(*page);
> +		size -= sizeof(*page);
> +	}
> +
> +	for (i = 0; i < size; ++i)
> +		*ptr++ = (value >> (i * 8)) & 0xff;
> +}

You're assuming little-endian here.  I think you need to do a
cpu_to_le() here, but I don't think we have a cpu_to_leul, only
cpu_to_le64/cpu_to_le32.  So you may have some work to do ...

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm: extend zero pages to same element pages for zram <zhouxianrong@huawei.com> - 2017-02-03 09:50 +0100
  Re: [PATCH] mm: extend zero pages to same element pages for zram Matthew Wilcox <willy@infradead.org> - 2017-02-03 16:50 +0100
    Re: [PATCH] mm: extend zero pages to same element pages for zram zhouxianrong <zhouxianrong@huawei.com> - 2017-02-04 04:40 +0100
  Re: [PATCH] mm: extend zero pages to same element pages for zram Minchan Kim <minchan@kernel.org> - 2017-02-05 15:30 +0100
    Re: [PATCH] mm: extend zero pages to same element pages for zram zhouxianrong <zhouxianrong@huawei.com> - 2017-02-06 02:40 +0100
      Re: [PATCH] mm: extend zero pages to same element pages for zram Matthew Wilcox <willy@infradead.org> - 2017-02-06 15:20 +0100
      Re: [PATCH] mm: extend zero pages to same element pages for zram Minchan Kim <minchan@kernel.org> - 2017-02-07 00:50 +0100
        Re: [PATCH] mm: extend zero pages to same element pages for zram zhouxianrong <zhouxianrong@huawei.com> - 2017-02-07 03:30 +0100
          Re: [PATCH] mm: extend zero pages to same element pages for zram Minchan Kim <minchan@kernel.org> - 2017-02-07 04:00 +0100
            Re: [PATCH] mm: extend zero pages to same element pages for zram zhouxianrong <zhouxianrong@huawei.com> - 2017-02-07 04:30 +0100
              Re: [PATCH] mm: extend zero pages to same element pages for zram Minchan Kim <minchan@kernel.org> - 2017-02-07 06:00 +0100

csiph-web