Re: How to safely reduce stack usage in nfs code?

From: Andreas Dilger
Date: Thu Oct 28 2004 - 20:57:52 EST


On Oct 29, 2004 00:20 +0300, Denis Vlasenko wrote:
> I've got one stack overflow sometime ago.
> Partially due to NFS stack usage.
>
> structs nfs_fh and nfs_fattr take together ~300 bytes
> and are one of the most frequently used:
>
> # cd fs/nfs; grep 'struct nfs_fh [a-z0-9_]*;' * ; grep 'struct nfs_fattr [a-z0-9_]*;' *
> callback.h: struct nfs_fh fh;
> callback.h: struct nfs_fh fh;
> dir.c: struct nfs_fh fhandle;
> dir.c: struct nfs_fh fhandle;
> dir.c: struct nfs_fh fhandle;
> dir.c: struct nfs_fh fhandle;
> dir.c: struct nfs_fh sym_fh;
> nfsroot.c: struct nfs_fh fh;
> dir.c: struct nfs_fattr fattr;
> dir.c: struct nfs_fattr fattr;
> dir.c: struct nfs_fattr fattr;
> dir.c: struct nfs_fattr fattr;
> dir.c: struct nfs_fattr fattr;
> dir.c: struct nfs_fattr sym_attr;
> inode.c: struct nfs_fattr fattr;
> inode.c: struct nfs_fattr fattr;
> inode.c: struct nfs_fattr fattr;
> nfs3proc.c: struct nfs_fattr res;
> nfs4proc.c: struct nfs_fattr fattr;
>
> I can convert these into kmalloc'ed variants but hesitate to do so
> because of possible 'need to kmalloc in order to free memory for kmalloc'
> deadlocks.

Make the thread kmalloc unless it has PF_MEMALLOC set, in which case it
could get the structs from a small pool of reserved ones.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://members.shaw.ca/adilger/ http://members.shaw.ca/golinux/

Attachment: pgp00000.pgp
Description: PGP signature