From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751200AbdBCPt0 (ORCPT ); Fri, 3 Feb 2017 10:49:26 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52231 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbdBCPtV (ORCPT ); Fri, 3 Feb 2017 10:49:21 -0500 Date: Fri, 3 Feb 2017 07:33:50 -0800 From: Matthew Wilcox To: zhouxianrong@huawei.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sergey.senozhatsky@gmail.com, minchan@kernel.org, iamjoonsoo.kim@lge.com, ngupta@vflare.org, Mi.Sophia.Wang@huawei.com, zhouxiyu@huawei.com, weidu.du@huawei.com, zhangshiming5@huawei.com, won.ho.park@huawei.com Subject: Re: [PATCH] mm: extend zero pages to same element pages for zram Message-ID: <20170203153350.GC2267@bombadil.infradead.org> References: <1483692145-75357-1-git-send-email-zhouxianrong@huawei.com> <1486111347-112972-1-git-send-email-zhouxianrong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1486111347-112972-1-git-send-email-zhouxianrong@huawei.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ...