From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752036AbdJROnz (ORCPT ); Wed, 18 Oct 2017 10:43:55 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:58512 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751714AbdJROnx (ORCPT ); Wed, 18 Oct 2017 10:43:53 -0400 X-AuditID: b6c32a4a-f73ff70000001014-80-59e768a61515 Mime-Version: 1.0 Subject: Re: [PATCH] zswap: Same-filled pages handling Reply-To: srividya.dr@samsung.com From: Srividya Desireddy To: Matthew Wilcox , Timofey Titovets CC: "sjenning@redhat.com" , "ddstreet@ieee.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , Dinakar Reddy Pathireddy , SHARAN ALLUR , RAJIB BASU , JUHUN KIM , "srividya.desireddy@gmail.com" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20171018141116.GA12063@bombadil.infradead.org> X-Drm-Type: N,general X-EPLocale: en_US.EUC-KR X-EPWebmail-Msg-Type: personal X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Illegal-Object: Syntax error in X-Sender: address found on vger.kernel.org: X-Sender: =?utf-8?B?U2Ftc3VuZyBFbGVjdHJvbmljcxtTUkktQmFuZ2Fs?= ^-Extraneous program text X-Sender-IP: 107.108.50.76 X-Local-Sender: =?UTF-8?B?U3JpdmlkeWEgRGVzaXJlZGR5G1NSSS1CYW5nYWxvcmUtQVAgU3lzdGVt?= =?UTF-8?B?cyAxG++/ve+/veyHse+/veq5hu+/ve+/ve+/ve+/ve+/vRtU?= =?UTF-8?B?ZWNobmljYWwgTGVhZA==?= X-Global-Sender: =?UTF-8?B?U3JpdmlkeWEgRGVzaXJlZGR5G1NSSS1CYW5nYWxvcmUtQVAgU3lzdGVt?= =?UTF-8?B?cyAxG1NhbXN1bmcgRWxlY3Ryb25pY3MbVGVjaG5pY2FsIExl?= =?UTF-8?B?YWQ=?= X-Sender-Code: =?UTF-8?B?QzEwGxtDMTBJRDAxSUQwMTA4OTQ=?= Message-ID: <20171018144350epcms5p1f390fae66f1c9440b8552acec555ca01@epcms5p1> Date: Wed, 18 Oct 2017 14:43:50 +0000 X-CMS-MailID: 20171018144350epcms5p1f390fae66f1c9440b8552acec555ca01 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-CPGSPASS: Y X-CPGSPASS: Y X-MTR: 20171018144350epcms5p1f390fae66f1c9440b8552acec555ca01 CMS-TYPE: 105P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7bCmuu6yjOeRBov361m8PKRpcaFtN4vF 7o4TjBanv51mtbi8aw6bxb01/1ktbj9bz2zR9vkfq8Wsn5PYLJYsW8tsseviEzaLczObGS1+ /5jD5sDrsXPWXXaPpxMOMnlsXqHlsWlVJ5vHpk+T2D3e77vK5tG3ZRWjx+dNcgEcUVw2Kak5 mWWpRfp2CVwZDb2n2AsO8lc8e2fcwPidu4uRk0NCwETibf8u5i5GLg4hgd2MEl0v77B0MXJw 8AoISvzdIQxSIyxgJvH9ZhMziC0koCjR3L2BESJuIrHp3wImkHI2ASOJw+dzQMIiAsESM3q7 wEYyC9xilrjf9ZAFYhevxIz2p1C2tMT25VvB5nAK2EicavnNChEXlbi5+i07hC0hsXrhczYI W05i2tc1zDA174/NZ4SwRSRa752FigtKPPi5GypeKdHxeTHUTCmJu98OsIAcJCGwjVFi0uSV TBCJ5YwS9+5AFZlLvH15ECzOK+ArsWzBCbAjWARUJZ4fnAR1tIvE/BkrwWxmAXmJ7W/nMIM8 zyygKbF+lz7Mjw0bf7Njsm0lvqy/ywbRyifR+/sJ0wRG1VmIkJ6FZOgshKELGJlXMUqmFhTn pqcWmxYY5aWW6xUn5haX5qXrJefnbmIEpy4trx2My875HGIU4GBU4uH9ofgsUog1say4MvcQ owQHs5II78yE55FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeY/tLI0UEkhPLEnNTk0tSC2CyTJx cEo1MIoVbvqj4yn3cf9t7gXeT9zOFJ66d+Hjvvezakz/RSaff/yA72qaWPc5NZ4tt2UPb5CY uc9hh9MW61Pv3e7eev9py1b5noyNq6Vzvk8pX3PcfuK5K4XvmZ617Nw2peHYj2WHy9XuXqrn vJrzsn/OyWfbT5hkh+Y8PeU85dnCZz+sZT8UZYmdPWD0UomlOCPRUIu5qDgRADAIsR9ZAwAA X-CMS-RootMailID: 20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0 X-RootMTR: 20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0 References: <20171018141116.GA12063@bombadil.infradead.org> <20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1> <20171018123427.GA7271@bombadil.infradead.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 18, 2017 at 7:41 PM, Matthew Wilcox wrote: > On Wed, Oct 18, 2017 at 04:33:43PM +0300, Timofey Titovets wrote: >> 2017-10-18 15:34 GMT+03:00 Matthew Wilcox : >> > On Wed, Oct 18, 2017 at 10:48:32AM +0000, Srividya Desireddy wrote: >> >> +static void zswap_fill_page(void *ptr, unsigned long value) >> >> +{ >> >> + unsigned int pos; >> >> + unsigned long *page; >> >> + >> >> + page = (unsigned long *)ptr; >> >> + if (value == 0) >> >> + memset(page, 0, PAGE_SIZE); >> >> + else { >> >> + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) >> >> + page[pos] = value; >> >> + } >> >> +} >> > >> > I think you meant: >> > >> > static void zswap_fill_page(void *ptr, unsigned long value) >> > { >> > memset_l(ptr, value, PAGE_SIZE / sizeof(unsigned long)); >> > } >> >> IIRC kernel have special zero page, and if i understand correctly. >> You can map all zero pages to that zero page and not touch zswap completely. >> (Your situation look like some KSM case (i.e. KSM can handle pages >> with same content), but i'm not sure if that applicable there) > >You're confused by the word "same". What Srividya meant was that the >page is filled with a pattern, eg 0xfffefffefffefffe..., not that it is >the same as any other page. In kernel there is a special zero page or empty_zero_page which is in general allocated in paging_init() function, to map all zero pages. But, same-value-filled pages including zero pages exist in memory because applications may be initializing the allocated pages with a value and not using them; or the actual content written to the memory pages during execution itself is same-value, in case of multimedia data for example. I had earlier posted a patch with similar implementaion of KSM concept for Zswap: https://lkml.org/lkml/2016/8/17/171 https://lkml.org/lkml/2017/2/17/612 - Srividya From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f69.google.com (mail-pg0-f69.google.com [74.125.83.69]) by kanga.kvack.org (Postfix) with ESMTP id E66E86B0069 for ; Wed, 18 Oct 2017 10:43:55 -0400 (EDT) Received: by mail-pg0-f69.google.com with SMTP id a192so4262762pge.1 for ; Wed, 18 Oct 2017 07:43:55 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTPS id l9si7082139pgn.319.2017.10.18.07.43.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 07:43:54 -0700 (PDT) Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20171018144351epoutp02168170887902d8d052cbc1cc188ac429~usUQ9vrNH1414714147epoutp02Z for ; Wed, 18 Oct 2017 14:43:51 +0000 (GMT) Mime-Version: 1.0 Subject: Re: [PATCH] zswap: Same-filled pages handling Reply-To: srividya.dr@samsung.com From: Srividya Desireddy In-Reply-To: <20171018141116.GA12063@bombadil.infradead.org> Message-ID: <20171018144350epcms5p1f390fae66f1c9440b8552acec555ca01@epcms5p1> Date: Wed, 18 Oct 2017 14:43:50 +0000 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" References: <20171018141116.GA12063@bombadil.infradead.org> <20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1> <20171018123427.GA7271@bombadil.infradead.org> Sender: owner-linux-mm@kvack.org List-ID: To: Matthew Wilcox , Timofey Titovets Cc: "sjenning@redhat.com" , "ddstreet@ieee.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , Dinakar Reddy Pathireddy , SHARAN ALLUR , RAJIB BASU , JUHUN KIM , "srividya.desireddy@gmail.com" On Wed, Oct 18, 2017 at 7:41 PM, Matthew Wilcox wrote: > On Wed, Oct 18, 2017 at 04:33:43PM +0300, Timofey Titovets wrote: >> 2017-10-18 15:34 GMT+03:00 Matthew Wilcox : >> > On Wed, Oct 18, 2017 at 10:48:32AM +0000, Srividya Desireddy wrote: >> >> +static void zswap_fill_page(void *ptr, unsigned long value) >> >> +{ >> >> + unsigned int pos; >> >> + unsigned long *page; >> >> + >> >> + page = (unsigned long *)ptr; >> >> + if (value == 0) >> >> + memset(page, 0, PAGE_SIZE); >> >> + else { >> >> + for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) >> >> + page[pos] = value; >> >> + } >> >> +} >> > >> > I think you meant: >> > >> > static void zswap_fill_page(void *ptr, unsigned long value) >> > { >> > memset_l(ptr, value, PAGE_SIZE / sizeof(unsigned long)); >> > } >> >> IIRC kernel have special zero page, and if i understand correctly. >> You can map all zero pages to that zero page and not touch zswap completely. >> (Your situation look like some KSM case (i.e. KSM can handle pages >> with same content), but i'm not sure if that applicable there) > >You're confused by the word "same". What Srividya meant was that the >page is filled with a pattern, eg 0xfffefffefffefffe..., not that it is >the same as any other page. In kernel there is a special zero page or empty_zero_page which is in general allocated in paging_init() function, to map all zero pages. But, same-value-filled pages including zero pages exist in memory because applications may be initializing the allocated pages with a value and not using them; or the actual content written to the memory pages during execution itself is same-value, in case of multimedia data for example. I had earlier posted a patch with similar implementaion of KSM concept for Zswap: https://lkml.org/lkml/2016/8/17/171 https://lkml.org/lkml/2017/2/17/612 - Srividya -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org