diff mbox series

[06/19] malloc: Show amount of used space when memory runs out

Message ID 20240829145802.1827952-7-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series vbe: Series part E | expand

Commit Message

Simon Glass Aug. 29, 2024, 2:57 p.m. UTC
Show a bit more information when malloc() space is exhausted and
debugging is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/malloc_simple.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tom Rini Aug. 29, 2024, 5:26 p.m. UTC | #1
On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> Show a bit more information when malloc() space is exhausted and
> debugging is enabled.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  common/malloc_simple.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> index 5a8ec538f8f..f2b3dc53689 100644
> --- a/common/malloc_simple.c
> +++ b/common/malloc_simple.c
> @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
>  	log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
>  		  gd->malloc_limit);
>  	if (new_ptr > gd->malloc_limit) {
> -		log_err("alloc space exhausted\n");
> +		log_err("alloc space exhausted %lx %x\n", new_ptr,
> +			gd->malloc_limit);
>  		return NULL;
>  	}

Since debugging is enabled you should update the error message to say
what the values mean...
Simon Glass Sept. 20, 2024, 7:25 a.m. UTC | #2
Hi Tom,

On Thu, 29 Aug 2024 at 19:26, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> > Show a bit more information when malloc() space is exhausted and
> > debugging is enabled.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  common/malloc_simple.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > index 5a8ec538f8f..f2b3dc53689 100644
> > --- a/common/malloc_simple.c
> > +++ b/common/malloc_simple.c
> > @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
> >       log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
> >                 gd->malloc_limit);
> >       if (new_ptr > gd->malloc_limit) {
> > -             log_err("alloc space exhausted\n");
> > +             log_err("alloc space exhausted %lx %x\n", new_ptr,
> > +                     gd->malloc_limit);
> >               return NULL;
> >       }
>
> Since debugging is enabled you should update the error message to say
> what the values mean...

OK, will do. This message is shown without debugging enabled, so I do
want to keep it short.

Regards,
Simon
Tom Rini Sept. 20, 2024, 2:59 p.m. UTC | #3
On Fri, Sep 20, 2024 at 09:25:44AM +0200, Simon Glass wrote:
> Hi Tom,
> 
> On Thu, 29 Aug 2024 at 19:26, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> > > Show a bit more information when malloc() space is exhausted and
> > > debugging is enabled.
> > >
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > ---
> > >
> > >  common/malloc_simple.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > > index 5a8ec538f8f..f2b3dc53689 100644
> > > --- a/common/malloc_simple.c
> > > +++ b/common/malloc_simple.c
> > > @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
> > >       log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
> > >                 gd->malloc_limit);
> > >       if (new_ptr > gd->malloc_limit) {
> > > -             log_err("alloc space exhausted\n");
> > > +             log_err("alloc space exhausted %lx %x\n", new_ptr,
> > > +                     gd->malloc_limit);
> > >               return NULL;
> > >       }
> >
> > Since debugging is enabled you should update the error message to say
> > what the values mean...
> 
> OK, will do. This message is shown without debugging enabled, so I do
> want to keep it short.

The commit message says "and debugging is enabled", so is that the case
or not?
Simon Glass Sept. 20, 2024, 4:04 p.m. UTC | #4
Hi Tom,

On Fri, 20 Sept 2024 at 16:59, Tom Rini <trini@konsulko.com> wrote:
>
> On Fri, Sep 20, 2024 at 09:25:44AM +0200, Simon Glass wrote:
> > Hi Tom,
> >
> > On Thu, 29 Aug 2024 at 19:26, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> > > > Show a bit more information when malloc() space is exhausted and
> > > > debugging is enabled.
> > > >
> > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > ---
> > > >
> > > >  common/malloc_simple.c | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > > > index 5a8ec538f8f..f2b3dc53689 100644
> > > > --- a/common/malloc_simple.c
> > > > +++ b/common/malloc_simple.c
> > > > @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
> > > >       log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
> > > >                 gd->malloc_limit);
> > > >       if (new_ptr > gd->malloc_limit) {
> > > > -             log_err("alloc space exhausted\n");
> > > > +             log_err("alloc space exhausted %lx %x\n", new_ptr,
> > > > +                     gd->malloc_limit);
> > > >               return NULL;
> > > >       }
> > >
> > > Since debugging is enabled you should update the error message to say
> > > what the values mean...
> >
> > OK, will do. This message is shown without debugging enabled, so I do
> > want to keep it short.
>
> The commit message says "and debugging is enabled", so is that the case
> or not?

Oh, I see. It should say 'not' :-) I will send a new patch.


