From patchwork Sun Jun 2 09:46:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Zhu X-Patchwork-Id: 10971689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C7AB1575 for ; Sun, 2 Jun 2019 09:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F06926220 for ; Sun, 2 Jun 2019 09:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41DB028C06; Sun, 2 Jun 2019 09:46:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ED3526220 for ; Sun, 2 Jun 2019 09:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BF836B000E; Sun, 2 Jun 2019 05:46:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2476E6B0010; Sun, 2 Jun 2019 05:46:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1100E6B0266; Sun, 2 Jun 2019 05:46:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id CD6E26B000E for ; Sun, 2 Jun 2019 05:46:29 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id n1so2550089plk.11 for ; Sun, 02 Jun 2019 02:46:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=2AkO3LxaNyQOB+mW9ZqnbZ02q46v1QMPGKcJa9dKCYY=; b=adQxRTOAFtdBfY0SMOfSWPjCgooNII2oyOJsFyr065dco1seYdSZpct4YT/dm/h/Jn DLdrP6x4ZmUJllmVwP2cS3TA4u1en6NxMUaAiqoKXaZzbzxdyBxmKm6tD6F5yXyWQWDX xEwo0rYrxkgpsPE1r4iF3mz+H8tUZi6p7wSIIju7b1o475iZiVpWuLhwcOc9nlMWgaK0 sHHtqIBtsGwWKaGLmtbzSGf4cKKzq//IHdVUmznWDP2LKUyOkiajO9NXemgmR82/ro1y d4nmBt1TAb/u54qv7UWtIEMGZcx/D1TvH1fZ/WHmmKv2cU6kKa2tl4ap0YASv0e3aIRL 8bvg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APjAAAWSELBMR+okzUyQ2i/CTp/ic+JCsd4YpH/LqO60BCZN1fkX+pwn Cs7Culh/dOL2ari6pMV+FLPgj+8v4uAR32t4DyWHh0Nm2FoXO2hAjGzaMlstmxJHN0TMhClWlw6 LRM2jiHcgfFrK25QiaYINNU1rHYUdfmjp+W7zBmp6gTX6MNmbZIsiC+Zxt+0Cz+8jHw== X-Received: by 2002:a63:5024:: with SMTP id e36mr21463225pgb.220.1559468789314; Sun, 02 Jun 2019 02:46:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqySMKzzPEH/Ew+qIxKpE68zlkAYuJhyYYhVcQ90B2xJ4IB75b5PYuMYx1spK3K/+Ai80H8s X-Received: by 2002:a63:5024:: with SMTP id e36mr21463174pgb.220.1559468787963; Sun, 02 Jun 2019 02:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559468787; cv=none; d=google.com; s=arc-20160816; b=RBnE1JGuAt0+FiYKbnXlJqmhVcc5638ZoV44FKkGXxvZ5ag6iy+WXnezjmflx7+vPb ehCNIw0Qtw48V2gBEwAFSzd2T0yHl/fhRkzzI2/FLVjrqaTyX9W3DNy4KaeS3iB4q/oY ECiRaPs4AfDKbrXtMt0CY3EN30YcCSMvj3LTpcEASUbmi0tpVpkDE7rOrDdZ6pCyno1+ keCpFCvlWBuLaccw5HtmILemVpLtnvcdysdiwZXdo9CWeeuapwzbfoYCnZgPRHfCTOCu e+Bx85YZXnu5pUBIE5FBT53aV+DRi7Wpgdzcl3tDKlDcVBlLoBLnYXhSYm2uLcMwe1sJ Y7tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=2AkO3LxaNyQOB+mW9ZqnbZ02q46v1QMPGKcJa9dKCYY=; b=jRvAPNw1Y9vNYpyiqA9+ivXjZ3o0GweELryKWDPheImEvnXDVbSK41Nl9tcGRIv8Dl iyFI2OZKXk2F8h2RPSpGLEfrWXp+GdfBejd741eWwm7jJDMQUFZPKZrj5WoyV/d0PoR8 zKJMRjkYhUusl2NB2uO3PLXYGUcPKSgDMpQOZoYYryzky+kw5cNsyWbfXvSonG2/jmfc kkqxP7pZmxW9S793RfKG4lLrLEWlyf9q+6GwT+2UjlueSZ7K8ZO03H0tYkisUZ0w3Tqo MvGgwmZmHKEIsnG1AJAoQoPb9aFVIgxyUC9HsnO7rlTctpOd6ASS7oANwwaivmtfQG9o xKDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com. [115.124.30.45]) by mx.google.com with ESMTPS id q42si488054pjc.103.2019.06.02.02.46.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 02:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.45 as permitted sender) client-ip=115.124.30.45; Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R521e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=teawaterz@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TTD1lNX_1559468776; Received: from localhost(mailfrom:teawaterz@linux.alibaba.com fp:SMTPD_---0TTD1lNX_1559468776) by smtp.aliyun-inc.com(127.0.0.1); Sun, 02 Jun 2019 17:46:25 +0800 From: Hui Zhu To: ddstreet@ieee.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, sjenning@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH V2 1/2] zpool: Add malloc_support_movable to zpool_driver Date: Sun, 2 Jun 2019 17:46:06 +0800 Message-Id: <20190602094607.41840-1-teawaterz@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP As a zpool_driver, zsmalloc can allocate movable memory because it support migate pages. But zbud and z3fold cannot allocate movable memory. This commit adds malloc_support_movable to zpool_driver. If a zpool_driver support allocate movable memory, set it to true. And add zpool_malloc_support_movable check malloc_support_movable to make sure if a zpool support allocate movable memory. Signed-off-by: Hui Zhu --- include/linux/zpool.h | 3 +++ mm/zpool.c | 16 ++++++++++++++++ mm/zsmalloc.c | 19 ++++++++++--------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/linux/zpool.h b/include/linux/zpool.h index 7238865e75b0..51bf43076165 100644 --- a/include/linux/zpool.h +++ b/include/linux/zpool.h @@ -46,6 +46,8 @@ const char *zpool_get_type(struct zpool *pool); void zpool_destroy_pool(struct zpool *pool); +bool zpool_malloc_support_movable(struct zpool *pool); + int zpool_malloc(struct zpool *pool, size_t size, gfp_t gfp, unsigned long *handle); @@ -90,6 +92,7 @@ struct zpool_driver { struct zpool *zpool); void (*destroy)(void *pool); + bool malloc_support_movable; int (*malloc)(void *pool, size_t size, gfp_t gfp, unsigned long *handle); void (*free)(void *pool, unsigned long handle); diff --git a/mm/zpool.c b/mm/zpool.c index a2dd9107857d..863669212070 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -238,6 +238,22 @@ const char *zpool_get_type(struct zpool *zpool) return zpool->driver->type; } +/** + * zpool_malloc_support_movable() - Check if the zpool support + * allocate movable memory + * @zpool: The zpool to check + * + * This returns if the zpool support allocate movable memory. + * + * Implementations must guarantee this to be thread-safe. + * + * Returns: true if if the zpool support allocate movable memory, false if not + */ +bool zpool_malloc_support_movable(struct zpool *zpool) +{ + return zpool->driver->malloc_support_movable; +} + /** * zpool_malloc() - Allocate memory * @zpool: The zpool to allocate from. diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 0787d33b80d8..8f3d9a4d46f4 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -437,15 +437,16 @@ static u64 zs_zpool_total_size(void *pool) } static struct zpool_driver zs_zpool_driver = { - .type = "zsmalloc", - .owner = THIS_MODULE, - .create = zs_zpool_create, - .destroy = zs_zpool_destroy, - .malloc = zs_zpool_malloc, - .free = zs_zpool_free, - .map = zs_zpool_map, - .unmap = zs_zpool_unmap, - .total_size = zs_zpool_total_size, + .type = "zsmalloc", + .owner = THIS_MODULE, + .create = zs_zpool_create, + .destroy = zs_zpool_destroy, + .malloc_support_movable = true, + .malloc = zs_zpool_malloc, + .free = zs_zpool_free, + .map = zs_zpool_map, + .unmap = zs_zpool_unmap, + .total_size = zs_zpool_total_size, }; MODULE_ALIAS("zpool-zsmalloc"); From patchwork Sun Jun 2 09:46:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Zhu X-Patchwork-Id: 10971691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E0F46C5 for ; Sun, 2 Jun 2019 09:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A02C26220 for ; Sun, 2 Jun 2019 09:46:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DBBC28C06; Sun, 2 Jun 2019 09:46:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E6D726220 for ; Sun, 2 Jun 2019 09:46:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 751CD6B0010; Sun, 2 Jun 2019 05:46:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6DB206B0266; Sun, 2 Jun 2019 05:46:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57EAE6B0269; Sun, 2 Jun 2019 05:46:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 1C3F26B0010 for ; Sun, 2 Jun 2019 05:46:44 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id 93so9494487plf.14 for ; Sun, 02 Jun 2019 02:46:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+RgFaPwzCNwNxIUjGFSq56qKQgfzgYNSGLTN36JyM2o=; b=XRNNYUR/2xLOqU8kMVCIwN3+iFH6c9Gq1reDMUwTd9B85tNKTSqSgOS2rYyzKNnbrj Ft8Vo8TteDBUx9ha62hpAI1oK6xXIBA1xZsaqVPEolob0HrzE0xNq81HDESYXcwEMBoL RPEP33jpG7l2StruVgk14xON5VH9uKiWLGVhsItcasEUuHTUbxk9NtUMx58vrDMWIgmb PV99tE0YtDfwqdTL0VpYS98HP4PLu4A36oh04Kv7uR8UXpXIPPBWNWj2iPn8jcdMYKeq bKlANJ9F6FFEozSBy81N2XR761pp6lFCSr7bsFd3Q5K5Dyn8SI/FkMmPj0epe+zmb83/ jg/w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APjAAAXhUjhic5ikY5EEmt9CkkBz+opeoNh4/G064nR+E/TnJYefJq8C sq7tPLz0anexq6LfvXojny/IO8zxGWfFPS2FPMZ/Vm9ODFF+fKopOX5DqharDWYsJnySGALZcHg 7w+n6HyIlq/S6xP+JHbpSVZ+z0t0Bm0yPIcZLEkAxXNI90o+rTxhlKQTlk2EsRbt85g== X-Received: by 2002:a17:902:2e81:: with SMTP id r1mr22207175plb.0.1559468803531; Sun, 02 Jun 2019 02:46:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWn4L2cGRqmu8d/CDMToLp1km0waNhsU3xLWLHZlA9NQZw0A0tbObBoqyY38YgAjgjs+au X-Received: by 2002:a17:902:2e81:: with SMTP id r1mr22207105plb.0.1559468801824; Sun, 02 Jun 2019 02:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559468801; cv=none; d=google.com; s=arc-20160816; b=WYi+oLSmZIJUiP8iOODE/jFj8hySyv/BzKQvlhBIIZzJmbbqfFzVhj05DKRzBhq6ZT wrqLEKu+n4vdnSWq0doZwai1zu8Lr21JQSBR1w4VhqGnPbNNIXEQGaXgWbuQZ/h91pWD 304mhyZMJs/WUacbatXENeSqIvkgzu6PFmOppCQts3GfmSNjWJHwZTZK7SScviRH0mQA /AAuYJOyP+FIw2Qn68lZ0LCYDJVpMCiq33/BfnJnnhH+9NFs9F8YJFaFIbDSeeWFOp4J 2OioLNVk2/jWAkg15MEmJsHgTLOCaauy3PUuYiZ+wHkEvy8ZbB6geuFVlWjK+f8+8Frt ZPLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=+RgFaPwzCNwNxIUjGFSq56qKQgfzgYNSGLTN36JyM2o=; b=euRLu0U1CchBp0F/9JPZFqAZY2dYxvavrFVmzie0ujF/BPWTY24GrqIAzLXRVhBOGk TC9X+3Awe3TOfjK0FVVbo10xClzICvhkPcvk6YbhzwoOMpHGybL5an3GDGP39IKIMcOc 8rWlyYCCTnjZQgyws86LJUxHMBICi944GqOJtoe/p7XXgSnlTjyNN3p098jhmh1MZZB+ IELQQh9ewBF38Or3mWImeAHj6Tw4RHd1aAJGxsAC0fACUOuW+SJnttPyHwOWacjqSEjq A55YxxIXsNNZR7aOV69rjhq9/oV6efTRny07vuiCZ7QZYYyR37OEzneyp0fKllc6vNlf lMZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com. [115.124.30.57]) by mx.google.com with ESMTPS id m5si12951928pgj.451.2019.06.02.02.46.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 02:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.57 as permitted sender) client-ip=115.124.30.57; Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07487;MF=teawaterz@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0TTD1lP8_1559468787; Received: from localhost(mailfrom:teawaterz@linux.alibaba.com fp:SMTPD_---0TTD1lP8_1559468787) by smtp.aliyun-inc.com(127.0.0.1); Sun, 02 Jun 2019 17:46:39 +0800 From: Hui Zhu To: ddstreet@ieee.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, sjenning@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH V2 2/2] zswap: Add module parameter malloc_movable_if_support Date: Sun, 2 Jun 2019 17:46:07 +0800 Message-Id: <20190602094607.41840-2-teawaterz@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190602094607.41840-1-teawaterz@linux.alibaba.com> References: <20190602094607.41840-1-teawaterz@linux.alibaba.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is the second version that was updated according to the comments from Sergey Senozhatsky in https://lkml.org/lkml/2019/5/29/73 zswap compresses swap pages into a dynamically allocated RAM-based memory pool. The memory pool should be zbud, z3fold or zsmalloc. All of them will allocate unmovable pages. It will increase the number of unmovable page blocks that will bad for anti-fragment. zsmalloc support page migration if request movable page: handle = zs_malloc(zram->mem_pool, comp_len, GFP_NOIO | __GFP_HIGHMEM | __GFP_MOVABLE); And commit "zpool: Add malloc_support_movable to zpool_driver" add zpool_malloc_support_movable check malloc_support_movable to make sure if a zpool support allocate movable memory. This commit adds module parameter malloc_movable_if_support to enable or disable zpool allocate block with gfp __GFP_HIGHMEM | __GFP_MOVABLE if it support allocate movable memory (disabled by default). Following part is test log in a pc that has 8G memory and 2G swap. When it disabled: echo lz4 > /sys/module/zswap/parameters/compressor echo zsmalloc > /sys/module/zswap/parameters/zpool echo 1 > /sys/module/zswap/parameters/enabled swapon /swapfile cd /home/teawater/kernel/vm-scalability/ /home/teawater/kernel/vm-scalability# export unit_size=$((9 * 1024 * 1024 * 1024)) /home/teawater/kernel/vm-scalability# ./case-anon-w-seq 2717908992 bytes / 3977932 usecs = 667233 KB/s 2717908992 bytes / 4160702 usecs = 637923 KB/s 2717908992 bytes / 4354611 usecs = 609516 KB/s 293359 usecs to free memory 340304 usecs to free memory 205781 usecs to free memory 2717908992 bytes / 5588016 usecs = 474982 KB/s 166124 usecs to free memory /home/teawater/kernel/vm-scalability# cat /proc/pagetypeinfo Page block order: 9 Pages per block: 512 Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10 Node 0, zone DMA, type Unmovable 1 1 1 0 2 1 1 0 1 0 0 Node 0, zone DMA, type Movable 0 0 0 0 0 0 0 0 0 1 3 Node 0, zone DMA, type Reclaimable 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type Unmovable 5 10 9 8 8 5 1 2 3 0 0 Node 0, zone DMA32, type Movable 15 16 14 12 14 10 9 6 6 5 776 Node 0, zone DMA32, type Reclaimable 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Unmovable 7097 6914 6473 5642 4373 2664 1220 319 78 4 0 Node 0, zone Normal, type Movable 2092 3216 2820 2266 1585 946 559 359 237 258 378 Node 0, zone Normal, type Reclaimable 47 88 122 80 34 9 5 4 2 1 2 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Number of blocks type Unmovable Movable Reclaimable HighAtomic CMA Isolate Node 0, zone DMA 1 7 0 0 0 0 Node 0, zone DMA32 4 1652 0 0 0 0 Node 0, zone Normal 834 1572 25 0 0 0 When it enabled: echo lz4 > /sys/module/zswap/parameters/compressor echo zsmalloc > /sys/module/zswap/parameters/zpool echo 1 > /sys/module/zswap/parameters/enabled echo 1 > /sys/module/zswap/parameters/malloc_movable_if_support swapon /swapfile cd /home/teawater/kernel/vm-scalability/ /home/teawater/kernel/vm-scalability# export unit_size=$((9 * 1024 * 1024 * 1024)) /home/teawater/kernel/vm-scalability# ./case-anon-w-seq 2717908992 bytes / 4721401 usecs = 562165 KB/s 2717908992 bytes / 4783167 usecs = 554905 KB/s 2717908992 bytes / 4802125 usecs = 552715 KB/s 2717908992 bytes / 4866579 usecs = 545395 KB/s 323605 usecs to free memory 414817 usecs to free memory 458576 usecs to free memory 355827 usecs to free memory /home/teawater/kernel/vm-scalability# cat /proc/pagetypeinfo Page block order: 9 Pages per block: 512 Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10 Node 0, zone DMA, type Unmovable 1 1 1 0 2 1 1 0 1 0 0 Node 0, zone DMA, type Movable 0 0 0 0 0 0 0 0 0 1 3 Node 0, zone DMA, type Reclaimable 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type Unmovable 8 10 8 7 7 6 5 3 2 0 0 Node 0, zone DMA32, type Movable 23 21 18 15 13 14 14 10 11 6 766 Node 0, zone DMA32, type Reclaimable 0 0 0 0 0 0 0 0 0 0 1 Node 0, zone DMA32, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone DMA32, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Unmovable 2660 1295 460 102 11 5 3 11 2 4 0 Node 0, zone Normal, type Movable 4178 5760 5045 4137 3324 2306 1482 930 497 254 460 Node 0, zone Normal, type Reclaimable 50 83 114 93 28 12 10 6 3 3 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type CMA 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0 Number of blocks type Unmovable Movable Reclaimable HighAtomic CMA Isolate Node 0, zone DMA 1 7 0 0 0 0 Node 0, zone DMA32 4 1650 2 0 0 0 Node 0, zone Normal 81 2325 25 0 0 0 You can see that the number of unmovable page blocks is decreased when malloc_movable_if_support is enabled. Signed-off-by: Hui Zhu --- mm/zswap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index a4e4d36ec085..2fc45de92383 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -123,6 +123,13 @@ static bool zswap_same_filled_pages_enabled = true; module_param_named(same_filled_pages_enabled, zswap_same_filled_pages_enabled, bool, 0644); +/* Enable/disable zpool allocate block with gfp __GFP_HIGHMEM | __GFP_MOVABLE + * if it support allocate movable memory (disabled by default). + */ +static bool __read_mostly zswap_malloc_movable_if_support; +module_param_cb(malloc_movable_if_support, ¶m_ops_bool, + &zswap_malloc_movable_if_support, 0644); + /********************************* * data structures **********************************/ @@ -1006,6 +1013,7 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, char *buf; u8 *src, *dst; struct zswap_header zhdr = { .swpentry = swp_entry(type, offset) }; + gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM; /* THP isn't supported */ if (PageTransHuge(page)) { @@ -1079,9 +1087,11 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, /* store */ hlen = zpool_evictable(entry->pool->zpool) ? sizeof(zhdr) : 0; - ret = zpool_malloc(entry->pool->zpool, hlen + dlen, - __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM, - &handle); + if (zswap_malloc_movable_if_support && + zpool_malloc_support_movable(entry->pool->zpool)) { + gfp |= __GFP_HIGHMEM | __GFP_MOVABLE; + } + ret = zpool_malloc(entry->pool->zpool, hlen + dlen, gfp, &handle); if (ret == -ENOSPC) { zswap_reject_compress_poor++; goto put_dstmem;