Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752468AbdGFKDr (ORCPT ); Thu, 6 Jul 2017 06:03:47 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:32828 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbdGFKDp (ORCPT ); Thu, 6 Jul 2017 06:03:45 -0400 MIME-Version: 1.0 In-Reply-To: <20170706092919epcms5p53dae183bd95cd2fa5b050f496f32aa73@epcms5p5> References: <20170702141959epcms5p32119c772b960e942da3a92e5a79d8c41@epcms5p3> <20170706051959.GD7195@jagdpanzerIV.localdomain> <20170706092919epcms5p53dae183bd95cd2fa5b050f496f32aa73@epcms5p5> From: Dan Streetman Date: Thu, 6 Jul 2017 06:02:58 -0400 X-Google-Sender-Auth: KMMzWxC5DsOQh2a8qV6uWsGBvk4 Message-ID: Subject: Re: [PATCH v2] zswap: Zero-filled pages handling To: srividya.dr@samsung.com Cc: Sergey Senozhatsky , Seth Jennings , "penberg@kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Dinakar Reddy Pathireddy , SHARAN ALLUR , SUNEEL KUMAR SURIMANI , JUHUN KIM , "srividya.desireddy@gmail.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2140 Lines: 48 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