Re: [PATCH 16/24] link_path_walk: kill the recursion

From: Linus Torvalds
Date: Mon Apr 20 2015 - 17:05:01 EST


On Mon, Apr 20, 2015 at 11:13 AM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> */
> static int link_path_walk(const char *name, struct nameidata *nd)
> {
> + struct saved {
> + struct path link;
> + void *cookie;
> + const char *name;
> + } stack[MAX_NESTED_LINKS], *last = stack + nd->depth - 1;
> struct path next;
> int err;

I was going to complain about this, and suggest that you move it to
the nameidata, but I see that you did that later.

That said, you then introduce a stack-allocated "struct saved stack[]"
in path_mountpoint[] instead, *and* nameidata is saved on stack, so
this all ends up being very stack-intensive anyway.

I might have missed some patch here, but would it be possible to just
allocate a single per-thread nameidata, and just leave it at that?
Because allocating that thing on the stack when it contains what is
now one kilobyte of array data is *not* acceptable.

Other than that, my quick scan through this looked fine. And maybe
that quick scan missed where you already did that too.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/