From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424831AbcBREp1 (ORCPT ); Wed, 17 Feb 2016 23:45:27 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:34126 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424254AbcBREp0 (ORCPT ); Wed, 17 Feb 2016 23:45:26 -0500 Date: Thu, 18 Feb 2016 13:46:42 +0900 From: Sergey Senozhatsky To: Sergey Senozhatsky Cc: Andrew Morton , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH 3/3] mm/zsmalloc: change ZS_MAX_PAGES_PER_ZSPAGE Message-ID: <20160218044642.GB10776@swordfish> References: <1455764556-13979-1-git-send-email-sergey.senozhatsky@gmail.com> <1455764556-13979-4-git-send-email-sergey.senozhatsky@gmail.com> <20160218044156.GA10776@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160218044156.GA10776@swordfish> 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 (02/18/16 13:41), Sergey Senozhatsky wrote: > I think we better switch to different logic here -- specify how many ->huge > classes we want to have, and let zsmalloc to calculate ZS_MAX_PAGES_PER_ZSPAGE. > > > For example, if we want to have 20 ->huge classes, the 'smallest' (or the last) ^^^ largest > non-huge class will have CLASS_SIZE * SIZE_CLASS_DELTA of spare (wasted) space, > so PAGE_SIZE / (CLASS_SIZE * SIZE_CLASS_DELTA) will give us the number of pages > we need to form into a zspage to make it the last huge class. ^^ 'non-huge'... what is the correct english word I'm looking for... -ss > setting ZS_MIN_HUGE_CLASSES_NUM to 32 gives us (on x86_64, PAGE_SHIFT 12) ->huge > class size range of [3648, 4096]. so all objects smaller than 3648 will not waste > an entire zspage (and order-0 page), but will share the page with another objects > of that size. > > > something like this: > > --- > > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c > index 0c9f117..d5252d1 100644 > --- a/mm/zsmalloc.c > +++ b/mm/zsmalloc.c > @@ -73,12 +73,6 @@ > */ > #define ZS_ALIGN 8 > > -/* > - * A single 'zspage' is composed of up ZS_MAX_PAGES_PER_ZSPAGE discontiguous > - * 0-order (single) pages. > - */ > -#define ZS_MAX_PAGES_PER_ZSPAGE 6 > - > #define ZS_HANDLE_SIZE (sizeof(unsigned long)) > > /* > @@ -149,6 +143,21 @@ > #define ZS_SIZE_CLASS_DELTA (PAGE_SIZE >> 8) > > /* > + * We want to have at least this number of ->huge classes. > + */ > +#define ZS_MIN_HUGE_CLASSES_NUM 32 > +/* > + * A single 'zspage' is composed of up ZS_MAX_PAGES_PER_ZSPAGE discontiguous > + * 0-order (single) pages. > + * > + * The smallest huge class will have CLASS_SIZE * SIZE_CLASS_DELTA of > + * wasted space, calculate how many pages we need to fit a CLASS_SIZE > + * object there and, thus, to save a additional zspage. > + */ > +#define ZS_MAX_PAGES_PER_ZSPAGE \ > + (PAGE_SIZE / (ZS_MIN_HUGE_CLASSES_NUM * ZS_SIZE_CLASS_DELTA)) > + > +/* > * We do not maintain any list for completely empty or full pages > */ > enum fullness_group { >