[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1208885594.8636.23.camel@localhost>
Date: Tue, 22 Apr 2008 10:33:14 -0700
From: Joe Perches <joe@...ches.com>
To: Eric Sandeen <sandeen@...deen.net>
Cc: Ingo Molnar <mingo@...e.hu>,
linux-kernel Mailing List <linux-kernel@...r.kernel.org>,
Arjan van de Ven <arjan@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] Fix max-stack calculators to skip canary
On Tue, 2008-04-22 at 12:18 -0500, Eric Sandeen wrote:
> Index: linux-2.6.25/kernel/exit.c
> ===================================================================
> --- linux-2.6.25.orig/kernel/exit.c 2008-04-20 22:34:16.000000000 -0500
> +++ linux-2.6.25/kernel/exit.c 2008-04-22 11:38:05.769412824 -0500
> @@ -826,6 +826,8 @@ static void check_stack_usage(void)
> unsigned long *n = end_of_stack(current);
> unsigned long free;
>
> + n++; /* skip over canary at end */
> +
> while (*n == 0)
> n++;
> free = (unsigned long)n - (unsigned long)end_of_stack(current);
> Index: linux-2.6.25/kernel/sched.c
> ===================================================================
> --- linux-2.6.25.orig/kernel/sched.c 2008-04-20 22:34:19.000000000 -0500
> +++ linux-2.6.25/kernel/sched.c 2008-04-22 11:48:06.975407495 -0500
> @@ -5190,6 +5190,8 @@ void sched_show_task(struct task_struct
> #ifdef CONFIG_DEBUG_STACK_USAGE
> {
> unsigned long *n = end_of_stack(p);
> +
> + n++; /* skip over canary at end */
> while (!*n)
> n++;
> free = (unsigned long)n - (unsigned long)end_of_stack(p);
>
Wouldn't it be better to have exactly the same code?
How about using a statement expression macro?
#define DEBUG_STACK_FREE(process) \
({ \
unsigned long *n = end_of_stack(process); \
do { /* Skip over canary */\
n++; \
} while (!*n); \
(unsigned long)n - (unsigned long)end_of_stack(process); \
})
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists