From patchwork Mon Mar 26 18:29:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 10308481 X-Patchwork-Delegate: snitzer@redhat.com 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 0224C60386 for ; Mon, 26 Mar 2018 18:31:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE51429581 for ; Mon, 26 Mar 2018 18:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D284229584; Mon, 26 Mar 2018 18:31:09 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6DA1C29581 for ; Mon, 26 Mar 2018 18:31:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B54D6804FA; Mon, 26 Mar 2018 18:31:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FAF15DD6F; Mon, 26 Mar 2018 18:31:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 10DCD181BA03; Mon, 26 Mar 2018 18:31:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2QIV5xl024232 for ; Mon, 26 Mar 2018 14:31:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id A03015E1C2; Mon, 26 Mar 2018 18:31:05 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from leontynka.twibright.com (ovpn-112-30.rdu2.redhat.com [10.10.112.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6949E5E1B7; Mon, 26 Mar 2018 18:30:59 +0000 (UTC) Received: from debian.vm ([192.168.192.2]) by leontynka.twibright.com with smtp (Exim 4.80) (envelope-from ) id 1f0WtT-0005KF-A4; Mon, 26 Mar 2018 20:30:56 +0200 Received: by debian.vm (sSMTP sendmail emulation); Mon, 26 Mar 2018 20:30:53 +0200 Message-Id: <20180326183053.714786438@debian.vm> User-Agent: quilt/0.63-1 Date: Mon, 26 Mar 2018 20:29:41 +0200 From: mpatocka@redhat.com To: mpatocka@redhat.com, msnitzer@redhat.com, agk@redhat.com References: <20180326182939.169591126@debian.vm> MIME-Version: 1.0 Content-Disposition: inline; filename=dm-bufio-remove-name-allocations.patch X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [patch 2/8] dm-bufio: get rid of slab cache name allocations X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 26 Mar 2018 18:31:09 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP dm-bufio keeps the array dm_bufio_cache_names that holds names of the slab caches. Since the commit db265eca7700 ("mm/sl[aou]b: Move duping of slab name to slab_common.c"), the kernel automatically duplicates the slab cache name when creating the slab cache, so we no longer have to keep the name allocated. This patch removes the code that allocates the slab names and keeps them around. Signed-off-by: Mikulas Patocka --- drivers/md/dm-bufio.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-bufio.c =================================================================== --- linux-2.6.orig/drivers/md/dm-bufio.c 2018-03-13 16:41:15.637954000 +0100 +++ linux-2.6/drivers/md/dm-bufio.c 2018-03-14 11:49:06.199999000 +0100 @@ -173,7 +173,6 @@ struct dm_buffer { /*----------------------------------------------------------------*/ static struct kmem_cache *dm_bufio_caches[PAGE_SHIFT - SECTOR_SHIFT]; -static char *dm_bufio_cache_names[PAGE_SHIFT - SECTOR_SHIFT]; static inline int dm_bufio_cache_index(struct dm_bufio_client *c) { @@ -185,7 +184,6 @@ static inline int dm_bufio_cache_index(s } #define DM_BUFIO_CACHE(c) (dm_bufio_caches[dm_bufio_cache_index(c)]) -#define DM_BUFIO_CACHE_NAME(c) (dm_bufio_cache_names[dm_bufio_cache_index(c)]) #define dm_bufio_in_request() (!!current->bio_list) @@ -1703,19 +1701,10 @@ struct dm_bufio_client *dm_bufio_client_ mutex_lock(&dm_bufio_clients_lock); if (c->blocks_per_page_bits) { - if (!DM_BUFIO_CACHE_NAME(c)) { - DM_BUFIO_CACHE_NAME(c) = kasprintf(GFP_KERNEL, "dm_bufio_cache-%u", c->block_size); - if (!DM_BUFIO_CACHE_NAME(c)) { - r = -ENOMEM; - mutex_unlock(&dm_bufio_clients_lock); - goto bad; - } - } - if (!DM_BUFIO_CACHE(c)) { - DM_BUFIO_CACHE(c) = kmem_cache_create(DM_BUFIO_CACHE_NAME(c), - c->block_size, - c->block_size, 0, NULL); + char name[26]; + snprintf(name, sizeof name, "dm_bufio_cache-%u", c->block_size); + DM_BUFIO_CACHE(c) = kmem_cache_create(name, c->block_size, c->block_size, 0, NULL); if (!DM_BUFIO_CACHE(c)) { r = -ENOMEM; mutex_unlock(&dm_bufio_clients_lock); @@ -1908,7 +1897,6 @@ static int __init dm_bufio_init(void) dm_bufio_current_allocated = 0; memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches); - memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names); mem = (__u64)mult_frac(totalram_pages - totalhigh_pages, DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT; @@ -1952,9 +1940,6 @@ static void __exit dm_bufio_exit(void) for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++) kmem_cache_destroy(dm_bufio_caches[i]); - for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++) - kfree(dm_bufio_cache_names[i]); - if (dm_bufio_client_count) { DMCRIT("%s: dm_bufio_client_count leaked: %d", __func__, dm_bufio_client_count);