From patchwork Wed Jun 5 10:06:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Zhu X-Patchwork-Id: 10976553 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 5DF1D76 for ; Wed, 5 Jun 2019 10:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DBBB28358 for ; Wed, 5 Jun 2019 10:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41FE4284F1; Wed, 5 Jun 2019 10:06:59 +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 A39891FF14 for ; Wed, 5 Jun 2019 10:06:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC8646B000E; Wed, 5 Jun 2019 06:06:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A79326B0010; Wed, 5 Jun 2019 06:06:57 -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 98E596B0266; Wed, 5 Jun 2019 06:06:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 5F75B6B000E for ; Wed, 5 Jun 2019 06:06:57 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 21so14481181pgl.5 for ; Wed, 05 Jun 2019 03:06:57 -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=gw1AnGYklzxJGBp1a1bdOMb9i8YZ42P936XCNomCzqk=; b=ZqbhvaNUMPsT9YZ47kkypkv7G1pMqC2SQ/FI/AtOdU/Qw5wbBwLUbNq88ONmCQceUE 3a2FYN9+0qubqDFwgvMAi6mS19XvGDKO/wpPtVB0xoOi68actQJdgfbc+75pqH7MHxEE igqP/wAvy9DhIjknZGEB2aS3EgXoCJdaGIxZYnxqUTK644dKKT/K5BZxeZrPC8GQw916 AN8wh+bwLZSaO0SYAQBzn3cCxVk9WN7Q0L1eP0YmiAnwTAB3YlKCnG8pWYQEFC6kXyyV RLOLvazO39+9PsaVEmuezA+2hVXok9rSSzlKUfm5qZlOxzD6Xl1ZwkQ/ztb+yKViVZ6J fWHQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 47.88.44.37 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: APjAAAWciNd255diCZhnPApzykT9NpGm3zozpzDKgrRI9UTBPDE6tMMD TTE6u7a7htU5a1QJDWUk6TfRGaFgnD+CKcoVXzqhRqmLzVPpVXR5Rqf3DbUvZyyyBpMa73tHHk6 N7rgvyzybDNHKV2Pvdtco5v2vb5yRD948AIddIGCm89m0PHqtzx6USSpixj2ftiv6Yw== X-Received: by 2002:a62:ea04:: with SMTP id t4mr43389759pfh.47.1559729216770; Wed, 05 Jun 2019 03:06:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtJf0ze1jGvAuOCIruC0y7BVOU+RFYLNuqfgTKDnYLNeM8QkjsnSM0ranHT18/V0qzQVpf X-Received: by 2002:a62:ea04:: with SMTP id t4mr43389613pfh.47.1559729215070; Wed, 05 Jun 2019 03:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559729215; cv=none; d=google.com; s=arc-20160816; b=FPOpjcUv40sSkM+qpCCyI2sLxelTDjg25PqqC/O3BPKSB3SityI138+bs2IewOwINg 9IWWHyeSC2oX+EpdkJ7MhvfZpaGIt29cR/uN9SOaOb1aomabz6xryfYsPJ6y+vTt4zd9 RGSdwxkvyy3bb7zUlNMzKGA/+XqA6VZtJRnYkb4YrzQSvQepZ8NYF1rkjw0EVjfN4Q1E DwC3mx+hX92oZvkly6TJr4IPiHU4poJofgGJhjXJW1Bppz15e/mtJX9ARjS4nh66ctat eEiqUpuibYKXqh1RCJDvvDfLRN0MtYuJ+rU8XvwdkLJEqKz8yWz0ba6+rYiy1132Lzb8 60tg== 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=gw1AnGYklzxJGBp1a1bdOMb9i8YZ42P936XCNomCzqk=; b=CBdLwyrZEGG7+XSDhAnRosCC5tdShUPlpHrELiT8iurf5qDhAfrp50sIZW1li4yCcT 2zA9ReAsuS5Q104WfDJfIhG1pcsHGE63za1MT3f/b2wrv8w/R0/ALiULCbD4XvCaYY1V MpxuZw1E1GFoeVcCn+Kn4R9cLbk9qNreiq0/kEjDLPpcANiaXP2bFsb0u19QU5bNeauw 3RFltR4rn6ATIeJ+hwqEqf34JcBGHbyRMWzSY4RvYDSNvh749AhJRFPB/2fT0OnEGXz8 K9hRVWaCxhyFi4n/kDE49+aZf2ZoTwADwCE0UgU1lu5Qp3O2ZQg9JC27cs3HanoZ8KUs w2SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4437.biz.mail.alibaba.com (out4437.biz.mail.alibaba.com. [47.88.44.37]) by mx.google.com with ESMTPS id b9si22215925pls.303.2019.06.05.03.06.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 03:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of teawaterz@linux.alibaba.com designates 47.88.44.37 as permitted sender) client-ip=47.88.44.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 47.88.44.37 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=e01f04446;MF=teawaterz@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0TTUHvst_1559729194; Received: from localhost(mailfrom:teawaterz@linux.alibaba.com fp:SMTPD_---0TTUHvst_1559729194) by smtp.aliyun-inc.com(127.0.0.1); Wed, 05 Jun 2019 18:06:39 +0800 From: Hui Zhu To: ddstreet@ieee.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, sjenning@redhat.com, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH V3 1/2] zpool: Add malloc_support_movable to zpool_driver Date: Wed, 5 Jun 2019 18:06:29 +0800 Message-Id: <20190605100630.13293-1-teawaterz@linux.alibaba.com> X-Mailer: git-send-email 2.21.0 (Apple Git-120) 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 Reviewed-by: Shakeel Butt --- 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 Wed Jun 5 10:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Zhu X-Patchwork-Id: 10976555 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 D7CB876 for ; Wed, 5 Jun 2019 10:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C82661FF60 for ; Wed, 5 Jun 2019 10:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBD4F28911; Wed, 5 Jun 2019 10:07:07 +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 E8F0F28918 for ; Wed, 5 Jun 2019 10:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E72646B0010; Wed, 5 Jun 2019 06:07:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E23B16B0266; Wed, 5 Jun 2019 06:07:05 -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 D37C06B0269; Wed, 5 Jun 2019 06:07:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by kanga.kvack.org (Postfix) with ESMTP id B26F26B0010 for ; Wed, 5 Jun 2019 06:07:05 -0400 (EDT) Received: by mail-it1-f199.google.com with SMTP id o83so1429353itc.9 for ; Wed, 05 Jun 2019 03:07:05 -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=3fn1Cj3qS1vM8x05CuUXuctfbV0i+6VVjPYt+7uhgbs=; b=k/nvFHu42XPp44A0VmYXE23KgSmSY23wtq/5sM7/xr+OFuwPxdfmfL9gZlhLzGDxni t1SjzJBb7FIUbsYri21YNC13g2GXKHHshNNng2ffYTZ854HyiUPJRMkyCJtvBFKP1CpV zgP5oRjPlriEusARlccvfr0ggteUV661NpBDAr3aSYOya/ChLn+HX4gAgQZrI7UeXNKH /Mkz5qUdcaob8FcwcfZ5/lEbroqSiP8CnDIMNcP5m/pM+jI9YUID5QgXARRiTNQPQlHZ pOJrwG6qhG/IOBd6I/olx+E2rqjvOIWiDwjNJ+2v2MBN2MuwOD8iKVZ1AKkYGoN8Tz1C Z4iQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.54 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: APjAAAXnAteFLvqSE8JsGZRevBuH/LvH+aYBsk3stlctqkUpA/wTNrAq 9R2fxLO39XrisA1PbptvY43IglbBq68eeWshak3PAgwj5qxgbinLHqFd2zyqjQCxjolwTypDnVC +tRitxTiyzvZxsnq0mjtlMVWzY757KMFvudicQw+mm0puwWsIxPKSG0VKyzFz+e9GHQ== X-Received: by 2002:a24:3a50:: with SMTP id m77mr26029441itm.110.1559729225432; Wed, 05 Jun 2019 03:07:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwL6A/9ulwG/THo8QAmWFOz0RIycngrLVOcsHubQmcMuey/GJlpuZUoovcwBJukPKAAw3wJ X-Received: by 2002:a24:3a50:: with SMTP id m77mr26029322itm.110.1559729223814; Wed, 05 Jun 2019 03:07:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559729223; cv=none; d=google.com; s=arc-20160816; b=POla4ywBSsQJWazuLUUqpuM2DbVXgDdu+z6SaMbtLl3tjTwYfj3yK1ihq0j1Ch7CQe NlGFlvODmScFO3CvpCC2A1hcmSFcOUlRhM8sYvNOBE5cHTQlmvdYkZAHgY2RlOUI1Dhx n2WrA4cjqDDreOLRoGbKn/gGAXmF0PTQi8z5m5S3H0ZOsGa1FbxWaGDIWj7Ko4mf0K6V 7+LGl94EDmmLW2PL/cvTBLS5LCDI2q+b3i63ao8tvHQX92G7vI9EY1zxnwP5kh3xUgQW cOcM67w7hQjgZSe74sfp+r8E5lAvhhi9ZtN0rlnMTgYvH77cpj+b8SD+JnGui/1EIExy k8Gw== 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=3fn1Cj3qS1vM8x05CuUXuctfbV0i+6VVjPYt+7uhgbs=; b=ksjcZHf2GTDdGIPlxBxDkja33afu2bJrWdwjfppuNrzmIcYxqqs7yKfnkqu1oss2lX OFSdAbEKO8/QK8njE/DPxBxzPJiISZmNPnFtg+WEIVJ/Di1rz2Xh/nkt0wMyCKQ+lGzo JDhxsWriT+QLU41kwYvA/JAvJrR62tLtbAgfC/giPlV8RVmr7CM6yF7JIg6KQgvnT5Jl DkkUXrU8CwyWePY/wxY97tnEM3Dx2RJktu10REthiVYs2ocU6+vGA4JRKfAUbFN3SDb5 i7fDYsye+TgyPWm/spzo94U+C5hbjZCNsO/xjPr0blOHCZ3zBxNIiWOitlLogGyTTxnQ xpkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.54 as permitted sender) smtp.mailfrom=teawaterz@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com. [115.124.30.54]) by mx.google.com with ESMTPS id p16si5814744itc.32.2019.06.05.03.07.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 03:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.54 as permitted sender) client-ip=115.124.30.54; Authentication-Results: mx.google.com; spf=pass (google.com: domain of teawaterz@linux.alibaba.com designates 115.124.30.54 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=01201311R391e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=teawaterz@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0TTUHvuX_1559729202; Received: from localhost(mailfrom:teawaterz@linux.alibaba.com fp:SMTPD_---0TTUHvuX_1559729202) by smtp.aliyun-inc.com(127.0.0.1); Wed, 05 Jun 2019 18:06:46 +0800 From: Hui Zhu To: ddstreet@ieee.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, sjenning@redhat.com, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH V3 2/2] zswap: Use movable memory if zpool support allocate movable memory Date: Wed, 5 Jun 2019 18:06:30 +0800 Message-Id: <20190605100630.13293-2-teawaterz@linux.alibaba.com> X-Mailer: git-send-email 2.21.0 (Apple Git-120) In-Reply-To: <20190605100630.13293-1-teawaterz@linux.alibaba.com> References: <20190605100630.13293-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 third version that was updated according to the comments from Sergey Senozhatsky https://lkml.org/lkml/2019/5/29/73 and Shakeel Butt https://lkml.org/lkml/2019/6/4/973 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 let zswap allocate block with gfp __GFP_HIGHMEM | __GFP_MOVABLE if zpool support allocate movable memory. Following part is test log in a pc that has 8G memory and 2G swap. Without this commit: ~# 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 / 4826062 usecs = 549973 KB/s 2717908992 bytes / 4864201 usecs = 545661 KB/s 2717908992 bytes / 4867015 usecs = 545346 KB/s 2717908992 bytes / 4915485 usecs = 539968 KB/s 397853 usecs to free memory 357820 usecs to free memory 421333 usecs to free memory 420454 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 6 5 8 6 6 5 4 1 1 1 0 Node 0, zone DMA32, type Movable 25 20 20 19 22 15 14 11 11 5 767 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 4753 5588 5159 4613 3712 2520 1448 594 188 11 0 Node 0, zone Normal, type Movable 16 3 457 2648 2143 1435 860 459 223 224 296 Node 0, zone Normal, type Reclaimable 0 0 44 38 11 2 0 0 0 0 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 1652 0 0 0 0 Node 0, zone Normal 931 1485 15 0 0 0 With this commit: ~# 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 / 4689240 usecs = 566020 KB/s 2717908992 bytes / 4760605 usecs = 557535 KB/s 2717908992 bytes / 4803621 usecs = 552543 KB/s 2717908992 bytes / 5069828 usecs = 523530 KB/s 431546 usecs to free memory 383397 usecs to free memory 456454 usecs to free memory 224487 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 10 8 10 9 10 4 3 2 3 0 0 Node 0, zone DMA32, type Movable 18 12 14 16 16 11 9 5 5 6 775 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 2669 1236 452 118 37 14 4 1 2 3 0 Node 0, zone Normal, type Movable 3850 6086 5274 4327 3510 2494 1520 934 438 220 470 Node 0, zone Normal, type Reclaimable 56 93 155 124 47 31 17 7 3 0 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 79 2326 26 0 0 0 You can see that the number of unmovable page blocks is decreased when the kernel has this commit. Signed-off-by: Hui Zhu Reviewed-by: Shakeel Butt --- mm/zswap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index a4e4d36ec085..c6bf92bf5890 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1006,6 +1006,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; /* THP isn't supported */ if (PageTransHuge(page)) { @@ -1079,9 +1080,10 @@ 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); + gfp = __GFP_NORETRY | __GFP_NOWARN | __GFP_KSWAPD_RECLAIM; + if (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;