From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751675AbbIOEVd (ORCPT ); Tue, 15 Sep 2015 00:21:33 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33054 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751074AbbIOEVc (ORCPT ); Tue, 15 Sep 2015 00:21:32 -0400 Date: Tue, 15 Sep 2015 13:22:16 +0900 From: Sergey Senozhatsky To: Dan Streetman Cc: Vlastimil Babka , Vitaly Wool , Minchan Kim , Sergey Senozhatsky , LKML , Linux-MM Subject: Re: [PATCH 0/3] allow zram to use zbud as underlying allocator Message-ID: <20150915042216.GE1860@swordfish> References: <20150914154901.92c5b7b24e15f04d8204de18@gmail.com> <55F6D356.5000106@suse.cz> <55F6D641.6010209@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (09/15/15 00:08), Dan Streetman wrote: [..] > > it doesn't. but it has a complex (compared to zbud) way of storing > pages - many different classes, which each are made up of zspages, > which contain multiple actual pages to store some number of > specifically sized objects. So it can get fragmented, with lots of > zspages with empty spaces for objects. That's what the recently added > zsmalloc compaction addresses, by scanning all the zspages in all the > classes and compacting zspages within each class. > correct. a bit of internals: we don't scan all the zspages every time. each class has stats for allocated used objects, allocated used objects, etc. so we 'compact' only classes that can be compacted: static unsigned long zs_can_compact(struct size_class *class) { unsigned long obj_wasted; obj_wasted = zs_stat_get(class, OBJ_ALLOCATED) - zs_stat_get(class, OBJ_USED); obj_wasted /= get_maxobj_per_zspage(class->size, class->pages_per_zspage); return obj_wasted * class->pages_per_zspage; } if we can free any zspages (which is at least one page), then we attempt to do so. is compaction the root cause of the symptoms Vitaly observe? Vitaly, if you disable compaction: --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 14fc466..d9b5427 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1944,8 +1944,9 @@ struct zs_pool *zs_create_pool(char *name, gfp_t flags) * Not critical, we still can use the pool * and user can trigger compaction manually. */ - if (zs_register_shrinker(pool) == 0) +/* if (zs_register_shrinker(pool) == 0) pool->shrinker_enabled = true; +*/ return pool; err: --- does the 'problem' go away? > but I haven't followed most of the recent zsmalloc updates too > closely, so I may be totally wrong :-) > > zbud is much simpler; since it just uses buddied pairs, it simply > keeps a list of zbud page with only 1 compressed page stored in it. > There is still the possibility of fragmentation, but since it's > simple, it's much smaller. And there is no compaction implemented in > it, currently. The downside, as we all know, is worse efficiency in > storing compressed pages - it can't do better than 2:1. > -ss From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by kanga.kvack.org (Postfix) with ESMTP id 04CEF6B0253 for ; Tue, 15 Sep 2015 00:21:33 -0400 (EDT) Received: by padhy16 with SMTP id hy16so163704283pad.1 for ; Mon, 14 Sep 2015 21:21:32 -0700 (PDT) Received: from mail-pa0-x233.google.com (mail-pa0-x233.google.com. [2607:f8b0:400e:c03::233]) by mx.google.com with ESMTPS id zm2si2010994pbc.165.2015.09.14.21.21.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Sep 2015 21:21:32 -0700 (PDT) Received: by padhy16 with SMTP id hy16so163703995pad.1 for ; Mon, 14 Sep 2015 21:21:31 -0700 (PDT) Date: Tue, 15 Sep 2015 13:22:16 +0900 From: Sergey Senozhatsky Subject: Re: [PATCH 0/3] allow zram to use zbud as underlying allocator Message-ID: <20150915042216.GE1860@swordfish> References: <20150914154901.92c5b7b24e15f04d8204de18@gmail.com> <55F6D356.5000106@suse.cz> <55F6D641.6010209@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Dan Streetman Cc: Vlastimil Babka , Vitaly Wool , Minchan Kim , Sergey Senozhatsky , LKML , Linux-MM On (09/15/15 00:08), Dan Streetman wrote: [..] > > it doesn't. but it has a complex (compared to zbud) way of storing > pages - many different classes, which each are made up of zspages, > which contain multiple actual pages to store some number of > specifically sized objects. So it can get fragmented, with lots of > zspages with empty spaces for objects. That's what the recently added > zsmalloc compaction addresses, by scanning all the zspages in all the > classes and compacting zspages within each class. > correct. a bit of internals: we don't scan all the zspages every time. each class has stats for allocated used objects, allocated used objects, etc. so we 'compact' only classes that can be compacted: static unsigned long zs_can_compact(struct size_class *class) { unsigned long obj_wasted; obj_wasted = zs_stat_get(class, OBJ_ALLOCATED) - zs_stat_get(class, OBJ_USED); obj_wasted /= get_maxobj_per_zspage(class->size, class->pages_per_zspage); return obj_wasted * class->pages_per_zspage; } if we can free any zspages (which is at least one page), then we attempt to do so. is compaction the root cause of the symptoms Vitaly observe? Vitaly, if you disable compaction: --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 14fc466..d9b5427 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1944,8 +1944,9 @@ struct zs_pool *zs_create_pool(char *name, gfp_t flags) * Not critical, we still can use the pool * and user can trigger compaction manually. */ - if (zs_register_shrinker(pool) == 0) +/* if (zs_register_shrinker(pool) == 0) pool->shrinker_enabled = true; +*/ return pool; err: --- does the 'problem' go away? > but I haven't followed most of the recent zsmalloc updates too > closely, so I may be totally wrong :-) > > zbud is much simpler; since it just uses buddied pairs, it simply > keeps a list of zbud page with only 1 compressed page stored in it. > There is still the possibility of fragmentation, but since it's > simple, it's much smaller. And there is no compaction implemented in > it, currently. The downside, as we all know, is worse efficiency in > storing compressed pages - it can't do better than 2:1. > -ss -- 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