Skip to contentSkip to conversation

exportfs: reduce stack usage

PATCH In review Randy.Dunlap 2 participants 2 messages Sep 29, 2004 – Oct 1, 2004 Filesystems exportfs

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exportfs: reduce stack usage

find_exported_dentry() declares

	char nbuf[NAME_MAX+1];

in 2 separate places, and gcc allocates space on the stack for both of them. Having just one of them will suffice, if we can put put with its scope.

Reduces function stack usage on x86-32 from 0x230 to 0x130.

diffstat:=

 fs/exportfs/expfs.c |    4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)
fs/exportfs/expfs.c renamed from fs/exportfs/expfs.c~expfs_stack +1 -3
diff -Naurp ./fs/exportfs/expfs.c~expfs_stack ./fs/exportfs/expfs.c
@@ -55,7 +55,7 @@ find_exported_dentry(struct super_block 
 	struct list_head *le, *head;
 	struct dentry *toput = NULL;
 	int noprogress;
-
+	char nbuf[NAME_MAX+1];
 
 	/*
 	 * Attempt to find the inode.
@@ -176,7 +176,6 @@ find_exported_dentry(struct super_block 
 			 */
 			struct dentry *ppd;
 			struct dentry *npd;
-			char nbuf[NAME_MAX+1];
 
 			down(&pd->d_inode->i_sem);
 			ppd = CALL(nops,get_parent)(pd);
@@ -241,7 +240,6 @@ find_exported_dentry(struct super_block 
 	/* if we weren't after a directory, have one more step to go */
 	if (result != target_dir) {
 		struct dentry *nresult;
-		char nbuf[NAME_MAX+1];
 		err = CALL(nops,get_name)(target_dir, nbuf, result);
 		if (!err) {
 			down(&target_dir->d_inode->i_sem);

--

#1 lore raw
Quoted 8 lines · On Tuesday September 28, [email protected] wrote:

find_exported_dentry() declares

	char nbuf[NAME_MAX+1];

in 2 separate places, and gcc allocates space on the stack for both of them. Having just one of them will suffice, if we can put put with its scope.

Reduces function stack usage on x86-32 from 0x230 to 0x130.

So it does. I thought gcc was cleverer than that. I'll add it to my collection.

Thanks,
NeilBrown