Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp866969pxf; Wed, 7 Apr 2021 13:40:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXAzVh8ER5SHIpkmytuCxWFhK5CJSkiGB2xal7UnGctSQ6aGVTWhZBlxWmCQ6GExTwA4N0 X-Received: by 2002:a17:906:a51:: with SMTP id x17mr5991297ejf.25.1617828059292; Wed, 07 Apr 2021 13:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617828059; cv=none; d=google.com; s=arc-20160816; b=cpq8plVrAlS2d32cvH3w0FXheJ2OnGCu/6ZfD2QA3Bfopf6CGQP22t61Bzv4gXykbj 0Xz4qo3Hq4NLbXdVmDWiqoWL8PdLkTSG6YIz/izQ5gN7sq6SpsMvt3U9GWHugAOwUO7B vfoxlHEtvD0QJpi8T7QIGOUCj/DCqfJg8Kk/4MKSKGt6HVjFkQ20FgwidEHJDEkLX/He yVwfjlUJtbByDASz2rIK6ivLMhWOcFKdASwbJ/iJ3mRma/vN0KzA9BjpBsOgZic81SjB SlzFt4hF83gKRKTbaPB7tCRrQ76Yz8B3tP36uKrRJxLXLiLfHkhonz4Uacr7oMduUHyY zapA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=PWbFOfAGfV5WZyn/OQZj1uu2ZsUfyRdycCXuLP1K8+0=; b=ouChY5UiIoVu07W7wp7hrJ3xRaXiW3SyzvqXXUCvNbyWeScrncvY/yipCVLyoBhwf+ mg4S/jEilOYk4pjav4qB+l2DJr2JzFuD1rIv9qKYOmaL0pQdd6TEmdB2wgEUg0+G7Ntl 2bn6efHsMRQB+2VOo8jh7kMNSSUWOkPr2iY8m5z8OLAmUtbWWrFgsGVGf5BKKBVYAzE5 C4VFWGZB5TQtsH43CSivc5syOlMo4q3MIIqOusbT1hTL+83+GqzpDdF0iMt0AkiO0Oo9 8AX1mwQehBqABxU+A9Eh+5AiL19Lg9uTLxM5Lyrh7hvhfFSTkNfubiybPHmUpN2yRz/U VbWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox5si725066ejb.324.2021.04.07.13.40.35; Wed, 07 Apr 2021 13:40:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234558AbhDGJZC (ORCPT + 99 others); Wed, 7 Apr 2021 05:25:02 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15940 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbhDGJZA (ORCPT ); Wed, 7 Apr 2021 05:25:00 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FFf7J4y90zyNbZ; Wed, 7 Apr 2021 17:22:36 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 7 Apr 2021 17:24:41 +0800 From: Zheng Yongjun To: , , , CC: Zheng Yongjun , Hulk Robot Subject: [PATCH -next v2] bcache: use DEFINE_MUTEX() for mutex lock Date: Wed, 7 Apr 2021 17:38:48 +0800 Message-ID: <20210407093848.567720-1-zhengyongjun3@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mutex lock can be initialized automatically with DEFINE_MUTEX() rather than explicitly calling mutex_init(). this patch will reduce the size of bcache.ko about 64 bytes, the reason as follows: though this patch will increase the size of .data segment about 32 bytes, it will also reduce the size of .init.text and .rodata.str1.1(at x86_64), .rodata_str1.8(at arm64) and .bss segment total about 96 bytes which reduce the size more than .data segment; here is the statistics: Sections: (arm64 platform) Idx name size -.init.text 00000240 +.init.text 00000228 -.rodata.str1.8 000012cd +.rodata.str1.8 000012b5 -.data 00000c60 +.data 00000c80 -.bss 00000080 +.bss 00000060 Sections: (x86 platform) Idx name size -.init.text 000001d9 +.init.text 000001bf -.rodata.str1.1 00000c80 +.rodata.str1.1 00000c6d -.data 00000cc0 +.data 00000ce0 -.bss 00000080 +.bss 00000070 Reported-by: Hulk Robot Signed-off-by: Zheng Yongjun --- drivers/md/bcache/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 03e1fe4de53d..3635f454309e 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -40,7 +40,7 @@ static const char invalid_uuid[] = { }; static struct kobject *bcache_kobj; -struct mutex bch_register_lock; +DEFINE_MUTEX(bch_register_lock); bool bcache_is_reboot; LIST_HEAD(bch_cache_sets); static LIST_HEAD(uncached_devices); @@ -2869,7 +2869,6 @@ static int __init bcache_init(void) check_module_parameters(); - mutex_init(&bch_register_lock); init_waitqueue_head(&unregister_wait); register_reboot_notifier(&reboot); -- 2.25.1