From: Colin Ian King <colin.king@canonical.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
"James E . J . Bottomley" <jejb@linux.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: ufs-exynos: make a const array static, makes object smaller
Date: Wed, 5 May 2021 20:49:51 +0100 [thread overview]
Message-ID: <a9fafdd2-6625-18dc-62f4-7b4a8c9fd9c2@canonical.com> (raw)
In-Reply-To: <0e90b057-3a87-bec5-c0b2-46c49b191651@canonical.com>
On 05/05/2021 20:41, Krzysztof Kozlowski wrote:
> On 05/05/2021 15:01, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Don't populate the const array granularity_tbl on the stack but instead it
>> static. Makes the object code smaller by 190 bytes:
>>
>> Before:
>> text data bss dec hex filename
>> 25563 6908 0 32471 7ed7 ./drivers/scsi/ufs/ufs-exynos.o
>>
>> After:
>> text data bss dec hex filename
>> 25213 7068 0 32281 7e19 ./drivers/scsi/ufs/ufs-exynos.o
>>
>> (gcc version 10.3.0)
>
> I am not sure what's the benefit here - you moved the code from text to
> data. In total you decreased the size for this compilation settings
> (e.g. compiler + optimizations) but that might not be always true, right?
It is a marginal saving, but for arrays this size it makes sense to not
have to populate the data into the stack before using it and then
discarding it. This change essentially replaces quite a lot of
instructions that put the data onto the stack so I think it's worth while.
>
> This has effect on the code readability - line is longer and reader
> would think "why this was made static since it is simple one-time const?".
>
Not sure how to respond to this. If they wonder why it is static const
and don't know why then one would hope they look it up in K&R and
familiarize themselves with C. It's not so subtle.
Colin
>
> Best regards,
> Krzysztof
>
next prev parent reply other threads:[~2021-05-05 19:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 19:01 [PATCH] scsi: ufs: ufs-exynos: make a const array static, makes object smaller Colin King
2021-05-05 19:41 ` Krzysztof Kozlowski
2021-05-05 19:49 ` Colin Ian King [this message]
2021-05-22 2:50 ` Martin K. Petersen
2021-05-26 4:07 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9fafdd2-6625-18dc-62f4-7b4a8c9fd9c2@canonical.com \
--to=colin.king@canonical.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).