* [PATCH] scsi: sd: Make protection lookup tables static
@ 2019-01-07 14:41 ` John Garry
0 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2019-01-07 14:41 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi, John Garry
Currently the protection lookup tables in sd_prot_flag_mask() and
sd_prot_op() are declared non-static. As such, they will be rebuilt for
each respective function call.
Optimise by making them static.
This saves ~100B object code for sd.c:
Before:
text data bss dec hex filename
25403 1024 16 26443 674b drivers/scsi/sd.o
After:
text data bss dec hex filename
25299 1024 16 26339 66e3 drivers/scsi/sd.o
Signed-off-by: John Garry <john.garry@huawei.com>
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 1d63f3a..89e6d42 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -195,15 +195,15 @@ static inline sector_t sectors_to_logical(struct scsi_device *sdev, sector_t sec
static inline unsigned int sd_prot_op(bool write, bool dix, bool dif)
{
/* Lookup table: bit 2 (write), bit 1 (dix), bit 0 (dif) */
- const unsigned int ops[] = { /* wrt dix dif */
- SCSI_PROT_NORMAL, /* 0 0 0 */
- SCSI_PROT_READ_STRIP, /* 0 0 1 */
- SCSI_PROT_READ_INSERT, /* 0 1 0 */
- SCSI_PROT_READ_PASS, /* 0 1 1 */
- SCSI_PROT_NORMAL, /* 1 0 0 */
- SCSI_PROT_WRITE_INSERT, /* 1 0 1 */
- SCSI_PROT_WRITE_STRIP, /* 1 1 0 */
- SCSI_PROT_WRITE_PASS, /* 1 1 1 */
+ static const unsigned int ops[] = { /* wrt dix dif */
+ SCSI_PROT_NORMAL, /* 0 0 0 */
+ SCSI_PROT_READ_STRIP, /* 0 0 1 */
+ SCSI_PROT_READ_INSERT, /* 0 1 0 */
+ SCSI_PROT_READ_PASS, /* 0 1 1 */
+ SCSI_PROT_NORMAL, /* 1 0 0 */
+ SCSI_PROT_WRITE_INSERT, /* 1 0 1 */
+ SCSI_PROT_WRITE_STRIP, /* 1 1 0 */
+ SCSI_PROT_WRITE_PASS, /* 1 1 1 */
};
return ops[write << 2 | dix << 1 | dif];
@@ -215,7 +215,7 @@ static inline unsigned int sd_prot_op(bool write, bool dix, bool dif)
*/
static inline unsigned int sd_prot_flag_mask(unsigned int prot_op)
{
- const unsigned int flag_mask[] = {
+ static const unsigned int flag_mask[] = {
[SCSI_PROT_NORMAL] = 0,
[SCSI_PROT_READ_STRIP] = SCSI_PROT_TRANSFER_PI |
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] scsi: sd: Make protection lookup tables static
@ 2019-01-07 14:41 ` John Garry
0 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2019-01-07 14:41 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi, John Garry
Currently the protection lookup tables in sd_prot_flag_mask() and
sd_prot_op() are declared non-static. As such, they will be rebuilt for
each respective function call.
Optimise by making them static.
This saves ~100B object code for sd.c:
Before:
text data bss dec hex filename
25403 1024 16 26443 674b drivers/scsi/sd.o
After:
text data bss dec hex filename
25299 1024 16 26339 66e3 drivers/scsi/sd.o
Signed-off-by: John Garry <john.garry@huawei.com>
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 1d63f3a..89e6d42 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -195,15 +195,15 @@ static inline sector_t sectors_to_logical(struct scsi_device *sdev, sector_t sec
static inline unsigned int sd_prot_op(bool write, bool dix, bool dif)
{
/* Lookup table: bit 2 (write), bit 1 (dix), bit 0 (dif) */
- const unsigned int ops[] = { /* wrt dix dif */
- SCSI_PROT_NORMAL, /* 0 0 0 */
- SCSI_PROT_READ_STRIP, /* 0 0 1 */
- SCSI_PROT_READ_INSERT, /* 0 1 0 */
- SCSI_PROT_READ_PASS, /* 0 1 1 */
- SCSI_PROT_NORMAL, /* 1 0 0 */
- SCSI_PROT_WRITE_INSERT, /* 1 0 1 */
- SCSI_PROT_WRITE_STRIP, /* 1 1 0 */
- SCSI_PROT_WRITE_PASS, /* 1 1 1 */
+ static const unsigned int ops[] = { /* wrt dix dif */
+ SCSI_PROT_NORMAL, /* 0 0 0 */
+ SCSI_PROT_READ_STRIP, /* 0 0 1 */
+ SCSI_PROT_READ_INSERT, /* 0 1 0 */
+ SCSI_PROT_READ_PASS, /* 0 1 1 */
+ SCSI_PROT_NORMAL, /* 1 0 0 */
+ SCSI_PROT_WRITE_INSERT, /* 1 0 1 */
+ SCSI_PROT_WRITE_STRIP, /* 1 1 0 */
+ SCSI_PROT_WRITE_PASS, /* 1 1 1 */
};
return ops[write << 2 | dix << 1 | dif];
@@ -215,7 +215,7 @@ static inline unsigned int sd_prot_op(bool write, bool dix, bool dif)
*/
static inline unsigned int sd_prot_flag_mask(unsigned int prot_op)
{
- const unsigned int flag_mask[] = {
+ static const unsigned int flag_mask[] = {
[SCSI_PROT_NORMAL] = 0,
[SCSI_PROT_READ_STRIP] = SCSI_PROT_TRANSFER_PI |
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: sd: Make protection lookup tables static
2019-01-07 14:41 ` John Garry
(?)
@ 2019-01-07 16:57 ` Bart Van Assche
2019-01-07 17:27 ` John Garry
-1 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2019-01-07 16:57 UTC (permalink / raw)
To: John Garry, jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi
On Mon, 2019-01-07 at 22:41 +0800, John Garry wrote:
> Currently the protection lookup tables in sd_prot_flag_mask() and
> sd_prot_op() are declared non-static. As such, they will be rebuilt for
> each respective function call.
>
> Optimise by making them static.
>
> This saves ~100B object code for sd.c:
>
> Before:
> text data bss dec hex filename
> 25403 1024 16 26443 674b drivers/scsi/sd.o
>
> After:
> text data bss dec hex filename
> 25299 1024 16 26339 66e3 drivers/scsi/sd.o
Since the sd_prot_op() function only has a single caller, please move it from sd.h
into sd.c.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: sd: Make protection lookup tables static
2019-01-07 16:57 ` Bart Van Assche
@ 2019-01-07 17:27 ` John Garry
0 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2019-01-07 17:27 UTC (permalink / raw)
To: Bart Van Assche, jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi
On 07/01/2019 16:57, Bart Van Assche wrote:
> On Mon, 2019-01-07 at 22:41 +0800, John Garry wrote:
>> Currently the protection lookup tables in sd_prot_flag_mask() and
>> sd_prot_op() are declared non-static. As such, they will be rebuilt for
>> each respective function call.
>>
>> Optimise by making them static.
>>
>> This saves ~100B object code for sd.c:
>>
>> Before:
>> text data bss dec hex filename
>> 25403 1024 16 26443 674b drivers/scsi/sd.o
>>
>> After:
>> text data bss dec hex filename
>> 25299 1024 16 26339 66e3 drivers/scsi/sd.o
>
> Since the sd_prot_op() function only has a single caller, please move it from sd.h
> into sd.c.
Can do, as long as no one has objection.
Function sd_prot_flag_mask() also has a single caller AFAICS, so this
could also be relocated.
Cheers,
John
>
> Thanks,
>
> Bart.
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: sd: Make protection lookup tables static
@ 2019-01-07 17:27 ` John Garry
0 siblings, 0 replies; 6+ messages in thread
From: John Garry @ 2019-01-07 17:27 UTC (permalink / raw)
To: Bart Van Assche, jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi
On 07/01/2019 16:57, Bart Van Assche wrote:
> On Mon, 2019-01-07 at 22:41 +0800, John Garry wrote:
>> Currently the protection lookup tables in sd_prot_flag_mask() and
>> sd_prot_op() are declared non-static. As such, they will be rebuilt for
>> each respective function call.
>>
>> Optimise by making them static.
>>
>> This saves ~100B object code for sd.c:
>>
>> Before:
>> text data bss dec hex filename
>> 25403 1024 16 26443 674b drivers/scsi/sd.o
>>
>> After:
>> text data bss dec hex filename
>> 25299 1024 16 26339 66e3 drivers/scsi/sd.o
>
> Since the sd_prot_op() function only has a single caller, please move it from sd.h
> into sd.c.
Can do, as long as no one has objection.
Function sd_prot_flag_mask() also has a single caller AFAICS, so this
could also be relocated.
Cheers,
John
>
> Thanks,
>
> Bart.
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: sd: Make protection lookup tables static
2019-01-07 17:27 ` John Garry
(?)
@ 2019-01-07 17:33 ` Bart Van Assche
-1 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2019-01-07 17:33 UTC (permalink / raw)
To: John Garry, jejb, martin.petersen; +Cc: linuxarm, linux-kernel, linux-scsi
On Mon, 2019-01-07 at 17:27 +0000, John Garry wrote:
> On 07/01/2019 16:57, Bart Van Assche wrote:
> > On Mon, 2019-01-07 at 22:41 +0800, John Garry wrote:
> > > Currently the protection lookup tables in sd_prot_flag_mask() and
> > > sd_prot_op() are declared non-static. As such, they will be rebuilt for
> > > each respective function call.
> > >
> > > Optimise by making them static.
> > >
> > > This saves ~100B object code for sd.c:
> > >
> > > Before:
> > > text data bss dec hex filename
> > > 25403 1024 16 26443 674b drivers/scsi/sd.o
> > >
> > > After:
> > > text data bss dec hex filename
> > > 25299 1024 16 26339 66e3 drivers/scsi/sd.o
> >
> > Since the sd_prot_op() function only has a single caller, please move it from sd.h
> > into sd.c.
>
> Can do, as long as no one has objection.
>
> Function sd_prot_flag_mask() also has a single caller AFAICS, so this
> could also be relocated.
Please move that function too from sd.h into sd.c.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-07 17:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 14:41 [PATCH] scsi: sd: Make protection lookup tables static John Garry
2019-01-07 14:41 ` John Garry
2019-01-07 16:57 ` Bart Van Assche
2019-01-07 17:27 ` John Garry
2019-01-07 17:27 ` John Garry
2019-01-07 17:33 ` Bart Van Assche
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.