From: Tom Rini <trini@konsulko.com>
To: Sughosh Ganu <sughosh.ganu@linaro.org>
Cc: Simon Glass <sjg@chromium.org>,
u-boot@lists.denx.de,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Marek Vasut <marex@denx.de>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
Fabio Estevam <festevam@gmail.com>,
Michal Simek <michal.simek@amd.com>
Subject: Re: [RFC PATCH v2 41/48] efi_memory: add an event handler to update memory map
Date: Tue, 16 Jul 2024 11:00:28 -0600 [thread overview]
Message-ID: <20240716170028.GF561963@bill-the-cat> (raw)
In-Reply-To: <CADg8p972kWS9DY_xmNm2uBAz5-y_LtSy0dq2eRTf5dJMCranCw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5589 bytes --]
On Tue, Jul 16, 2024 at 11:55:10AM +0530, Sughosh Ganu wrote:
> On Tue, 16 Jul 2024 at 00:35, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Mon, Jul 15, 2024 at 12:39:32PM +0100, Simon Glass wrote:
> > > Hi Sughosh,
> > >
> > > On Mon, 15 Jul 2024 at 10:39, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
> > > >
> > > > hi Simon,
> > > >
> > > > On Sat, 13 Jul 2024 at 20:46, Simon Glass <sjg@chromium.org> wrote:
> > > > >
> > > > > Hi Sughosh,
> > > > >
> > > > > On Thu, 4 Jul 2024 at 08:38, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
> > > > > >
> > > > > > There are events that would be used to notify other interested modules
> > > > > > of any changes in available and occupied memory. This would happen
> > > > > > when a module allocates or reserves memory, or frees up memory. These
> > > > > > changes in memory map should be notified to other interested modules
> > > > > > so that the allocated memory does not get overwritten. Add an event
> > > > > > handler in the EFI memory module to update the EFI memory map
> > > > > > accordingly when such changes happen. As a consequence, any subsequent
> > > > > > memory request would honour the updated memory map and only available
> > > > > > memory would be allocated from.
> > > > > >
> > > > > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > > > > > ---
> > > > > > Changes since V1:
> > > > > > * Handle the addition of memory to the LMB memory map.
> > > > > > * Pass the overlap_only_ram parameter to the efi_add_memory_map_pg()
> > > > > > based on the type of operation.
> > > > > >
> > > > > > lib/efi_loader/Kconfig | 1 +
> > > > > > lib/efi_loader/efi_memory.c | 34 ++++++++++++++++++++++++++++++++++
> > > > > > 2 files changed, 35 insertions(+)
> > > > > >
> > > > >
> > > > > This is getting complicated and I don't believe it is needed.
> > > > >
> > > > > EFI should not be allocating memory 'in free space' until it starts
> > > > > up. For the very few (if any) cases where it does, it can do an lmb
> > > > > allocation.
> > > >
> > > > EFI memory module is not allocating memory at all now. This patch is
> > > > adding an event handler for updating the EFI memory map, whenever the
> > > > LMB memory map changes. All the EFI allocations are now being routed
> > > > through the LMB API's.
> > >
> > > OK
> > >
> > > >
> > > > >
> > > > > As to the lmb allocations themselves, EFI can simply call look through
> > > > > the lmb list and call efi_add_memory_map_pg() for each entry, when it
> > > > > is ready to boot. There is no need to do it earlier.
> > > >
> > > > So in this case, I believe that rather than adding code in multiple
> > > > places where the EFI memory module would have to get the LMB map and
> > > > then update it's own, I think it is easier to update the EFI memory
> > > > map as and when the LMB map gets updated. Else, we have a scenario
> > > > where the EFI memory map would have to be updated as part of the EFI
> > > > memory map dump function, as well as before the EFI boot. Any new code
> > > > that would be subsequently introduced that might have a similar
> > > > requirement would then be needed to keep this point in mind(to get the
> > > > memory map from LMB).
> > >
> > > That doesn't hold water in my eyes. I actually like the idea of the
> > > EFI memory map being set up before booting. It should be done in a
> > > single function called from one place, just before booting. Well, I
> > > suppose it could be called from the memory-map-dump function too. But
> > > it should be pretty simple...just add some pre-defined things and then
> > > add the lmb records. You can even write a unit test for it.
> > >
> > > >
> > > > This is not an OS file-system kind of an operation where performance
> > > > is critical, nor is this event(LMB memory map update) going to happen
> > > > very frequently. So I believe that it would be better to keep the EFI
> > > > memory map updated along with the LMB one.
> > >
> > > I really don't like that idea at all. One table is enough for use by
> > > U-Boot. The EFI one is needed for booting. Keeping them in sync as
> > > U-Boot is running is not necessary, just invites bugs and makes the
> > > whole thing harder to test.
> >
> > Doesn't that ignore the issue of EFI being re-entrant to us? Or no,
> > because you're suggesting we only update the EFI map before entering the
> > EFI loader, not strictly "booting the OS"? In which case, maybe that
> > does end up being both cleaner and smaller? I'm not sure.
>
> And that is my concern here about having to update the EFI map at
> multiple call points, instead of keeping it updated -- I feel this is
> more prone to being buggy. And to add to this, there might be code
> paths added subsequently which might need an updated EFI map where
> this gets missed. The only downside to the current design is that it
> might be slower since the EFI map gets updated on every change to the
> LMB map. But I am not sure if the LMB map changes are going to be that
> frequent.
To me the question really is, do we have a single entry point to the EFI
loader that must always be used (and is before EFI loader must know for
sure it has up to date memory reservations) or are there two or more
points? If there's two or more points then yes, your current approach is
best as we don't want to introduce problems down the line. If there's
one (which is what I hope), then we can just make that entry point be
where the resync happens.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2024-07-16 17:00 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 7:34 [RFC PATCH v2 00/48] Make U-Boot memory reservations coherent Sughosh Ganu
2024-07-04 7:34 ` [RFC PATCH v2 01/48] malloc: Support testing with realloc() Sughosh Ganu
2024-07-04 7:34 ` [RFC PATCH v2 02/48] lib: Handle a special case with str_to_list() Sughosh Ganu
2024-07-04 7:34 ` [RFC PATCH v2 03/48] alist: Add support for an allocated pointer list Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 04/48] lib: Convert str_to_list() to use alist Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 05/48] alist: add a couple of helper functions Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 06/48] alist: add a function declaration for alist_expand_by() Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 07/48] lmb: remove the unused lmb_is_reserved() function Sughosh Ganu
2024-07-13 15:13 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 08/48] lmb: staticize __lmb_alloc_base() Sughosh Ganu
2024-07-13 15:13 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 09/48] lmb: remove call to lmb_init() Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-15 9:31 ` Sughosh Ganu
2024-07-15 11:39 ` Simon Glass
2024-07-16 6:30 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 10/48] lmb: remove local instances of the lmb structure variable Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-15 9:29 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 11/48] lmb: pass a flag to image_setup_libfdt() for lmb reservations Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 12/48] lmb: allow for resizing lmb regions Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-15 9:27 ` Sughosh Ganu
2024-07-15 11:39 ` Simon Glass
2024-07-16 6:26 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 13/48] lmb: make LMB memory map persistent and global Sughosh Ganu
2024-07-13 15:16 ` Simon Glass
2024-07-15 9:48 ` Sughosh Ganu
2024-07-15 11:39 ` Simon Glass
2024-07-15 17:58 ` Tom Rini
2024-07-15 19:32 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 14/48] lmb: remove config symbols used for lmb region count Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-23 8:48 ` Ilias Apalodimas
2024-07-04 7:35 ` [RFC PATCH v2 15/48] test: lmb: remove the test for max regions Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-22 11:24 ` Ilias Apalodimas
2024-07-04 7:35 ` [RFC PATCH v2 16/48] lmb: config: add lmb config symbols for SPL Sughosh Ganu
2024-07-05 19:48 ` Tom Rini
2024-07-08 11:36 ` Sughosh Ganu
2024-07-08 14:46 ` Tom Rini
2024-07-13 15:15 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 17/48] lmb: allow lmb module to be used in SPL Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-15 9:24 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 18/48] lmb: introduce a function to add memory to the lmb memory map Sughosh Ganu
2024-07-08 14:11 ` Tom Rini
2024-07-04 7:35 ` [RFC PATCH v2 19/48] lmb: remove the lmb_init_and_reserve() function Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-22 12:27 ` Ilias Apalodimas
2024-07-04 7:35 ` [RFC PATCH v2 20/48] lmb: reserve common areas during board init Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 21/48] lmb: remove lmb_init_and_reserve_range() function Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 22/48] lmb: init: initialise the lmb data structures during board init Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 23/48] lmb: use the BIT macro for lmb flags Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 24/48] lmb: add a common implementation of arch_lmb_reserve() Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 25/48] sandbox: spl: enable lmb in SPL Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 26/48] sandbox: iommu: remove lmb allocation in the driver Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 27/48] zynq: lmb: do not add to lmb map before relocation Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 28/48] test: cedit: use allocated address for reading file Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 29/48] test: lmb: tweak the tests for the persistent lmb memory map Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 30/48] test: lmb: run lmb tests only manually Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 31/48] test: lmb: add a separate class of unit tests for lmb Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 32/48] test: lmb: invoke the LMB unit tests from a separate script Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 33/48] test: bdinfo: dump the global LMB memory map Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 34/48] lmb: add versions of the lmb API with flags Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 35/48] lmb: add a flag to allow suppressing memory map change notification Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 36/48] efi: memory: use the lmb API's for allocating and freeing memory Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 37/48] event: add event to notify lmb memory map changes Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 38/48] lib: Kconfig: add a config symbol for getting lmb memory map updates Sughosh Ganu
2024-07-05 19:50 ` Tom Rini
2024-07-22 12:30 ` Ilias Apalodimas
2024-07-22 12:59 ` Sughosh Ganu
2024-07-23 7:09 ` Ilias Apalodimas
2024-07-23 12:42 ` Simon Glass
2024-07-23 14:20 ` Tom Rini
2024-07-24 14:37 ` Simon Glass
2024-07-24 14:52 ` Tom Rini
2024-07-24 15:40 ` Simon Glass
2024-07-24 22:47 ` Tom Rini
2024-07-25 23:32 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 39/48] add a function to check if an address is in RAM memory Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 40/48] lmb: notify of any changes to the LMB memory map Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 41/48] efi_memory: add an event handler to update " Sughosh Ganu
2024-07-13 15:16 ` Simon Glass
2024-07-15 9:39 ` Sughosh Ganu
2024-07-15 11:39 ` Simon Glass
2024-07-15 19:05 ` Tom Rini
2024-07-16 6:25 ` Sughosh Ganu
2024-07-16 7:09 ` Simon Glass
2024-07-16 8:35 ` Sughosh Ganu
2024-07-16 17:00 ` Tom Rini [this message]
2024-07-17 7:58 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 42/48] ti: k3: remove efi_add_known_memory() function definition Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 43/48] layerscape: use the lmb API's to add RAM memory Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 44/48] x86: e820: use the lmb API for adding " Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 45/48] efi_memory: do not add RAM memory to the memory map Sughosh Ganu
2024-07-13 15:15 ` Simon Glass
2024-07-04 7:35 ` [RFC PATCH v2 46/48] lmb: mark the EFI runtime memory regions as reserved Sughosh Ganu
2024-07-13 15:16 ` Simon Glass
2024-07-15 9:41 ` Sughosh Ganu
2024-07-15 11:39 ` Simon Glass
2024-07-16 6:31 ` Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 47/48] test: event: update the expected event dump output Sughosh Ganu
2024-07-04 7:35 ` [RFC PATCH v2 48/48] temp: mx6sabresd: bump up the size limit of the board Sughosh Ganu
2024-07-05 18:36 ` Tom Rini
2024-07-08 14:02 ` [RFC PATCH v2 00/48] Make U-Boot memory reservations coherent Tom Rini
2024-07-22 6:28 ` Sughosh Ganu
2024-07-22 17:33 ` Tom Rini
2024-07-22 17:37 ` Sughosh Ganu
2024-07-23 12:47 ` Simon Glass
2024-07-23 14:48 ` Tom Rini
2024-07-23 14:51 ` Sughosh Ganu
2024-07-23 15:29 ` Tom Rini
2024-07-08 14:35 ` Tom Rini
2024-07-13 15:15 ` Simon Glass
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=20240716170028.GF561963@bill-the-cat \
--to=trini@konsulko.com \
--cc=festevam@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=marex@denx.de \
--cc=mark.kettenis@xs4all.nl \
--cc=michal.simek@amd.com \
--cc=sjg@chromium.org \
--cc=sughosh.ganu@linaro.org \
--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