Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6574851ybi; Wed, 5 Jun 2019 03:09:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGjO3gCnJhK0z9DEfKhOkYZKKjXmW/nzwwAi1+TqL53Y+x+i50VdLAXvpFOsm5m66LxEIh X-Received: by 2002:a17:902:bd06:: with SMTP id p6mr41821906pls.112.1559729340261; Wed, 05 Jun 2019 03:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559729340; cv=none; d=google.com; s=arc-20160816; b=TChEZ/wuREiVTGDOH34Xtw5m3TmX4nTTQxlEkMUCf81ZMkl1+DXD3v0BMnCDGXhS1l 0j9GS1xChqbVUsH7kJNXhSId5qarCjc6n6Tks4Rlb5Toeuc01RtARlP3pzFK83SHiXWE ObqRKVWIdSbf/+T79VLffNd7iwwZ8FstcqdcWNzh6AcVr5dDHCF07o/bdtpz3GuQm2pg D8oDU75iCgamYLM7TMYQfv5fikt/zCljdNUTW13hEeLVWBzNcmyV5UC0qzJ9Jj6J3OM+ U7iXol89ptXY6adLKoNZJmoHJNbbO5HVlIDj6t/3ySjPvdr/ZgSG2X2+Zq3NM/DvKsbl Gfog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gw1AnGYklzxJGBp1a1bdOMb9i8YZ42P936XCNomCzqk=; b=CPRHWdj9gBVjLQZQD/LcbViv4W6GnkbsH6EJXyZijwhhDWtDbBCasNbFvRjfa5hrY4 KOeP8h5sXYXNqraYUM15b6kfvfKWqBWxrTeX6DpyvfPvVPViIvUYAUL0kwjnIJmqgj+H fNIJHdH+NR1A/2y4Ks06NCmMENGtMTgRvK9ofWanTLOOhpU60ZOP4RYUcT4WWwmDLr8r eoYlNlDAi4bPUwUcE3B8ypsIVUmrmpxAuDlMum6z65sM7B+aXh4D7BPElq1fOsONEYaQ dCzB3cvrYLdiWilIwaLdOpSTz5HuXzVeeE0fPdHdEEC11mfAG9yeRwPNUMaglw0q0PTL ua8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si25348022pjv.55.2019.06.05.03.08.41; Wed, 05 Jun 2019 03:09:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbfFEKGp (ORCPT + 99 others); Wed, 5 Jun 2019 06:06:45 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:36575 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbfFEKGp (ORCPT ); Wed, 5 Jun 2019 06:06:45 -0400 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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"); -- 2.21.0 (Apple Git-120)