Re: [PATCH] Reduce stack usage in time.c

From: Jeff Garzik (jgarzik_at_pobox.com)
Date: 03/31/05

  • Next message: Greg KH: "syslog loves the new driver core code"
    Date:	Thu, 31 Mar 2005 03:26:43 -0500
    To: Yum Rayan <yum.rayan@gmail.com>
    
    

    Yum Rayan wrote:
    > 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:

    It seems quite unhealthy to add a kmalloc(,GFP_KERNEL) allocation into a
    time-sensitive function.

            Jeff

    -
    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/


  • Next message: Greg KH: "syslog loves the new driver core code"

    Relevant Pages

    • Re: [patch 3/9] no PF_MEMALLOC tinkering
      ... > was addressed by the previous patch. ... radix tree allocation doesn't use mempools, ... bvec and if we're doing pageout then try to allocate a smaller-sized bvec ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: HUGETLB commit handling.
      ... The other problem we are wrestling with is how to do the ia386 and ia64 lazy ... allocation code without breaking the architectures that haven't yet switched ... >>close a final merged patch. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [PATCH]: Clean up of __alloc_pages
      ... patch does the cleanup, second does the direct pcp list alloc. ... Regarding the direct pcp list allocation - I think it is a good ... Send instant messages to your online friends http://au.messenger.yahoo.com ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [patch 3/9] no PF_MEMALLOC tinkering
      ... >> was addressed by the previous patch. ... > bvec and if we're doing pageout then try to allocate a smaller-sized bvec ... might as well just wait for its allocation. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: PCI memory reservation failure - 2.4/2.6
      ... > If it's of any help to you, please see my recent bugzilla posting and ... I don't think that patch will work, and here is why. ... and it required that the memory be aligned on its allocation size. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)