[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH] lib/ukdebug: Print bottom of stack instead of thread name



Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx>

Simon Kuenzer <simon.kuenzer@xxxxxxxxx> writes:

> The option of printing the thread name of the one
> issueing a uk_printd() call did not work all the
> time and causes the system to access invalid memory
> addresses for retrieving the thread name string. The
> reason is that we currently do not have a fast and
> efficient way to differentiate if a stack was created
> by libuksched or not (e.g., boot stacks, interrupt stacks).
>
> This patch changes this option to print the bottom
> address of the current stack instead. This way, the user
> can still distinguish different threads or stack types
> by their stack address and we remove any dependency to
> other libraries or system configuration.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
>  lib/ukdebug/Config.uk |  8 ++++----
>  lib/ukdebug/print.c   | 30 ++++++++++--------------------
>  2 files changed, 14 insertions(+), 24 deletions(-)
>
> diff --git a/lib/ukdebug/Config.uk b/lib/ukdebug/Config.uk
> index 2a1ea7e..dcaeb3a 100644
> --- a/lib/ukdebug/Config.uk
> +++ b/lib/ukdebug/Config.uk
> @@ -44,10 +44,10 @@ config LIBUKDEBUG_PRINTD_TIME
>       default y
>       depends on LIBUKDEBUG_PRINTD
>  
> -config LIBUKDEBUG_PRINTD_THREAD
> -     bool "Show name of thread in debug messages"
> -     default y
> -     depends on LIBUKDEBUG_PRINTD && LIBUKSCHED
> +config LIBUKDEBUG_PRINTD_STACK
> +     bool "Print bottom address of stack in debug messages"
> +     default n
> +     depends on LIBUKDEBUG_PRINTD
>  
>  choice
>       prompt "Message redirection"
> diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c
> index 9673dc9..42dca4a 100644
> --- a/lib/ukdebug/print.c
> +++ b/lib/ukdebug/print.c
> @@ -44,9 +44,6 @@
>  #include <uk/plat/console.h>
>  #include <uk/plat/time.h>
>  #include <uk/print.h>
> -#if LIBUKSCHED
> -#include <uk/thread.h>
> -#endif
>  #include <uk/errptr.h>
>  #include <uk/arch/lcpu.h>
>  
> @@ -96,24 +93,17 @@ static void _printd_timestamp(void)
>  }
>  #endif
>  
> -#if LIBUKDEBUG_PRINTD_THREAD
> -static void _printd_thread(void)
> +#if LIBUKDEBUG_PRINTD_STACK
> +static void _printd_stack(void)
>  {
> -     struct uk_thread *thread;
> +     unsigned long stackb;
> +     char buf[BUFLEN];
> +     int len;
>  
> -     thread = uk_thread_current();
> -     if (!PTRISERR(thread) && thread->name) {
> -             _ukplat_coutd("<", 1);
> -             _ukplat_coutd((char *)thread->name,
> -                             strlen(thread->name));
> -             _ukplat_coutd("> ", 2);
> -     } else {
> -             char buf[BUFLEN];
> -             int len;
> +     stackb = (ukarch_read_sp() & ~(__STACK_SIZE - 1)) + __STACK_SIZE;
>  
> -             len = snprintf(buf, BUFLEN, "<%p> ", thread);
> -             _ukplat_coutd((char *)buf, len);
> -     }
> +     len = snprintf(buf, BUFLEN, "<%p> ", (void *) stackb);
> +     _ukplat_coutd((char *)buf, len);
>  }
>  #endif
>  
> @@ -175,8 +165,8 @@ static inline void _vprintd(int lvl, const char *libname, 
> const char *srcname,
>                       _printd_timestamp();
>  #endif
>                       _ukplat_coutd(DECONST(char *, msghdr), 6);
> -#if LIBUKDEBUG_PRINTD_THREAD
> -                     _printd_thread();
> +#if LIBUKDEBUG_PRINTD_STACK
> +                     _printd_stack();
>  #endif
>                       if (libname) {
>                               _ukplat_coutd("[", 1);
> -- 
> 2.7.4
>

-- 
Yuri Volchkov
Software Specialist

NEC Europe Ltd
Kurfürsten-Anlage 36
D-69115 Heidelberg

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.