From: Benjamin LaHaise <bcrl@redhat.com>
To: Linus Torvalds <torvalds@transmeta.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
trond.myklebust@fys.uio.no
Subject: [patch] v2.5.31 nfsctl.c stack usage reduction
Date: Thu, 15 Aug 2002 17:31:36 -0400 [thread overview]
Message-ID: <20020815173136.D29874@redhat.com> (raw)
Heyo,
The patch below (which depends on the copy_from_user_kmalloc addition)
reduces the stack usage in nfsctl.c, which was allocating structures that
were 2KB or more on the stack.
-ben
:r ~/patches/v2.5/v2.5.31-stack-nfs.diff
diff -urN foo-v2.5.31/fs/nfsd/nfsctl.c bar-v2.5.31/fs/nfsd/nfsctl.c
--- foo-v2.5.31/fs/nfsd/nfsctl.c Tue Jul 30 10:24:17 2002
+++ bar-v2.5.31/fs/nfsd/nfsctl.c Thu Aug 15 17:26:09 2002
@@ -155,56 +155,47 @@
* payload - write methods
*/
+/* Rather than duplicate this many times, just use a funky macro. */
+#define WRITE_METHOD(type, fn) \
+ type *data; \
+ ssize_t ret; \
+ if (size < sizeof(*data)) \
+ return -EINVAL; \
+ data = copy_from_user_kmalloc(buf, size);\
+ if (IS_ERR(data)) \
+ return PTR_ERR(data); \
+ ret = fn; \
+ kfree(data); \
+ return ret;
+
static ssize_t write_svc(struct file *file, const char *buf, size_t size)
{
- struct nfsctl_svc data;
- if (size < sizeof(data))
- return -EINVAL;
- if (copy_from_user(&data, buf, size))
- return -EFAULT;
- return nfsd_svc(data.svc_port, data.svc_nthreads);
+ WRITE_METHOD(struct nfsctl_svc,
+ nfsd_svc(data->svc_port, data->svc_nthreads));
}
static ssize_t write_add(struct file *file, const char *buf, size_t size)
{
- struct nfsctl_client data;
- if (size < sizeof(data))
- return -EINVAL;
- if (copy_from_user(&data, buf, size))
- return -EFAULT;
- return exp_addclient(&data);
+ WRITE_METHOD(struct nfsctl_client, exp_addclient(data));
}
static ssize_t write_del(struct file *file, const char *buf, size_t size)
{
- struct nfsctl_client data;
- if (size < sizeof(data))
- return -EINVAL;
- if (copy_from_user(&data, buf, size))
- return -EFAULT;
- return exp_delclient(&data);
+ WRITE_METHOD(struct nfsctl_client, exp_delclient(data));
}
static ssize_t write_export(struct file *file, const char *buf, size_t size)
{
- struct nfsctl_export data;
- if (size < sizeof(data))
- return -EINVAL;
- if (copy_from_user(&data, buf, size))
- return -EFAULT;
- return exp_export(&data);
+ WRITE_METHOD(struct nfsctl_export, exp_export(data));
}
static ssize_t write_unexport(struct file *file, const char *buf, size_t size)
{
- struct nfsctl_export data;
- if (size < sizeof(data))
- return -EINVAL;
- if (copy_from_user(&data, buf, size))
- return -EFAULT;
- return exp_unexport(&data);
+ WRITE_METHOD(struct nfsctl_export, exp_unexport(data));
}
+#undef WRITE_METHOD
+
static ssize_t write_getfs(struct file *file, const char *buf, size_t size)
{
struct nfsctl_fsparm data;
next reply other threads:[~2002-08-15 21:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-15 21:31 Benjamin LaHaise [this message]
2002-08-19 0:49 ` [patch] v2.5.31 nfsctl.c stack usage reduction Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020815173136.D29874@redhat.com \
--to=bcrl@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.