lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160218044156.GA10776@swordfish>
Date:	Thu, 18 Feb 2016 13:41:56 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Minchan Kim <minchan@...nel.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC PATCH 3/3] mm/zsmalloc: change ZS_MAX_PAGES_PER_ZSPAGE

On (02/18/16 12:02), Sergey Senozhatsky wrote:
[..]
> ---
>  mm/zsmalloc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 61b1b35..0c9f117 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -74,11 +74,10 @@
>  #define ZS_ALIGN		8
>  
>  /*
> - * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single)
> - * pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N.
> + * A single 'zspage' is composed of up ZS_MAX_PAGES_PER_ZSPAGE discontiguous
> + * 0-order (single) pages.
>   */
> -#define ZS_MAX_ZSPAGE_ORDER 2
> -#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)
> +#define ZS_MAX_PAGES_PER_ZSPAGE	6
>  
>  #define ZS_HANDLE_SIZE (sizeof(unsigned long))
>  


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)
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.


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 {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