Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1017594iob; Fri, 13 May 2022 19:48:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCHHfPoDwb0YM3kbT3pr371pFb3WNB3h2hKuuklFriId77J/eKX+aRJo728tLwdEotvb1z X-Received: by 2002:a5d:6f05:0:b0:20c:d4eb:365b with SMTP id ay5-20020a5d6f05000000b0020cd4eb365bmr5981019wrb.674.1652496489358; Fri, 13 May 2022 19:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652496489; cv=none; d=google.com; s=arc-20160816; b=Tk1M81moWVCuh961+UjxovhCcp1w/LBGHUPPtk/5RiEELCML8N6SI6tXsPS+q7+O/0 h76Rrilff7GxCtO9ATIRcjWXUyQMzdYys37qWZi9sjzfFEqjH/nx9tWAwv37gtWhSflH MBMrO3T5JPgbGVISSSt3tNrJZXlSGFe9s9I4panNcgJJ/4n71PrM5dANLBWGf0malD01 7RK1baTaTIKXOOTCn+KKRHpP+z9JfCSHHVOVOY9hyUOj56Tdf+GVf/Yt9gywlpEZyPZ/ 6iMBJxd1Hhg40kwJjxvNa4kUzu4S9hK2W84W2mSzmYlVnL3ZUY1Fe9miKi0qWfXn2ya3 rgIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=fMQD60Se+VbijwlWSIyoQaf+GhT4mFTl+yNKtCcD9js=; b=ZVauBoUlf+g7jJZyh//hqAf5Y+PJjoBpN3+3JSaRP7qbR+lLAuaj6JwIRd1A5beWX9 Xfl2nkp1s+J39Jju/ntQLD8dSgbnWy8qdKAt0vOdYEBVQPADOaYFH3Cd07lRL9d0/mho n7VkbtP15/AwlSnqmRTTQHe692JgGHNOMXxznYYz1HkZ1ppwUf7f0YetdIfQHGpWG43Z sr3M3VHuEJW21DFqNf9l7cLBV5ZXIpTL6Sm8y5L8fc5stXhSHObRIxc6SHgs0a9Mxocs 6VxcTqzaQV6sjn+zNmBYvBIc/tOHYlmpx00UrZdqjslK7VL06i5ouc9N76ZEH43R52+G Z60Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a8-20020adfdd08000000b0020cdd41b02csi3519430wrm.656.2022.05.13.19.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A89C367E7F; Fri, 13 May 2022 16:35:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379763AbiEMLGb convert rfc822-to-8bit (ORCPT + 99 others); Fri, 13 May 2022 07:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379732AbiEMLG2 (ORCPT ); Fri, 13 May 2022 07:06:28 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5708027CC0 for ; Fri, 13 May 2022 04:06:26 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-197-ASZCsPWJPluT1yty21qOXQ-1; Fri, 13 May 2022 12:06:24 +0100 X-MC-Unique: ASZCsPWJPluT1yty21qOXQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 13 May 2022 12:06:23 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.033; Fri, 13 May 2022 12:06:23 +0100 From: David Laight To: 'Andrew Morton' , liqiong CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] mm: change "char *bdi_unknown_name" to "char bdi_unknown_name[]" Thread-Topic: [PATCH] mm: change "char *bdi_unknown_name" to "char bdi_unknown_name[]" Thread-Index: AQHYZjsAqW5HazYh8E6shSZ+mswpua0cpDpg Date: Fri, 13 May 2022 11:06:23 +0000 Message-ID: <4b21dec7e98243b89daea96286c33434@AcuMS.aculab.com> References: <20220512082637.24649-1-liqiong@nfschina.com> <20220512130051.94a0c53e5d1498292473975d@linux-foundation.org> In-Reply-To: <20220512130051.94a0c53e5d1498292473975d@linux-foundation.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Morton > Sent: 12 May 2022 21:01 > > On Thu, 12 May 2022 16:26:37 +0800 liqiong wrote: > > > "char bdi_unknown_nam[]" string form declares a single variable. > > It is better then "char *bdi_unknown_name" which creates two > > variables. > > > > ... > > > > --- a/mm/backing-dev.c > > +++ b/mm/backing-dev.c > > @@ -20,7 +20,7 @@ struct backing_dev_info noop_backing_dev_info; > > EXPORT_SYMBOL_GPL(noop_backing_dev_info); > > > > static struct class *bdi_class; > > -static const char *bdi_unknown_name = "(unknown)"; > > +static const char bdi_unknown_name[] = "(unknown)"; > > > > heh, fun patch. We actually do this quite a lot. > > grep -r "^[a-z].*char \*[a-z].*= \"" . > > is a pathetic pattern which catches a lot of them. > > > However. I expected your patch to shrink the kernel a bit, but it has > the opposite effect: > > hp2:/usr/src/25> size mm/backing-dev.o > text data bss dec hex filename > 21288 9396 3808 34492 86bc mm/backing-dev.o-before > 21300 9428 3808 34536 86e8 mm/backing-dev.o-after > > Even .data became larger. I didn't investigate why. The linker can merge replicated strings (ie data in .rodata.str1.n sections) but I don't think the compiler puts variables into that section. So if you have: static const char *const foo_xxx = "foo"; in multiple source/object files you get lots of pointers but only one string. OTOH with: static const char foo_xxx[] = "foo"; you get lots of copies of the string. Which is smaller depends on the number of variables and the length of the string. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)