From patchwork Thu Dec 8 01:23:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 9465601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3C2D607D4 for ; Thu, 8 Dec 2016 01:30:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9361B2850D for ; Thu, 8 Dec 2016 01:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87CCC28583; Thu, 8 Dec 2016 01:30:49 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 974B72850D for ; Thu, 8 Dec 2016 01:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753366AbcLHBas (ORCPT ); Wed, 7 Dec 2016 20:30:48 -0500 Received: from mail-wj0-f174.google.com ([209.85.210.174]:34120 "EHLO mail-wj0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbcLHBar (ORCPT ); Wed, 7 Dec 2016 20:30:47 -0500 Received: by mail-wj0-f174.google.com with SMTP id tg4so121248276wjb.1 for ; Wed, 07 Dec 2016 17:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pLUDgT+Dd2SqKB17twYtB/zLxzKqMhyANOurWoTPPhc=; b=JYuztT4r1dq2tY91DPvQWanUaFMghRwIOw2qzY5izm1v51B5h7OQjuOREJQxqU0DIy bL3BHrA81Js0gZ3N6mLGfw5mcpt1qAXEb5FZVjI2g6rsbmOmyJzr4Aej+kaTXeqpFNQq ffS5W9LQ60pUYed0SjyluO83Q7CJQeRPxl8KI= 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; bh=pLUDgT+Dd2SqKB17twYtB/zLxzKqMhyANOurWoTPPhc=; b=cXHiPgHd//jw2vpb+Pfm61anS1FDIls/aEiUUVwf80oy4Gzmd1P33f4erAXq6vUUtM lGXwJIJeiSrinQVDLVpD9DK+G1O4Ve58dYYmO0PNijo5oMWkyjCjfDzQTujk77I5G7i5 AR2R1z+RY/x6bQbRC3taA8Jc5BZDIJtBGpqNEOJN2LzZ/iInqipezeA3MwB7OyN0kBOJ 0Tef65YgeBkgqz4nqDIKZwOFpXDp8VnL6vm9HN3Ugrl17l7lNCJxrV1JSSJokK3/byVD YVMHDQoJA4wRer7fCUl/tAs6D7WHb5TjDFbF2JhJYIn3pv9ZOUUcpnF0VjVvqToSh4TG lczg== X-Gm-Message-State: AKaTC00Au9jrxB/ONNgs6Xqv+Apuukp+/O3PPa/NRc6fYzORnpwyRECuwIQbOVuCT80A4Q== X-Received: by 10.194.123.170 with SMTP id mb10mr3584305wjb.158.1481160206734; Wed, 07 Dec 2016 17:23:26 -0800 (PST) Received: from lvps87-230-87-209.dedicated.hosteurope.de (wildmoose.dk. [87.230.87.209]) by smtp.gmail.com with ESMTPSA id bj1sm34218689wjc.17.2016.12.07.17.23.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 17:23:26 -0800 (PST) From: Rasmus Villemoes To: Tejun Heo , Andrew Morton Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , Jens Axboe , Greg Kroah-Hartman , Rasmus Villemoes , linux-block@vger.kernel.org Subject: [RFC 06/10] block: use tida as small id allocator Date: Thu, 8 Dec 2016 02:23:01 +0100 Message-Id: <1481160187-9652-7-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk> References: <1481160187-9652-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A struct ida ends up costing > 16 KB of runtime memory, which is quite a lot for something which on my laptop as of this writing has handed out 27 ids in its lifetime. So use the simpler and lighter-weight struct tida. Signed-off-by: Rasmus Villemoes --- block/blk-core.c | 6 +++--- block/blk-sysfs.c | 2 +- block/blk.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 14d7c0740dc0..6919a519d797 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -46,7 +46,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); EXPORT_TRACEPOINT_SYMBOL_GPL(block_split); EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug); -DEFINE_IDA(blk_queue_ida); +DEFINE_TIDA(blk_queue_ida); /* * For the allocated request tables @@ -699,7 +699,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) if (!q) return NULL; - q->id = ida_simple_get(&blk_queue_ida, 0, 0, gfp_mask); + q->id = tida_get(&blk_queue_ida, gfp_mask); if (q->id < 0) goto fail_q; @@ -771,7 +771,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) fail_split: bioset_free(q->bio_split); fail_id: - ida_simple_remove(&blk_queue_ida, q->id); + tida_put(&blk_queue_ida, q->id); fail_q: kmem_cache_free(blk_requestq_cachep, q); return NULL; diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 9cc8d7c5439a..5a04dd6cb20d 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -652,7 +652,7 @@ static void blk_release_queue(struct kobject *kobj) if (q->bio_split) bioset_free(q->bio_split); - ida_simple_remove(&blk_queue_ida, q->id); + tida_put(&blk_queue_ida, q->id); call_rcu(&q->rcu_head, blk_free_queue_rcu); } diff --git a/block/blk.h b/block/blk.h index 74444c49078f..a0a606efed91 100644 --- a/block/blk.h +++ b/block/blk.h @@ -1,7 +1,7 @@ #ifndef BLK_INTERNAL_H #define BLK_INTERNAL_H -#include +#include #include #include "blk-mq.h" @@ -34,7 +34,7 @@ struct blk_flush_queue { extern struct kmem_cache *blk_requestq_cachep; extern struct kmem_cache *request_cachep; extern struct kobj_type blk_queue_ktype; -extern struct ida blk_queue_ida; +extern struct tida blk_queue_ida; static inline struct blk_flush_queue *blk_get_flush_queue( struct request_queue *q, struct blk_mq_ctx *ctx)