From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770AbdHPRUP (ORCPT ); Wed, 16 Aug 2017 13:20:15 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:12629 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751893AbdHPRUM (ORCPT ); Wed, 16 Aug 2017 13:20:12 -0400 X-AuditID: b6c32a4a-f79896d000000f29-4c-59947ec96345 Mime-Version: 1.0 Subject: [PATCH v2] zswap: Zero-filled pages handling Reply-To: srividya.dr@samsung.com From: Srividya Desireddy To: "ddstreet@ieee.org" , "sergey.senozhatsky.work@gmail.com" , "sjenning@redhat.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "penberg@kernel.org" , Dinakar Reddy Pathireddy , SHARAN ALLUR , JUHUN KIM , "srividya.desireddy@gmail.com" , Sarbojit Ganguly X-Priority: 3 X-Content-Kind-Code: NORMAL 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: <20170816172008epcms5p24e951e01951f055559210af10edf2250@epcms5p2> Date: Wed, 16 Aug 2017 17:20:08 +0000 X-CMS-MailID: 20170816172008epcms5p24e951e01951f055559210af10edf2250 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-CPGSPASS: Y X-CPGSPASS: Y X-MTR: 20170816172008epcms5p24e951e01951f055559210af10edf2250 CMS-TYPE: 105P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDKsWRmVeSWpSXmKPExsWy7bCmuu7JuimRBvebrCxeHtK0uNC2m8Vi d8cJRotrK96zWJz+dprV4vKuOWwW99b8Z7Vo+/yP1eLRhElMFkuWrWW22HXxCZvFuZnNjA48 Hjtn3WX3eDrhIJPHplWdbB6bPk1i93i/7yqbR9+WVYwenzfJBbBHcdmkpOZklqUW6dslcGVs 27OPvaBfsWLuombWBsYnkl2MnBwSAiYSyy5tYoawxSQu3FvP1sXIxSEksJtR4lRvO2MXIwcH r4CgxN8dwiA1wgKmEvuP7WEBsYUEFCWauzcwQsRNJDb9W8AEUs4mYCRx+HwOyBgRgTUsEtsv NrJBzOeVmNH+lAXClpbYvnwrI4QtKnFz9Vt2CFtCYvXC51D1chLTvq5hhql5f2w+VL2IROu9 s1BxQYkHP3dDxSslOj4vZoWwpSTufjvAAnKEhMA2RolJk1cyQSSWM0rcuwNVZC7x9uVBsDiv gK/EqoM3wY5gEVCVmNS4Hux3CQEXicb/EiBhZgF5ie1v5zCDhJkFNCXW79KHeath4292TLat xNWDc5ggWvkken8/YYKYqCrxf5HlBEaVWYiwnYVk/iyE+QsYmVcxSqYWFOempxabFhjlpZbr FSfmFpfmpesl5+duYgSnKS2vHYzLzvkcYhTgYFTi4Y3ImxIpxJpYVlyZe4hRgoNZSYR3eg1Q iDclsbIqtSg/vqg0J7X4EKM0B4uSOO+xnaWRQgLpiSWp2ampBalFMFkmDk6pBkaDiW27fcUC dYqKD31+68CuwNfxXnkCQ57v1tQjvJ6ssUWP9a5NsTUxOeBY+Kf9vdgO7V/cq1ft85iwfXFR uN20Rp2Daxz3Z03z29XKZfnla6FJ17IM9t2zbhYv5GqcePvSLqUyi/KnG+O1Tj6qj2xnt369 euUmXcvzgs7S2Qrzcpv9fuSF2yuxFGckGmoxFxUnAgAf7nB9TwMAAA== X-CMS-RootMailID: 20170816172008epcms5p24e951e01951f055559210af10edf2250 X-RootMTR: 20170816172008epcms5p24e951e01951f055559210af10edf2250 References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 6, 2017 at 3:32 PM, Dan Streetman wrote: > On Thu, Jul 6, 2017 at 5:29 AM, Srividya Desireddy > wrote: >> On Wed, Jul 6, 2017 at 10:49 AM, Sergey Senozhatsky wrote: >>> On (07/02/17 20:28), Seth Jennings wrote: >>>> On Sun, Jul 2, 2017 at 9:19 AM, Srividya Desireddy >>>> > Zswap is a cache which compresses the pages that are being swapped out >>>> > and stores them into a dynamically allocated RAM-based memory pool. >>>> > Experiments have shown that around 10-20% of pages stored in zswap >>>> > are zero-filled pages (i.e. contents of the page are all zeros), but >>>> > these pages are handled as normal pages by compressing and allocating >>>> > memory in the pool. >>>> >>>> I am somewhat surprised that this many anon pages are zero filled. >>>> >>>> If this is true, then maybe we should consider solving this at the >>>> swap level in general, as we can de-dup zero pages in all swap >>>> devices, not just zswap. >>>> >>>> That being said, this is a fair small change and I don't see anything >>>> objectionable. However, I do think the better solution would be to do >>> this at a higher level. >>> >> >> Thank you for your suggestion. It is a better solution to handle >> zero-filled pages before swapping-out to zswap. Since, Zram is already >> handles Zero pages internally, I considered to handle within Zswap. >> In a long run, we can work on it to commonly handle zero-filled anon >> pages. >> >>> zero-filled pages are just 1 case. in general, it's better >>> to handle pages that are memset-ed with the same value (e.g. >>> memset(page, 0x01, page_size)). which includes, but not >>> limited to, 0x00. zram does it. >>> >>> -ss >> >> It is a good solution to extend zero-filled pages handling to same value >> pages. I will work on to identify the percentage of same value pages >> excluding zero-filled pages in Zswap and will get back. > > Yes, this sounds like a good modification to the patch. Also, unless > anyone else disagrees, it may be good to control this with a module > param - in case anyone has a use case that they know won't be helped > by this, and the extra overhead of checking each page is wasteful. > Probably should default to enabled. > >> >> - Srividya I have made changes to patch to handle pages with same-value filled. I tested on a ARM Quad Core 32-bit device with 1.5GB RAM by launching and relaunching different applications. After the test, out of ~64000 pages stored in zswap, ~ 11000 pages were same-value filled pages (including zero-filled pages) and ~9000 pages were zero-filled pages. An average of 17% of pages(including zero-filled pages) in zswap are same-value filled pages and 14% pages are zero-filled pages. An average of 3% of pages are same-filled non-zero pages. The below table shows the execution time profiling with the patch. Baseline With patch % Improvement ----------------------------------------------------------------- *Zswap Store Time 26.5ms 18ms 32% (of same value pages) *Zswap Load Time (of same value pages) 25.5ms 13ms 49% ----------------------------------------------------------------- On Ubuntu PC with 2GB RAM, while executing kernel build and other test scripts and running multimedia applications, out of 360000 pages stored in zswap 78000(~22%) of pages were found to be same-value filled pages (including zero-filled pages) and 64000(~17%) are zero-filled pages. So an average of %5 of pages are same-filled non-zero pages. The below table shows the execution time profiling with the patch. Baseline With patch % Improvement ----------------------------------------------------------------- *Zswap Store Time 91ms 74ms 19% (of same value pages) *Zswap Load Time 50ms 7.5ms 85% (of same value pages) ----------------------------------------------------------------- *The execution times may vary with test device used. I will send this patch of handling same-value filled pages along with module param to control it(default being enabled). - Srividya