[PATCH] Reduce stack usage in time.c
From: Yum Rayan (yum.rayan_at_gmail.com)
Date: 03/31/05
- Previous message: Yum Rayan: "[PATCH] Reduce stack usage in sys.c"
- Next in thread: Jeff Garzik: "Re: [PATCH] Reduce stack usage in time.c"
- Reply: Jeff Garzik: "Re: [PATCH] Reduce stack usage in time.c"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Mar 2005 23:46:51 -0800 To: linux-kernel@vger.kernel.org
Attempt to reduce stack usage in time.c (linux-2.6.12-rc1-mm3). Stack
usage was noted using checkstack.pl. Specifically:
Before patch
------------
sys_adjtimex - 128
After patch
-----------
sys_adjtimex - none (register usage only)
Signed-off-by: Yum Rayan <yum.rayan@gmail.com>
--- a/kernel/time.c 2005-03-25 22:11:06.000000000 -0800
+++ b/kernel/time.c 2005-03-30 16:59:51.000000000 -0800
@@ -413,17 +413,27 @@
asmlinkage long sys_adjtimex(struct timex __user *txc_p)
{
- struct timex txc; /* Local copy of parameter */
- int ret;
+ struct timex *txc; /* Local copy of parameter */
+ int retval;
+
+ txc = kmalloc(sizeof(struct timex), GFP_KERNEL);
+ if (!txc)
+ return -ENOMEM;
/* Copy the user data space into the kernel copy
* structure. But bear in mind that the structures
* may change
*/
- if(copy_from_user(&txc, txc_p, sizeof(struct timex)))
- return -EFAULT;
- ret = do_adjtimex(&txc);
- return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
+ if(copy_from_user(txc, txc_p, sizeof(struct timex))) {
+ retval = -EFAULT;
+ goto free_txc;
+ }
+ retval = do_adjtimex(txc);
+ if (copy_to_user(txc_p, txc, sizeof(struct timex)))
+ retval = -EFAULT;
+free_txc:
+ kfree(txc);
+ return retval;
}
inline struct timespec current_kernel_time(void)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Yum Rayan: "[PATCH] Reduce stack usage in sys.c"
- Next in thread: Jeff Garzik: "Re: [PATCH] Reduce stack usage in time.c"
- Reply: Jeff Garzik: "Re: [PATCH] Reduce stack usage in time.c"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- two pipe bugfixes
... Current output of strace with this patch applied is this: ... usage with
all sort of desktop apps and twisted). ... send the line "unsubscribe linux-kernel" in
... (Linux-Kernel) - Re: [RFC] [PATCH 1/3] ioat: DMA subsystem
... if you disagree please submit a patch to ... - if it gets accepted fine,
else just remove this usage. ... send the line "unsubscribe linux-kernel" in ...
(Linux-Kernel) - Re: [PATCH] fix rq->flags use in ide-tape.c
... On Wed, Nov 05 2003, Bartlomiej Zolnierkiewicz wrote: ... >> usage
would be a whole lot better. ... This patch should never have been ... send the
line "unsubscribe linux-kernel" in ... (Linux-Kernel) - [patch 4/8] Corgi Touchscreen: Allow the driver to share the PMU
... which conflicts with its usage for performance monitoring. ... This patch
... send the line "unsubscribe linux-kernel" in ... (Linux-Kernel) - Re: [PATCH] fix rq->flags use in ide-tape.c
... > usage would be a whole lot better. ... This patch should never have
been ... Yeah, it is ugly. ... send the line "unsubscribe linux-kernel" in
... (Linux-Kernel)