* include/linux/nfs/nfsfh.h declares a symbol
@ 2003-10-01 12:18 Jörn Engel
2003-10-13 4:43 ` Neil Brown
0 siblings, 1 reply; 3+ messages in thread
From: Jörn Engel @ 2003-10-01 12:18 UTC (permalink / raw)
To: Neil Brown, nfs; +Cc: linux-kernel
Neil, the function SVCFH_fmt uses a static variable to sprintf into.
Looks like this variable is declared locally for every .c file
including nfsfh.h, which is quite a few.
You could remove the static, but that would increase the stack usage,
which might be a problem too. The buffer could be reduced to 64
chars, to reduce that problem. kmalloc()ing it seems a bit expensive,
but might be an option, too.
Thanks!
Jörn
--
This above all: to thine own self be true.
-- Shakespeare
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: include/linux/nfs/nfsfh.h declares a symbol
2003-10-01 12:18 include/linux/nfs/nfsfh.h declares a symbol Jörn Engel
@ 2003-10-13 4:43 ` Neil Brown
2003-10-13 9:21 ` Jörn Engel
0 siblings, 1 reply; 3+ messages in thread
From: Neil Brown @ 2003-10-13 4:43 UTC (permalink / raw)
To: Jörn Engel; +Cc: nfs, linux-kernel
On Wednesday October 1, joern@wohnheim.fh-wedel.de wrote:
> Neil, the function SVCFH_fmt uses a static variable to sprintf into.
> Looks like this variable is declared locally for every .c file
> including nfsfh.h, which is quite a few.
>
> You could remove the static, but that would increase the stack usage,
> which might be a problem too. The buffer could be reduced to 64
> chars, to reduce that problem. kmalloc()ing it seems a bit expensive,
> but might be an option, too.
Thanks. I think it is best to simply make SVCFH_fmt a real function
instead of inline, as below.
NeilBrown
=======================================
Move SVCFH_fmt from being 'inline' to being 'extern'.
This way, the "static char buf" is defined only once instead
of once per file.
----------- Diffstat output ------------
./fs/nfsd/nfsfh.c | 18 ++++++++++++++++++
./include/linux/nfsd/nfsfh.h | 17 ++---------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff ./fs/nfsd/nfsfh.c~current~ ./fs/nfsd/nfsfh.c
--- ./fs/nfsd/nfsfh.c~current~ 2003-10-13 14:24:46.000000000 +1000
+++ ./fs/nfsd/nfsfh.c 2003-10-13 14:30:06.000000000 +1000
@@ -489,3 +489,21 @@ fh_put(struct svc_fh *fhp)
return;
}
+/*
+ * Shorthand for dprintk()'s
+ */
+char * SVCFH_fmt(struct svc_fh *fhp)
+{
+ struct knfsd_fh *fh = &fhp->fh_handle;
+
+ static char buf[80];
+ sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
+ fh->fh_size,
+ fh->fh_base.fh_pad[0],
+ fh->fh_base.fh_pad[1],
+ fh->fh_base.fh_pad[2],
+ fh->fh_base.fh_pad[3],
+ fh->fh_base.fh_pad[4],
+ fh->fh_base.fh_pad[5]);
+ return buf;
+}
diff ./include/linux/nfsd/nfsfh.h~current~ ./include/linux/nfsd/nfsfh.h
--- ./include/linux/nfsd/nfsfh.h~current~ 2003-10-13 14:22:27.000000000 +1000
+++ ./include/linux/nfsd/nfsfh.h 2003-10-13 14:30:16.000000000 +1000
@@ -186,21 +186,8 @@ static inline void mk_fsid_v2(u32 *fsidv
/*
* Shorthand for dprintk()'s
*/
-inline static char * SVCFH_fmt(struct svc_fh *fhp)
-{
- struct knfsd_fh *fh = &fhp->fh_handle;
-
- static char buf[80];
- sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
- fh->fh_size,
- fh->fh_base.fh_pad[0],
- fh->fh_base.fh_pad[1],
- fh->fh_base.fh_pad[2],
- fh->fh_base.fh_pad[3],
- fh->fh_base.fh_pad[4],
- fh->fh_base.fh_pad[5]);
- return buf;
-}
+extern char * SVCFH_fmt(struct svc_fh *fhp);
+
/*
* Function prototypes
*/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: include/linux/nfs/nfsfh.h declares a symbol
2003-10-13 4:43 ` Neil Brown
@ 2003-10-13 9:21 ` Jörn Engel
0 siblings, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2003-10-13 9:21 UTC (permalink / raw)
To: Neil Brown; +Cc: nfs, linux-kernel
On Mon, 13 October 2003 14:43:57 +1000, Neil Brown wrote:
> On Wednesday October 1, joern@wohnheim.fh-wedel.de wrote:
> > Neil, the function SVCFH_fmt uses a static variable to sprintf into.
> > Looks like this variable is declared locally for every .c file
> > including nfsfh.h, which is quite a few.
> >
> > You could remove the static, but that would increase the stack usage,
> > which might be a problem too. The buffer could be reduced to 64
> > chars, to reduce that problem. kmalloc()ing it seems a bit expensive,
> > but might be an option, too.
>
> Thanks. I think it is best to simply make SVCFH_fmt a real function
> instead of inline, as below.
>
> NeilBrown
>
> =======================================
> Move SVCFH_fmt from being 'inline' to being 'extern'.
>
> This way, the "static char buf" is defined only once instead
> of once per file.
Patch looks good. Thanks!
Jörn
--
To recognize individual spam features you have to try to get into the
mind of the spammer, and frankly I want to spend as little time inside
the minds of spammers as possible.
-- Paul Graham
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-13 9:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-01 12:18 include/linux/nfs/nfsfh.h declares a symbol Jörn Engel
2003-10-13 4:43 ` Neil Brown
2003-10-13 9:21 ` Jörn Engel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®