From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753073AbdBFOOx (ORCPT ); Mon, 6 Feb 2017 09:14:53 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:58254 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751948AbdBFOOv (ORCPT ); Mon, 6 Feb 2017 09:14:51 -0500 Date: Mon, 6 Feb 2017 06:14:48 -0800 From: Matthew Wilcox To: zhouxianrong Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, sergey.senozhatsky@gmail.com, 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: <20170206141448.GF2267@bombadil.infradead.org> References: <1483692145-75357-1-git-send-email-zhouxianrong@huawei.com> <1486111347-112972-1-git-send-email-zhouxianrong@huawei.com> <20170205142100.GA9611@bbox> <2f6e188c-5358-eeab-44ab-7634014af651@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2f6e188c-5358-eeab-44ab-7634014af651@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 Mon, Feb 06, 2017 at 09:28:18AM +0800, zhouxianrong 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; > > > + } > > > + } > > > + > > > > I don't think we need this part because block layer works with sector > > size or multiple times of it so it must be aligned unsigned long. > > Minchan and Matthew Wilcox: > > 1. right, but users could open /dev/block/zram0 file and do any read operations. But any such read operation would go through the page cache, so will be page aligned. Unless they do an O_DIRECT operation, in which case it must be aligned to block size. Please, try it. I/Os which are not aligned should be failed long before they reach your driver.