From patchwork Thu Dec 19 14:21:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Wool X-Patchwork-Id: 11303721 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68EE76C1 for ; Thu, 19 Dec 2019 14:21:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 27491222C2 for ; Thu, 19 Dec 2019 14:21:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WiB/mqAZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27491222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3FBB38E0172; Thu, 19 Dec 2019 09:21:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 382E48E00F5; Thu, 19 Dec 2019 09:21:55 -0500 (EST) 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 24B1C8E0172; Thu, 19 Dec 2019 09:21:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 0B34E8E00F5 for ; Thu, 19 Dec 2019 09:21:55 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id B63AA181AC9CC for ; Thu, 19 Dec 2019 14:21:54 +0000 (UTC) X-FDA: 76282104948.09.title11_2db4a2a9c1d43 X-Spam-Summary: 2,0,0,1d84a5dfc8cfc974,d41d8cd98f00b204,vitalywool@gmail.com,::akpm@linux-foundation.org:ddstreet@ieee.org:minchan@kernel.org:sergey.senozhatsky.work@gmail.com:linux-kernel@vger.kernel.org:vbabka@suse.cz:shakeelb@google.com:henrywolfeburns@gmail.com:tytso@thunk.org,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3355:3369:3865:3866:3867:3868:3871:4117:4250:4321:4605:5007:6119:6261:6653:7875:7903:8603:9413:10004:10400:11026:11658:11914:12043:12048:12291:12296:12297:12438:12517:12519:12555:12683:12760:12895:12986:13161:13229:13439:13869:13972:14096:14097:14181:14394:14659:14687:14721:21080:21444:21451:21627:21666:21990:30005:30034:30054:30070,0,RBL:209.85.208.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom _rules:0 X-HE-Tag: title11_2db4a2a9c1d43 X-Filterd-Recvd-Size: 6938 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 19 Dec 2019 14:21:53 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id p8so6470920ljg.0 for ; Thu, 19 Dec 2019 06:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gofwvjfHv3OpfgHnS5zABByZ2BwnD9/VLkGxBh/tVfU=; b=WiB/mqAZ5AgK4mWB/04pDrsu5J3ScbjcrXxRkJwcLKm91NhUe8IvvUTONor6F0A3gH 19dDsLf3/hz8GHot/TCP/m0hsK93Oot9SLDUsghv+t7Dgwu6++UWgSFHiVVPUUVq35S6 EgTddRAERBaqN9C1MwvwsAugoFKdC7Z5KPePDxnXBYP6J9WnTFOddR58Cl2KbsOhyc97 /V6L2So+t3zvjo5NzniUssdOWQ0WJ6Y6pwxKk5HvpyOBfBRNCoMlD2uuw7ciXjXmzEeT uILplQ0AxEos6IXc7g7SRVII1SPd87EcX/migVeLZoNhX1RJhhcK3r+vZ7S2SN+lmE0n PHDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gofwvjfHv3OpfgHnS5zABByZ2BwnD9/VLkGxBh/tVfU=; b=aqWxjLhjACYBZoHPQ0ae9Oq3n6j2Xyyh4bakWUgHgf8mPvH3tHLMerpWs4tkAGQ/rc WjCmUeOIf6H4yy9Upi/rsrqizfog02JhvBs8grL+GCbCVYgP/+WplYU+pkWFGKiz/M3n UdQ7mBx75hL1qq2u4dwHXboc3Leg7T+eVme38utqLZFf2lu2iOT+lz0WUT0905gJMpJv 112NGBS7MyLpr23HOraLw3xFxAym2//LoclCAgNtPjBy/yQe9LqSBCYdqgQFUu6MAJrP 85wJNXVFvjiz4+kTK7/P1I4Rp/S7TBn+5iys3H2HGIzhZ4PbBCKU15kV+StvyAeGYQu3 Fx+g== X-Gm-Message-State: APjAAAWAUfuj3czeVHcNb4Va2R8bKdT7nVwQM/drcl2UUOXrmYQ7qFEB GPCBpFcQaq52EzKRR/0XhJcrx14Qt21cnQ== X-Google-Smtp-Source: APXvYqzf/gl2762BuLOYeikmN5C5VC3CQ+H9Afb70IeusMMpvUcm6hTtOZduBDnKaZt8uHwja2fH7A== X-Received: by 2002:a2e:86c4:: with SMTP id n4mr6068346ljj.97.1576765312270; Thu, 19 Dec 2019 06:21:52 -0800 (PST) Received: from assa ([109.252.14.238]) by smtp.gmail.com with ESMTPSA id 140sm2728532lfk.78.2019.12.19.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 06:21:51 -0800 (PST) Date: Thu, 19 Dec 2019 15:21:50 +0100 From: Vitaly Wool To: Linux-MM , Andrew Morton , Dan Streetman , Minchan Kim Cc: Sergey Senozhatsky , LKML , Vlastimil Babka , Shakeel Butt , Henry Burns , Theodore Ts'o Subject: [PATCHv2 1/3] zpool: add compaction api Message-Id: <20191219152150.1ed1900008a6ec867779f82e@gmail.com> In-Reply-To: <20191219151928.ad4ccf732b64b7f8a26116db@gmail.com> References: <20191219151928.ad4ccf732b64b7f8a26116db@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) 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: This patch adds the following functions to the zpool API: - zpool_compact() - zpool_get_num_compacted() - zpool_huge_class_size() The first one triggers compaction for the underlying allocator, the second retrieves the number of pages migrated due to compaction for the whole time of this pool's existence and the third one returns the huge class size. This API extension is done to align zpool API with zsmalloc API. Signed-off-by: Vitaly Wool --- include/linux/zpool.h | 14 +++++++++++++- mm/zpool.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/include/linux/zpool.h b/include/linux/zpool.h index 51bf43076165..31f0c1360569 100644 --- a/include/linux/zpool.h +++ b/include/linux/zpool.h @@ -61,8 +61,13 @@ void *zpool_map_handle(struct zpool *pool, unsigned long handle, void zpool_unmap_handle(struct zpool *pool, unsigned long handle); +unsigned long zpool_compact(struct zpool *pool); + +unsigned long zpool_get_num_compacted(struct zpool *pool); + u64 zpool_get_total_size(struct zpool *pool); +size_t zpool_huge_class_size(struct zpool *zpool); /** * struct zpool_driver - driver implementation for zpool @@ -75,7 +80,10 @@ u64 zpool_get_total_size(struct zpool *pool); * @shrink: shrink the pool. * @map: map a handle. * @unmap: unmap a handle. - * @total_size: get total size of a pool. + * @compact: try to run compaction over a pool + * @get_num_compacted: get amount of compacted pages for a pool + * @total_size: get total size of a pool + * @huge_class_size: huge class threshold for pool pages. * * This is created by a zpool implementation and registered * with zpool. @@ -104,7 +112,11 @@ struct zpool_driver { enum zpool_mapmode mm); void (*unmap)(void *pool, unsigned long handle); + unsigned long (*compact)(void *pool); + unsigned long (*get_num_compacted)(void *pool); + u64 (*total_size)(void *pool); + size_t (*huge_class_size)(void *pool); }; void zpool_register_driver(struct zpool_driver *driver); diff --git a/mm/zpool.c b/mm/zpool.c index 863669212070..55e69213c2eb 100644 --- a/mm/zpool.c +++ b/mm/zpool.c @@ -362,6 +362,30 @@ void zpool_unmap_handle(struct zpool *zpool, unsigned long handle) zpool->driver->unmap(zpool->pool, handle); } + /** + * zpool_compact() - try to run compaction over zpool + * @pool The zpool to compact + * + * Returns: the number of migrated pages + */ +unsigned long zpool_compact(struct zpool *zpool) +{ + return zpool->driver->compact ? zpool->driver->compact(zpool->pool) : 0; +} + + +/** + * zpool_get_num_compacted() - get the number of migrated/compacted pages + * @pool The zpool to get compaction statistic for + * + * Returns: the total number of migrated pages for the pool + */ +unsigned long zpool_get_num_compacted(struct zpool *zpool) +{ + return zpool->driver->get_num_compacted ? + zpool->driver->get_num_compacted(zpool->pool) : 0; +} + /** * zpool_get_total_size() - The total size of the pool * @zpool: The zpool to check @@ -375,6 +399,18 @@ u64 zpool_get_total_size(struct zpool *zpool) return zpool->driver->total_size(zpool->pool); } +/** + * zpool_huge_class_size() - get size for the "huge" class + * @pool The zpool to check + * + * Returns: size of the huge class + */ +size_t zpool_huge_class_size(struct zpool *zpool) +{ + return zpool->driver->huge_class_size ? + zpool->driver->huge_class_size(zpool->pool) : 0; +} + /** * zpool_evictable() - Test if zpool is potentially evictable * @zpool: The zpool to test