From patchwork Thu Nov 19 11:50:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 7656611 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D68969F2E2 for ; Thu, 19 Nov 2015 11:51:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D21B2069E for ; Thu, 19 Nov 2015 11:51:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2956320699 for ; Thu, 19 Nov 2015 11:51:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757640AbbKSLuT (ORCPT ); Thu, 19 Nov 2015 06:50:19 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37109 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754269AbbKSLuR (ORCPT ); Thu, 19 Nov 2015 06:50:17 -0500 Received: by wmww144 with SMTP id w144so112894388wmw.0 for ; Thu, 19 Nov 2015 03:50:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=GXesNUcOAsUF7h6hLtN3UlfuKaCUihsZpuW6ZKpqzko=; b=H/uugTOYykKb/maIR8xLrdBQuPgt6OGsnPVkPEnEmXaWg65qCgFriDL26+SMe5oXeV dMDBTX2bmg1pmstGOArb02xOnIjcyBxZXTqGfnJW0Lg4L9blQuKJ9rxC+TCbQ8xOaBmB KdNxjkRz1Kk7OOu4VdEcF+ui4GaYxarRIvyqM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=GXesNUcOAsUF7h6hLtN3UlfuKaCUihsZpuW6ZKpqzko=; b=UsjRFzAoJOPoTO1dyaOpsKhSeOlGlJIUquWZSXHEO0nGvlLqAycse8iHRcqGwcCkph sNAD+/P/EDc9EUJUuU5ZhjVpunxMdAZN17eUFbaOWa4ljW6G35/1hxgNLWXVE2dgtwus vnH5XkXQwa9PBs573C3PsCa/l2c3p5WHZnnLUJ5kQUjbuC5Wv5OhNNPCA8rgTl0lXR1m SxHw19CuwnAN46gjYSC2R4Ms1SI86M7JJjqZkhuaIP87Nj+sDsd4Ayptcz3dBHXh8smm Gs0dUZdv77jx1TfpLW5Dh1Uw31bh89L7ge3I9impGoSeOS6K9ij4bq6u1paZx2RLHYas MTjw== X-Gm-Message-State: ALoCoQkqagRxIslFHpDHc3jotI25Tkwx6V8bewFc3MWEdDOo6EP9IBOXsQbeXe++RM1xMGSXCGIp X-Received: by 10.28.100.84 with SMTP id y81mr10752868wmb.48.1447933816084; Thu, 19 Nov 2015 03:50:16 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id a186sm7950653wmh.4.2015.11.19.03.50.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 03:50:15 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 1/3] null_blk: use ppa_cache pool Date: Thu, 19 Nov 2015 12:50:08 +0100 Message-Id: <1447933810-10267-2-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447933810-10267-1-git-send-email-m@bjorling.me> References: <1447933810-10267-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using a page pool, we can save memory by only allocating room for 64 entries for the ppa command. Introduce a ppa_cache to allocate only the required memory for the ppa list. Signed-off-by: Matias Bjørling --- drivers/block/null_blk.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 8165251..173ba24 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -47,6 +47,7 @@ static LIST_HEAD(nullb_list); static struct mutex lock; static int null_major; static int nullb_indexes; +static struct kmem_cache *ppa_cache; struct completion_queue { struct llist_head list; @@ -521,7 +522,7 @@ static void *null_lnvm_create_dma_pool(struct request_queue *q, char *name) { mempool_t *virtmem_pool; - virtmem_pool = mempool_create_page_pool(64, 0); + virtmem_pool = mempool_create_slab_pool(64, ppa_cache); if (!virtmem_pool) { pr_err("null_blk: Unable to create virtual memory pool\n"); return NULL; @@ -767,6 +768,12 @@ static int __init null_init(void) bs = PAGE_SIZE; } + if (use_lightnvm && bs != 4096) { + pr_warn("null_blk: LightNVM only supports 4k block size\n"); + pr_warn("null_blk: defaults block size to 4k\n"); + bs = 4096; + } + if (use_lightnvm && queue_mode != NULL_Q_MQ) { pr_warn("null_blk: LightNVM only supported for blk-mq\n"); pr_warn("null_blk: defaults queue mode to blk-mq\n"); @@ -803,15 +810,27 @@ static int __init null_init(void) if (null_major < 0) return null_major; + if (use_lightnvm) { + ppa_cache = kmem_cache_create("ppa_cache", 64 * sizeof(u64), + 0, 0, NULL); + if (!ppa_cache) { + pr_err("null_blk: unable to create ppa cache\n"); + return -ENOMEM; + } + } + for (i = 0; i < nr_devices; i++) { if (null_add_dev()) { unregister_blkdev(null_major, "nullb"); - return -EINVAL; + goto err_ppa; } } pr_info("null: module loaded\n"); return 0; +err_ppa: + kmem_cache_destroy(ppa_cache); + return -EINVAL; } static void __exit null_exit(void) @@ -826,6 +845,9 @@ static void __exit null_exit(void) null_del_dev(nullb); } mutex_unlock(&lock); + + if (use_lightnvm) + kmem_cache_destroy(ppa_cache); } module_init(null_init);