From: Tom Rini <trini@konsulko.com>
To: Simon Glass <sjg@chromium.org>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
Marek Vasut <marex@denx.de>, Bin Meng <bmeng@tinylab.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Nikhil M Jain <n-jain1@ti.com>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Stefan Roese <sr@denx.de>
Subject: Re: [PATCH 09/32] spl: Avoid an #ifdef when printing gd->malloc_ptr
Date: Fri, 22 Sep 2023 15:28:47 -0400 [thread overview]
Message-ID: <20230922192847.GD305624@bill-the-cat> (raw)
In-Reply-To: <CAPnjgZ0ZqySaVa6LKWz7p7h8gjH1yTsLtds_8hF+DEXQGC459g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4370 bytes --]
On Fri, Sep 22, 2023 at 12:27:36PM -0600, Simon Glass wrote:
> Hi Tom,
>
> On Thu, 21 Sept 2023 at 09:36, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Wed, Sep 20, 2023 at 07:03:34PM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Wed, 30 Aug 2023 at 15:39, Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Wed, Aug 30, 2023 at 12:04:40PM -0600, Simon Glass wrote:
> > > > > Use an accessor in the header file to avoid this.
> > > > >
> > > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > > ---
> > > > >
> > > > > common/spl/spl.c | 9 +++++----
> > > > > include/asm-generic/global_data.h | 7 +++++++
> > > > > 2 files changed, 12 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/common/spl/spl.c b/common/spl/spl.c
> > > > > index f0a90c280da..f5cef81000c 100644
> > > > > --- a/common/spl/spl.c
> > > > > +++ b/common/spl/spl.c
> > > > > @@ -876,10 +876,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> > > > > } else {
> > > > > debug("Unsupported OS image.. Jumping nevertheless..\n");
> > > > > }
> > > > > -#if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SPL_SYS_MALLOC_SIZE)
> > > > > - debug("SPL malloc() used 0x%lx bytes (%ld KB)\n", gd->malloc_ptr,
> > > > > - gd->malloc_ptr / 1024);
> > > > > -#endif
> > > > > + if (IS_ENABLED(CONFIG_SYS_MALLOC_F) &&
> > > > > + !IS_ENABLED(CONFIG_SPL_SYS_MALLOC_SIZE))
> > > > > + debug("SPL malloc() used 0x%lx bytes (%ld KB)\n",
> > > > > + gd_malloc_ptr(), gd_malloc_ptr() / 1024);
> >
> > This is not more readable. But I guess my comment was unclear as you're
> > mixing changes here. gd_malloc_ptr() rather than gd->malloc_ptr is a
> > wash, to me. I think one could argue it's not a helpful abstraction.
> > but it's so that you can avoid CONFIG_VAL here, and say "if (...)" not
> > "#if ..." here.
>
> Yes,
>
> >
> > > > > +
> > > > > bootstage_mark_name(get_bootstage_id(false), "end phase");
> > > > > #ifdef CONFIG_BOOTSTAGE_STASH
> > > > > ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
> > > > > diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
> > > > > index 8fc205ded1a..edf9ff6823f 100644
> > > > > --- a/include/asm-generic/global_data.h
> > > > > +++ b/include/asm-generic/global_data.h
> > > > > @@ -573,6 +573,13 @@ static_assert(sizeof(struct global_data) == GD_SIZE);
> > > > > #define gd_malloc_start() 0
> > > > > #define gd_set_malloc_start(val)
> > > > > #endif
> > > > > +
> > > > > +#if CONFIG_VAL(SYS_MALLOC_F_LEN)
> > > > > +#define gd_malloc_ptr() gd->malloc_ptr
> > > > > +#else
> > > > > +#define gd_malloc_ptr() 0L
> > > > > +#endif
> > > > > +
> > > > > /**
> > > > > * enum gd_flags - global data flags
> > > > > *
> > > >
> > > > This is another case where readability is not improved. I also have a
> > > > bad feeling that changing that exact area had some unintended
> > > > consequences from the compiler, that totally should not have happened.
> > > > But maybe that was something in a similar code section instead.
> > >
> > > The improvement is in the C file...here we have an accessor in the
> > > header file as has been done elsewhere.
> > >
> > > Do you have any more details on the problem you mention? I will align
> > > the accessor to the struct member which should resolve it.
> >
> > It's unfortunately one of those cases to do a global before/after build
> > and see if anything does or does not get tripped up. As I believe I did
> > use CONFIG_VAL there and not a check on CONFIG_SYS_MALLOC_F itself for a
> > reason, at the time.
>
> But the CONFIG_VAL symbols actually depends on CONFIG_SYS_MALLOC_F, so
> I can't imagine what it might be. Of course if the value is 0, then
> the 'if CONFIG_VAL()' test would fail, but to what purpose?
Yes, there's been a time or two where I banged my head against the
figurative wall trying to understand what exactly the compiler could be
seeing as why to change something. I don't have a "reasonable"
explanation. Readability aside, "tidy things up" changes need to be on
their own so that their impact can be seen aside from the new
functionality changes.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2023-09-22 19:28 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 18:04 [PATCH 00/32] spl: Preparation for Universal Payload Simon Glass
2023-08-30 18:04 ` [PATCH 01/32] dm: core: support reading a single indexed u64 value Simon Glass
2023-08-30 18:04 ` [PATCH 02/32] spl: Use CONFIG_SPL... instead of CONFIG_..._SPL_ Simon Glass
2023-08-31 7:37 ` Marcel Ziswiler
2023-08-31 8:42 ` Martyn Welch
2023-08-31 9:22 ` Svyatoslav Ryhel
2023-08-30 18:04 ` [PATCH 03/32] spl: Rename SYS_SPL_ARGS_ADDR to SPL_SYS_ARGS_ADDR Simon Glass
2023-08-30 21:37 ` Tom Rini
2023-08-30 18:04 ` [PATCH 04/32] spl: Avoid #ifdef with CONFIG_SPL_SYS_MALLOC Simon Glass
2023-08-30 21:32 ` Tom Rini
2023-08-30 18:04 ` [PATCH 05/32] spl: mx6: powerpc: Drop the condition on timer_init() Simon Glass
2023-08-31 17:50 ` Tom Rini
2023-09-21 1:03 ` Simon Glass
2023-09-26 11:37 ` Simon Glass
2023-09-26 13:38 ` Christophe Leroy
2023-08-30 18:04 ` [PATCH 06/32] spl: Drop #ifdefs for BOARD_INIT and watchdog Simon Glass
2023-08-30 18:04 ` [PATCH 07/32] spl: Avoid #ifdef with CONFIG_SPL_SYS_ARGS_ADDR Simon Glass
2023-08-30 21:34 ` Tom Rini
2023-08-30 18:04 ` [PATCH 08/32] spl: Drop the switch() statement for OS selection Simon Glass
2023-08-30 18:04 ` [PATCH 09/32] spl: Avoid an #ifdef when printing gd->malloc_ptr Simon Glass
2023-08-30 21:39 ` Tom Rini
2023-09-21 1:03 ` Simon Glass
2023-09-21 15:35 ` Tom Rini
2023-09-22 18:27 ` Simon Glass
2023-09-22 19:28 ` Tom Rini [this message]
2023-09-22 23:06 ` Simon Glass
2023-08-30 18:04 ` [PATCH 10/32] spl: Remove #ifdefs with BOOTSTAGE Simon Glass
2023-08-30 18:04 ` [PATCH 11/32] spl: Rename spl_load_fit_image() to load_simple_fit() Simon Glass
2023-08-30 18:04 ` [PATCH 12/32] spl: Move the full FIT code to spl_fit.c Simon Glass
2023-08-30 18:04 ` [PATCH 13/32] spl: Use the correct FIT_..._PROP constants Simon Glass
2023-08-30 18:04 ` [PATCH 14/32] spl: Move bloblist writing until the image is known Simon Glass
2023-08-30 18:04 ` [PATCH 15/32] dm: core: Reverse the argument order in ofnode_copy_props() Simon Glass
2023-08-30 18:04 ` [PATCH 16/32] dm: core: Ensure we run flattree tests on ofnode Simon Glass
2023-08-30 18:04 ` [PATCH 17/32] dm: core: Tidy up comments in the ofnode tests Simon Glass
2023-08-30 18:04 ` [PATCH 18/32] dm: core: Add a function to create an empty tree Simon Glass
2023-08-30 18:04 ` [PATCH 19/32] dm: core: Add a way to copy a node Simon Glass
2023-08-30 18:04 ` [PATCH 20/32] dm: core: Add a way to delete " Simon Glass
2023-08-30 18:04 ` [PATCH 21/32] dm: core: Add a way to convert a devicetree to a dtb Simon Glass
2023-08-30 18:04 ` [PATCH 22/32] dm: core: Support writing a boolean Simon Glass
2023-08-30 18:04 ` [PATCH 23/32] dm: core: Support writing a 64-bit value Simon Glass
2023-08-30 18:04 ` [PATCH 24/32] dm: core: Add tests for oftree_path() Simon Glass
2023-08-30 18:04 ` [PATCH 25/32] sandbox: Move reading the RAM buffer into a better place Simon Glass
2023-08-30 18:04 ` [PATCH 26/32] sandbox: Init the EC properly even if no state file is available Simon Glass
2023-08-30 18:04 ` [PATCH 27/32] sandbox: Only read the state if we have a state file Simon Glass
2023-08-30 18:04 ` [PATCH 28/32] sandbox: Move the bloblist down a little in memory Simon Glass
2023-08-30 18:05 ` [PATCH 29/32] bloblist: Support initing from multiple places Simon Glass
2023-08-30 18:05 ` [PATCH 30/32] fdt: Allow the devicetree to come from a bloblist Simon Glass
2023-08-31 7:06 ` Ilias Apalodimas
2023-08-31 19:02 ` Simon Glass
2023-09-01 7:49 ` Ilias Apalodimas
2023-09-01 15:51 ` Simon Glass
2023-09-04 9:30 ` Ilias Apalodimas
2023-09-10 19:13 ` Simon Glass
2023-09-11 6:17 ` Ilias Apalodimas
2023-09-11 6:38 ` Michal Simek
2023-09-11 7:56 ` Ilias Apalodimas
2023-09-11 10:58 ` Michal Simek
2023-09-11 11:47 ` Ilias Apalodimas
2023-09-21 1:03 ` Simon Glass
2023-09-25 10:18 ` Ilias Apalodimas
2023-10-18 15:26 ` Simon Glass
2023-10-20 8:21 ` Ilias Apalodimas
2023-10-20 13:59 ` Tom Rini
2023-10-20 15:13 ` Simon Glass
2023-08-30 18:05 ` [PATCH 31/32] command: Include a required header in command.h Simon Glass
2023-08-30 18:05 ` [PATCH 32/32] pci: serial: Support reading PCI-register size with base Simon Glass
2023-08-30 18:14 ` Pali Rohár
2023-08-30 18:17 ` Tom Rini
2023-08-30 18:39 ` Pali Rohár
2023-08-30 19:04 ` Tom Rini
2023-08-30 19:10 ` Pali Rohár
2023-08-30 19:41 ` Tom Rini
2023-08-30 19:44 ` Pali Rohár
2023-08-30 20:51 ` Pali Rohár
2023-08-30 21:08 ` Tom Rini
2023-08-30 21:13 ` Pali Rohár
2023-08-30 21:26 ` Tom Rini
2023-08-30 21:29 ` Pali Rohár
2023-08-30 21:42 ` Tom Rini
2023-09-03 20:36 ` Pali Rohár
2023-09-04 19:55 ` Tom Rini
2023-09-04 20:07 ` Pali Rohár
2023-09-03 20:39 ` Pali Rohár
2023-09-04 20:15 ` Pali Rohár
2023-09-04 20:27 ` Tom Rini
2023-09-04 21:07 ` Pali Rohár
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=20230922192847.GD305624@bill-the-cat \
--to=trini@konsulko.com \
--cc=bmeng@tinylab.org \
--cc=marex@denx.de \
--cc=n-jain1@ti.com \
--cc=nathan.morrison@timesys.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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