All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>,
	trond.myklebust@fys.uio.no
Subject: Re: Linux 2.6.7-rc2
Date: 01 Jun 2004 00:04:14 +0200	[thread overview]
Message-ID: <m34qpw5k4h.fsf@telia.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0405310955420.4573@ppc970.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> On Mon, 31 May 2004, Peter Osterlund wrote:
> > 
> > If I put "#if 0" around the *wdata assignment in nfs_writepage_sync,
> > the stack usage goes down to 36, so it looks like gcc is building a
> > temporary structure on the stack and then copies the whole thing to
> > *wdata.
> 
> Yeah, that's silly. But understandable. A lot of problems go away by doing 
> a temporary private node..
> 
> > Does this construct save stack space for any version of gcc? Maybe the
> > code should be changed to do a memset() followed by explicit
> > initialization of the non-zero member variables instead.
> 
> In this case, I'd agree.
> 
> In some other cases, it's better to create a initialized static variable, 
> and just use that as an initial initializer. In this case that doesn't 
> much help, since none of the fields are constant.

Here is a patch that does this. I've verified that it compiles and
that it fixes the excessive stack problem, but I failed to come up
with a test case that exercises these code paths.


--- linux/fs/nfs/read.c.orig	2004-05-31 23:34:15.890307512 +0200
+++ linux/fs/nfs/read.c	2004-05-31 23:29:26.077365776 +0200
@@ -103,22 +103,16 @@
 	if (!rdata)
 		return -ENOMEM;
 
-	*rdata = (struct nfs_read_data) {
-		.flags		= (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0),
-		.cred		= NULL,
-		.inode		= inode,
-		.pages		= LIST_HEAD_INIT(rdata->pages),
-		.args		= {
-			.fh		= NFS_FH(inode),
-			.lockowner	= current->files,
-			.pages		= &page,
-			.pgbase		= 0UL,
-			.count		= rsize,
-		},
-		.res		= {
-			.fattr		= &rdata->fattr,
-		}
-	};
+	memset(rdata, 0, sizeof(*rdata));
+	rdata->flags = (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
+	rdata->inode = inode;
+	INIT_LIST_HEAD(&rdata->pages);
+	rdata->args.fh = NFS_FH(inode);
+	rdata->args.lockowner = current->files;
+	rdata->args.pages = &page;
+	rdata->args.pgbase = 0UL;
+	rdata->args.count = rsize;
+	rdata->res.fattr = &rdata->fattr;
 
 	dprintk("NFS: nfs_readpage_sync(%p)\n", page);
 
--- linux/fs/nfs/write.c.orig	2004-05-31 23:34:20.529602232 +0200
+++ linux/fs/nfs/write.c	2004-05-31 23:29:33.165288248 +0200
@@ -185,23 +185,17 @@
 	if (!wdata)
 		return -ENOMEM;
 
-	*wdata = (struct nfs_write_data) {
-		.flags		= how,
-		.cred		= NULL,
-		.inode		= inode,
-		.args		= {
-			.fh		= NFS_FH(inode),
-			.lockowner	= current->files,
-			.pages		= &page,
-			.stable		= NFS_FILE_SYNC,
-			.pgbase		= offset,
-			.count		= wsize,
-		},
-		.res		= {
-			.fattr		= &wdata->fattr,
-			.verf		= &wdata->verf,
-		},
-	};
+	memset(wdata, 0, sizeof(*wdata));
+	wdata->flags = how;
+	wdata->inode = inode;
+	wdata->args.fh = NFS_FH(inode);
+	wdata->args.lockowner = current->files;
+	wdata->args.pages = &page;
+	wdata->args.stable = NFS_FILE_SYNC;
+	wdata->args.pgbase = offset;
+	wdata->args.count = wsize;
+	wdata->res.fattr = &wdata->fattr;
+	wdata->res.verf = &wdata->verf;
 
 	dprintk("NFS:      nfs_writepage_sync(%s/%Ld %d@%Ld)\n",
 		inode->i_sb->s_id,

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

  reply	other threads:[~2004-05-31 22:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-30  6:52 Linux 2.6.7-rc2 Linus Torvalds
2004-05-30  7:56 ` Danny ter Haar
2004-05-30 11:09   ` Francois Romieu
2004-05-30 13:16     ` Danny ter Haar
2004-05-30 13:24       ` Danny ter Haar
2004-05-30 16:26   ` Malte Schröder
2004-05-30 17:26   ` Jeff Garzik
2004-05-31  9:21 ` Peter Osterlund
2004-05-31  9:27   ` Andrew Morton
2004-05-31 16:58   ` Linus Torvalds
2004-05-31 22:04     ` Peter Osterlund [this message]
2004-06-03 20:01       ` Flavio Stanchina
2004-06-01  3:44 ` Linux 2.6.7-rc2 (compile stats) John Cherry
2004-06-01 16:07 ` 2.6.7-rc2: .bss.page_aligned warning with gcc 2.95 Adrian Bunk
2004-06-02 14:37 ` Linux 2.6.7-rc2 Thomas Zehetbauer
2004-06-04 14:06   ` Denis Vlasenko
2004-06-08 17:02     ` Bill Davidsen
2004-06-08 18:02       ` David Ford
2004-06-09  6:37       ` sk98lin (was: Re: Linux 2.6.7-rc2) Geert Uytterhoeven
2004-06-10 15:03 ` SCSI_DPT_I2O " Geert Uytterhoeven
2004-06-10 15:33 ` ide-proc.c " Geert Uytterhoeven
  -- strict thread matches above, loose matches on Subject: below --
2004-05-31 12:20 Linux 2.6.7-rc2 Albert Cahalan
2004-05-31 16:53 ` Linus Torvalds
2004-05-31 15:12   ` Albert Cahalan

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=m34qpw5k4h.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --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.