public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Benjamin LaHaise <bcrl@redhat.com>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org,
	trond.myklebust@fys.uio.no
Subject: Re: [patch] v2.5.31 nfsctl.c stack usage reduction
Date: Mon, 19 Aug 2002 10:49:29 +1000	[thread overview]
Message-ID: <20020819104929.1eabb7ce.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20020815173136.D29874@redhat.com>

On Thu, 15 Aug 2002 17:31:36 -0400
Benjamin LaHaise <bcrl@redhat.com> wrote:

> 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;
> +

One tiny request: make the macro an expression statement, and then use it
as "return WRITE_METHOD(xxx, yyy)".

Or even an inline function taking void * and a size.

Let's not encourage people to do returns in macros 8)

Thanks!
Rusty.
-- 
   there are those who do and those who hang on and you don't see too
   many doers quoting their contemporaries.  -- Larry McVoy

      reply	other threads:[~2002-08-19  3:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-15 21:31 [patch] v2.5.31 nfsctl.c stack usage reduction Benjamin LaHaise
2002-08-19  0:49 ` Rusty Russell [this message]

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=20020819104929.1eabb7ce.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox