From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
Qiang Zhao <qiang.zhao@nxp.com>, Li Yang <leoyang.li@nxp.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Scott Wood <oss@buserror.net>,
Rasmus Villemoes <Rasmus.Villemoes@prevas.se>,
Rob Herring <robh+dt@kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/5] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K
Date: Wed, 1 May 2019 05:51:26 +0000 [thread overview]
Message-ID: <cb6a20d0-5ff1-8be9-5e3a-bd5c881dbae6@prevas.dk> (raw)
In-Reply-To: <51b00425-58a7-089a-67a9-61cd315d5097@c-s.fr>
On 30/04/2019 19.12, Christophe Leroy wrote:
>
> Le 30/04/2019 à 15:36, Rasmus Villemoes a écrit :
>> The current array of struct qe_snum use 256*4 bytes for just keeping
>> track of the free/used state of each index, and the struct layout
>> means there's another 768 bytes of padding. If we just unzip that
>> structure, the array of snum values just use 256 bytes, while the
>> free/inuse state can be tracked in a 32 byte bitmap.
>>
>> So this reduces the .data footprint by 1760 bytes. It also serves as
>> preparation for introducing another DT binding for specifying the snum
>> values.
>>
>> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
>> ---
>> -
>> /* We allocate this here because it is used almost exclusively for
>> * the communication processor devices.
>> */
>> struct qe_immap __iomem *qe_immr;
>> EXPORT_SYMBOL(qe_immr);
>> -static struct qe_snum snums[QE_NUM_OF_SNUM]; /* Dynamically
>> allocated SNUMs */
>> +static u8 snums[QE_NUM_OF_SNUM]; /* Dynamically allocated SNUMs */
>> +static DECLARE_BITMAP(snum_state, QE_NUM_OF_SNUM);
>> static unsigned int qe_num_of_snum;
>> static phys_addr_t qebase = -1;
>> @@ -308,6 +298,7 @@ static void qe_snums_init(void)
>> };
>> const u8 *snum_init;
>> + bitmap_zero(snum_state, QE_NUM_OF_SNUM);
>
> Doesn't make much importance, but wouldn't it be more logical to add
> this line where the setting of .state = QE_SNUM_STATE_FREE was done
> previously, ie around the for() loop below ?
This was on purpose, to avoid having to move it up in patch 4, where we
don't necessarily reach the for loop.
>> qe_num_of_snum = qe_get_num_of_snums();
>> if (qe_num_of_snum == 76)
>> @@ -315,10 +306,8 @@ static void qe_snums_init(void)
>> else
>> snum_init = snum_init_46;
>> - for (i = 0; i < qe_num_of_snum; i++) {
>> - snums[i].num = snum_init[i];
>> - snums[i].state = QE_SNUM_STATE_FREE;
>> - }
>> + for (i = 0; i < qe_num_of_snum; i++)
>> + snums[i] = snum_init[i];
>
> Could use memcpy() instead ?
Yes, I switch to that in 5/5. Sure, I could do it here already, but I
did it this way to keep close to the current style. I don't care either
way, so if you prefer introducing memcpy here, fine by me.
>> spin_unlock_irqrestore(&qe_lock, flags);
>> @@ -346,8 +333,8 @@ void qe_put_snum(u8 snum)
>> int i;
>> for (i = 0; i < qe_num_of_snum; i++) {
>> - if (snums[i].num == snum) {
>> - snums[i].state = QE_SNUM_STATE_FREE;
>> + if (snums[i] == snum) {
>> + clear_bit(i, snum_state);
>> break;
>> }
>> }
>
> Can we replace this loop by memchr() ?
Hm, yes. So that would be
const u8 *p = memchr(snums, snum, qe_num_of_snum)
if (p)
clear_bit(p - snums, snum_state);
I guess. Let me fold that in and see how it looks.
Thanks,
Rasmus
next prev parent reply other threads:[~2019-05-01 5:51 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 13:36 [PATCH RESEND 0/5] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-04-30 13:36 ` [PATCH 1/5] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-04-30 17:03 ` Christophe Leroy
2019-04-30 13:36 ` [PATCH 2/5] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-04-30 17:12 ` Christophe Leroy
2019-05-01 5:51 ` Rasmus Villemoes [this message]
2019-04-30 13:36 ` [PATCH 3/5] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-04-30 17:14 ` Christophe Leroy
2019-04-30 13:36 ` [PATCH 4/5] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-04-30 17:19 ` Christophe Leroy
2019-05-01 6:00 ` Rasmus Villemoes
2019-04-30 13:36 ` [PATCH 5/5] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-04-30 17:27 ` Christophe Leroy
2019-05-01 9:29 ` [PATCH v2 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-05-01 9:29 ` [PATCH v2 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-05-01 9:29 ` [PATCH v2 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-05-02 4:51 ` Christophe Leroy
2019-05-01 9:29 ` [PATCH v2 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-05-01 9:29 ` [PATCH v2 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Rasmus Villemoes
2019-05-01 15:12 ` Joakim Tjernlund
2019-05-01 18:47 ` Rasmus Villemoes
2019-05-01 21:00 ` Rob Herring
2019-05-01 9:29 ` [PATCH v2 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-05-02 4:52 ` Christophe Leroy
2019-05-01 9:29 ` [PATCH v2 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-05-02 4:54 ` Christophe Leroy
2019-05-09 2:35 ` [EXT] " Qiang Zhao
2019-05-13 11:14 ` [PATCH v3 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-05-13 11:14 ` [PATCH v3 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-05-13 11:14 ` [PATCH v3 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-05-13 11:14 ` [PATCH v3 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-05-13 11:14 ` [PATCH v3 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Rasmus Villemoes
2019-05-13 11:39 ` Joakim Tjernlund
2019-05-13 17:51 ` Rob Herring
2019-05-13 11:15 ` [PATCH v3 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-05-13 11:15 ` [PATCH v3 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-06-03 19:53 ` [PATCH v3 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-06-03 19:55 ` Leo Li
2019-06-04 20:29 ` Li Yang
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=cb6a20d0-5ff1-8be9-5e3a-bd5c881dbae6@prevas.dk \
--to=rasmus.villemoes@prevas.dk \
--cc=Rasmus.Villemoes@prevas.se \
--cc=christophe.leroy@c-s.fr \
--cc=leoyang.li@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=oss@buserror.net \
--cc=qiang.zhao@nxp.com \
--cc=robh+dt@kernel.org \
/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
all inboxes | Powered by JetHome®