Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240106
| Path | csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Julian Calaby <julian.calaby@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k |
| Date | Tue, 06 Oct 2015 03:40:02 +0200 |
| Message-ID | <qgpou-8an-3@gated-at.bofh.it> (permalink) |
| References | <qetwe-3ox-29@gated-at.bofh.it> <qfyDw-8hJ-13@gated-at.bofh.it> <qfDjP-6BW-1@gated-at.bofh.it> |
| X-Original-To | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=VcL3vIIdsZhNAvRDskAlVWWm53ow6LuiEsQ7EPiAy+k=; b=GO7HkKazVpJCdbvQOCPzXqnwmWDjtIpoUsXCDmOjA3cYlA/bhgjTF+hYUrWOBIa/QC p0NDygt6YsOQFx7JkX1JK7UdTCQgtkvMOrSw/ITA7zYbIAYjvTOBIrpm6IMIvXlgLhFy rde+/JhkxDArJaPA5T8AD7vkP9eUKh7BPu/cUKu9f7hsbsI5oqLom+9MHEncLQrSYf+w u5vLX3NmUpykWBRf4P7Bapuz70cQD9O0CYxlCVGutnDzVKh5iplHrRS451MO8BvOVd3x iX0mDPkBhClV0hFXYs7oEq1iovFSy3EYFdRgYJVdMi1MCQQebTxt34CYDzXKB245qa1O Sy3A== |
| X-Received | by 10.107.165.140 with SMTP id o134mr29755262ioe.29.1444095186656; Mon, 05 Oct 2015 18:33:06 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 95 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Christoph Hellwig <hch@infradead.org>, Hannes Reinecke <hare@suse.de>, "James E.J. Bottomley" <JBottomley@odin.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, linux-scsi <linux-scsi@vger.kernel.org> |
| X-Original-Date | Tue, 6 Oct 2015 12:32:47 +1100 |
| X-Original-Message-ID | <CAGRGNgXt6qt4K+O9u+Y45rZNh07X=6wh7CdCwJ4mwiYkjXyCWA@mail.gmail.com> |
| X-Original-References | <87h9mbg6h1.fsf@rasmusvillemoes.dk> <20151003171437.GA20847@infradead.org> <87bncf1u4p.fsf@rasmusvillemoes.dk> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1240106 |
Show key headers only | View raw
Hi Rasmus,
On Sun, Oct 4, 2015 at 9:09 AM, Rasmus Villemoes
<linux@rasmusvillemoes.dk> wrote:
> Subject: [PATCH 2/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k
>
> On 64 bit, struct error_info has 6 bytes of padding, which amounts to
> over 4k of wasted space in the additional[] array. We could easily get
> rid of that by instead using separate arrays for the codes and the
> pointers. However, we can do even better than that and save an
> additional 6 bytes per entry: In the table, just store the sizeof()
> the corresponding string literal. The cumulative sum of these is then
> the appropriate offset into additional_text, which is built from the
> concatenation (with '\0's inbetween) of the strings.
>
> $ scripts/bloat-o-meter /tmp/vmlinux vmlinux
> add/remove: 0/0 grow/shrink: 1/1 up/down: 24/-8488 (-8464)
> function old new delta
> scsi_extd_sense_format 136 160 +24
> additional 11312 2824 -8488
Quick question:
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/scsi/constants.c | 25 +++++++++++++++++++++----
> drivers/scsi/sense_codes.h | 2 --
> 2 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 47aaccd5e68e..ccd34b0481cd 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -292,17 +292,31 @@ bool scsi_opcode_sa_name(int opcode, int service_action,
>
> struct error_info {
> unsigned short code12; /* 0x0302 looks better than 0x03,0x02 */
> - const char * text;
> + unsigned short size;
> };
>
>
> +/*
> + * There are 700+ entries in this table. To save space, we don't store
> + * (code, pointer) pairs, which would make sizeof(struct
> + * error_info)==16 on 64 bits. Rather, the second element just stores
> + * the size (including \0) of the corresponding string, and we use the
> + * sum of these to get the appropriate offset into additional_text
> + * defined below. This approach saves 12 bytes per entry.
> + */
> static const struct error_info additional[] =
> {
> -#define SENSE_CODE(c, s) {c, s},
> +#define SENSE_CODE(c, s) {c, sizeof(s)},
> #include "sense_codes.h"
> #undef SENSE_CODE
> };
>
> +static const char *additional_text =
> +#define SENSE_CODE(c, s) s "\0"
> +#include "sense_codes.h"
> +#undef SENSE_CODE
> + ;
> +
> struct error_info2 {
> unsigned char code1, code2_min, code2_max;
> const char * str;
> @@ -364,11 +378,14 @@ scsi_extd_sense_format(unsigned char asc, unsigned char ascq, const char **fmt)
> {
> int i;
> unsigned short code = ((asc << 8) | ascq);
> + unsigned offset = 0;
>
> *fmt = NULL;
> - for (i = 0; additional[i].text; i++)
> + for (i = 0; i < ARRAY_SIZE(additional); i++) {
> if (additional[i].code12 == code)
> - return additional[i].text;
> + return additional_text + offset;
> + offset += additional[i].size;
You don't seem to be accounting for the null bytes here.
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-09-30 19:40 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Christoph Hellwig <hch@infradead.org> - 2015-10-03 19:20 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-04 00:20 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Christoph Hellwig <hch@infradead.org> - 2015-10-04 10:10 +0200
[PATCH 0/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-05 11:30 +0200
[PATCH 2/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-05 11:30 +0200
Re: [PATCH 2/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-06 17:40 +0200
Re: [PATCH 1/2] scsi: move Additional Sense Codes to separate file Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-06 17:30 +0200
Re: [PATCH 1/2] scsi: move Additional Sense Codes to separate file Rasmus Villemoes <rv@rasmusvillemoes.dk> - 2015-10-18 00:20 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Julian Calaby <julian.calaby@gmail.com> - 2015-10-06 03:40 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-10-06 17:40 +0200
Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k Julian Calaby <julian.calaby@gmail.com> - 2015-10-07 01:10 +0200
csiph-web