- Simon
Tom Rini Sept. 20, 2024, 4:35 p.m. UTC | #5
On Fri, Sep 20, 2024 at 06:04:01PM +0200, Simon Glass wrote:
> Hi Tom,
> 
> On Fri, 20 Sept 2024 at 16:59, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Fri, Sep 20, 2024 at 09:25:44AM +0200, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Thu, 29 Aug 2024 at 19:26, Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> > > > > Show a bit more information when malloc() space is exhausted and
> > > > > debugging is enabled.
> > > > >
> > > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > > ---
> > > > >
> > > > >  common/malloc_simple.c | 3 ++-
> > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > > > > index 5a8ec538f8f..f2b3dc53689 100644
> > > > > --- a/common/malloc_simple.c
> > > > > +++ b/common/malloc_simple.c
> > > > > @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
> > > > >       log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
> > > > >                 gd->malloc_limit);
> > > > >       if (new_ptr > gd->malloc_limit) {
> > > > > -             log_err("alloc space exhausted\n");
> > > > > +             log_err("alloc space exhausted %lx %x\n", new_ptr,
> > > > > +                     gd->malloc_limit);
> > > > >               return NULL;
> > > > >       }
> > > >
> > > > Since debugging is enabled you should update the error message to say
> > > > what the values mean...
> > >
> > > OK, will do. This message is shown without debugging enabled, so I do
> > > want to keep it short.
> >
> > The commit message says "and debugging is enabled", so is that the case
> > or not?
> 
> Oh, I see. It should say 'not' :-) I will send a new patch.

Thanks!
Simon Glass Sept. 21, 2024, 11:37 a.m. UTC | #6
Hi Tom,

On Fri, 20 Sept 2024 at 18:35, Tom Rini <trini@konsulko.com> wrote:
>
> On Fri, Sep 20, 2024 at 06:04:01PM +0200, Simon Glass wrote:
> > Hi Tom,
> >
> > On Fri, 20 Sept 2024 at 16:59, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Fri, Sep 20, 2024 at 09:25:44AM +0200, Simon Glass wrote:
> > > > Hi Tom,
> > > >
> > > > On Thu, 29 Aug 2024 at 19:26, Tom Rini <trini@konsulko.com> wrote:
> > > > >
> > > > > On Thu, Aug 29, 2024 at 08:57:49AM -0600, Simon Glass wrote:
> > > > > > Show a bit more information when malloc() space is exhausted and
> > > > > > debugging is enabled.
> > > > > >
> > > > > > Signed-off-by: Simon Glass <sjg@chromium.org>
> > > > > > ---
> > > > > >
> > > > > >  common/malloc_simple.c | 3 ++-
> > > > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/common/malloc_simple.c b/common/malloc_simple.c
> > > > > > index 5a8ec538f8f..f2b3dc53689 100644
> > > > > > --- a/common/malloc_simple.c
> > > > > > +++ b/common/malloc_simple.c
> > > > > > @@ -26,7 +26,8 @@ static void *alloc_simple(size_t bytes, int align)
> > > > > >       log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
> > > > > >                 gd->malloc_limit);
> > > > > >       if (new_ptr > gd->malloc_limit) {
> > > > > > -             log_err("alloc space exhausted\n");
> > > > > > +             log_err("alloc space exhausted %lx %x\n", new_ptr,
> > > > > > +                     gd->malloc_limit);
> > > > > >               return NULL;
> > > > > >       }
> > > > >
> > > > > Since debugging is enabled you should update the error message to say
> > > > > what the values mean...
> > > >
> > > > OK, will do. This message is shown without debugging enabled, so I do
> > > > want to keep it short.
> > >
> > > The commit message says "and debugging is enabled", so is that the case
> > > or not?
> >
> > Oh, I see. It should say 'not' :-) I will send a new patch.
>
> Thanks!

OK done, it is here:

https://patchwork.ozlabs.org/project/uboot/patch/20240921113450.319072-6-sjg@chromium.org/

Regards,
Simon
diff mbox series

Patch

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 5a8ec538f8f..f2b3dc53689 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -26,7 +26,8 @@  static void *alloc_simple(size_t bytes, int align)
 	log_debug("size=%lx, ptr=%lx, limit=%x: ", (ulong)bytes, new_ptr,
 		  gd->malloc_limit);
 	if (new_ptr > gd->malloc_limit) {
-		log_err("alloc space exhausted\n");
+		log_err("alloc space exhausted %lx %x\n", new_ptr,
+			gd->malloc_limit);
 		return NULL;
 	}