Re: [PATCH] fs/devfs/base.c

Richard Gooch (rgooch@ras.ucalgary.ca)
Sun, 27 May 2001 09:21:50 -0400


Akash Jain writes:
> hello,
>
> in fs/devfs/base.c,
> the struct devfsd_notify_struct is approx 1056 bytes, allocating it
> on a stack of 8k seems unreasonable. here we simply move it to the
> heap, i don't think it is a _must_ be on stack type thing

I absolutely don't want this patch applied. It's bogus. It is entirely
safe to alloc 1 kB on the stack in this code, since it has a short and
well-controlled code path from syscall entry to the function. This is
not some function that can be called from some random place in the
kernel and thus has a random call path.

Using the stack is much faster than calling kmalloc() and it also
doesn't add to system memory pressure. That's why I did it this way in
the first place. Further, it's much safer to use the stack, since the
memory is freed automatically. Thus, there's less scope for
introducing errors.

Please fix your checker to deal with this class of functions which
have a well-defined call path. I'd suggest looking at the total stack
allocations from syscall entry point all the way to the end function.
Ideally, you'd trace the call path to every function, but of course
that may be computationally infeasible. Hopefully it's feasible to do
this for any function which has a stack allocation which exceeds some
threshold.

Regards,

Richard....
Permanent: rgooch@atnf.csiro.au
Current: rgooch@ras.ucalgary.ca
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/