mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: chalianis1@gmail.com
Cc: barebox@lists.infradead.org, Ahmad Fatoum <a.fatoum@barebox.org>
Subject: Re: [PATCH v2 03/10] tlsf: support on-demand requesting memory from external store
Date: Tue, 7 Oct 2025 15:42:57 +0200	[thread overview]
Message-ID: <aOUY4c06GbpbTSyt@pengutronix.de> (raw)
In-Reply-To: <20251007005955.1427990-3-chalianis1@gmail.com>

On Mon, Oct 06, 2025 at 08:59:48PM -0400, chalianis1@gmail.com wrote:
> From: Chali Anis <chalianis1@gmail.com>
> 
> barebox running under an operating system (or nearly one like UEFI) does
> not have control over all the memory and should not hog too much memory
> upfront as that can interfere with other applications, e.g. EFI drivers
> or the EFI firmware itself.
> 
> To accommodate this use case, allow TLSF to dynamically request more
> memory from an external store via tlsf_register_store().
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
> Signed-off-by: Chali Anis <chalianis1@gmail.com>
> ---
>  common/tlsf.c  | 29 ++++++++++++++++++++++++++++-
>  include/tlsf.h |  1 +
>  2 files changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/common/tlsf.c b/common/tlsf.c
> index 4ee53a9b2f20..636b57b1c642 100644
> --- a/common/tlsf.c
> +++ b/common/tlsf.c
> @@ -159,6 +159,9 @@ typedef struct control_t
>  	/* Empty lists point at this block to indicate they are free. */
>  	block_header_t block_null;
>  
> +	void (*request_store)(tlsf_t, size_t);
> +
> +

This breaks compilation on 32bit platforms.

The reason is we have this directly under the definition of control_t:

tlsf_static_assert(sizeof(control_t) % ALIGN_SIZE == 0);

I fixed it up as follows.

It looks odd to me that we have to manually align the struct size each
time we add a field to this struct. Isn't there something better?

Sascha

---------------------------8<------------------------------
>From 11fcc69bbc41954d5e28a3b082dc39171bd6cdc0 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Tue, 7 Oct 2025 15:39:38 +0200
Subject: [PATCH] fixup! tlsf: support on-demand requesting memory from
 external store

---
 common/tlsf.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/common/tlsf.c b/common/tlsf.c
index 636b57b1c6..c4ba8259b2 100644
--- a/common/tlsf.c
+++ b/common/tlsf.c
@@ -161,11 +161,9 @@ typedef struct control_t
 
 	void (*request_store)(tlsf_t, size_t);
 
-
 	/* Bitmaps for free lists. */
 	unsigned int fl_bitmap;
 	unsigned int sl_bitmap[FL_INDEX_COUNT];
-	u32 : BYTES_TO_BITS(ALIGN_SIZE - sizeof(size_t));
 
 	/* Head of free lists. */
 	block_header_t* blocks[FL_INDEX_COUNT][SL_INDEX_COUNT];
-- 
2.47.3


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2025-10-07 13:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  0:59 [PATCH v2 01/10] efi: payload: split out payload Kconfig symbols chalianis1
2025-10-07  0:59 ` [PATCH v2 02/10] tlsf: move kasan_poison_shadow into tlsf_add_pool chalianis1
2025-10-07  0:59 ` [PATCH v2 03/10] tlsf: support on-demand requesting memory from external store chalianis1
2025-10-07 13:42   ` Sascha Hauer [this message]
2025-10-07 14:34     ` Ahmad Fatoum
2025-10-07  0:59 ` [PATCH v2 04/10] efi: payload: add support for EFI initrd media protocol chalianis1
2025-10-07  0:59 ` [PATCH v2 05/10] efi: payload: earlymem: allocate only the barebox needs in term of memory chalianis1
2025-10-07  0:59 ` [PATCH v2 06/10] efi: payload: split image handling from legacy handover boot and add linux x86 image filetype chalianis1
2025-10-07  0:59 ` [PATCH v2 07/10] efi: payload: bootm: add support for efi stub boot chalianis1
2025-10-07  0:59 ` [PATCH v2 08/10] efi: payload: bootm: add support for fit image chalianis1
2025-10-07  0:59 ` [PATCH v2 09/10] efi: payload: make selectable without COMPILE_TEST chalianis1
2025-10-07  0:59 ` [PATCH v2 10/10] ARM: efi: add a generic defconfig for v8 efi payload chalianis1
2025-10-07 10:15 ` [PATCH v2 01/10] efi: payload: split out payload Kconfig symbols Sascha Hauer

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=aOUY4c06GbpbTSyt@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=chalianis1@gmail.com \
    /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