From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753273AbbF2I6c (ORCPT ); Mon, 29 Jun 2015 04:58:32 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:36813 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752702AbbF2I60 (ORCPT ); Mon, 29 Jun 2015 04:58:26 -0400 Date: Mon, 29 Jun 2015 17:58:53 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCHv3 4/7] zsmalloc: introduce zs_can_compact() function Message-ID: <20150629085853.GB549@swordfish> References: <1434628004-11144-1-git-send-email-sergey.senozhatsky@gmail.com> <1434628004-11144-5-git-send-email-sergey.senozhatsky@gmail.com> <20150629064546.GB13179@bbox> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150629064546.GB13179@bbox> User-Agent: Mutt/1.5.23+89 (0255b37be491) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (06/29/15 15:45), Minchan Kim wrote: [..] > > +/* > > + * Make sure that we actually can compact this class, > > + * IOW if migration will release at least one szpage. > > zspage, ok. > > + * > > + * Should be called under class->lock > > Please comment about return. ok. > > + */ > > +static unsigned long zs_can_compact(struct size_class *class) > > +{ > > + /* > > + * Calculate how many unused allocated objects we > > + * have and see if we can free any zspages. Otherwise, > > + * compaction can just move objects back and forth w/o > > + * any memory gain. > > + */ > > + unsigned long obj_wasted = zs_stat_get(class, OBJ_ALLOCATED) - > > + zs_stat_get(class, OBJ_USED); > > + > > I want to check one more thing. > > We could have lots of ZS_ALMOST_FULL but no ZS_ALMOST_EMPTY. > In this implementation, compaction cannot have a source so > it would better to bail out. > IOW, > > if (!zs_stat_get(class, CLASS_ALMOST_EMPTY)) > return 0; ok. -ss