[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20141124145752.ab64fd85.akpm@linux-foundation.org>
Date: Mon, 24 Nov 2014 14:57:52 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Joonsoo Kim <iamjoonsoo.kim@....com>
Cc: Mel Gorman <mgorman@...e.de>, Johannes Weiner <hannes@...xchg.org>,
Minchan Kim <minchan@...nel.org>, Dave Hansen <dave@...1.net>,
Michal Nazarewicz <mina86@...a86.com>,
Jungsoo Son <jungsoo.son@....com>,
Ingo Molnar <mingo@...hat.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 5/8] stacktrace: introduce snprint_stack_trace for
buffer output
On Mon, 24 Nov 2014 17:15:23 +0900 Joonsoo Kim <iamjoonsoo.kim@....com> wrote:
> Current stacktrace only have the function for console output.
> page_owner that will be introduced in following patch needs to print
> the output of stacktrace into the buffer for our own output format
> so so new function, snprint_stack_trace(), is needed.
>
> ...
>
> +int snprint_stack_trace(char *buf, size_t size,
> + struct stack_trace *trace, int spaces)
> +{
> + int i;
> + unsigned long ip;
> + int generated;
> + int total = 0;
> +
> + if (WARN_ON(!trace->entries))
> + return 0;
> +
> + for (i = 0; i < trace->nr_entries; i++) {
> + ip = trace->entries[i];
> + generated = snprintf(buf, size, "%*c[<%p>] %pS\n",
> + 1 + spaces, ' ', (void *) ip, (void *) ip);
> +
> + total += generated;
> +
> + /* Assume that generated isn't a negative number */
> + if (generated >= size) {
> + buf += size;
> + size = 0;
Seems strange to keep looping around doing nothing. Would it be better
to `break' here?
> + } else {
> + buf += generated;
> + size -= generated;
> + }
> + }
> +
> + return total;
> +}
> +EXPORT_SYMBOL_GPL(snprint_stack_trace);
> +
--
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