mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Unusually long delay in the kernel
Date: Fri, 16 Sep 2005 23:52:59 -0700	[thread overview]
Message-ID: <20050916235259.61b87069.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0509161236440.4523-100000@iolanthe.rowland.org>

Alan Stern <stern@rowland.harvard.edu> wrote:
>
> This code excerpt is taken from the start of the control thread for the 
>  usb-storage driver in 2.6.14-rc1:
> 
> 
>  static int usb_stor_control_thread(void * __us)
>  {
>  	struct us_data *us = (struct us_data *)__us;
>  	struct Scsi_Host *host = us_to_host(us);
> 
>  printk(KERN_INFO "Before thread start\n");
>  	lock_kernel();
> 
>  	/*
>  	 * This thread doesn't need any user-level access,
>  	 * so get rid of all our resources.
>  	 */
>  	daemonize("usb-storage");
>  	current->flags |= PF_NOFREEZE;
>  	unlock_kernel();
>  printk(KERN_INFO "After thread start\n");
> 
> 
>  The code between the two printk's takes a long time to run.  I don't have 
>  precise numbers, but it feels like more than 1 second.
> 
>  (1) Can anyone explain why, or indicate how to speed it up?

What's it doing at the time?  (kgdb is great for this sort of thing: hit
^C, go for a wander through the thread callchains).

Presumably it's spinning on the bkl.  Is this actually an SMP machine?  If
so, perhaps some other process is holding the bkl for a long time.  Perhaps
a netdevice spending a long time diddling hardware in an ioctl, something
like that.

>  (2) Are the {un}lock_kernel calls really needed?

Definitely not.

That code could be converted to the kthread API btw.

  parent reply	other threads:[~2005-09-17  6:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-16 16:42 Alan Stern
2005-09-16 17:58 ` Fawad Lateef
2005-09-17  6:52 ` Andrew Morton [this message]
2005-09-17 22:15   ` Alan Stern
2005-09-17 23:41     ` Andrew Morton
2005-09-18 15:05       ` Alan Stern
2005-09-18 20:09         ` Andrew Morton
2005-09-19 14:40           ` [Proposed PATCH] Add kthread_stop_sem Alan Stern
2005-09-19 18:06       ` Unusually long delay in the kernel Alan Stern

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=20050916235259.61b87069.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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

all inboxes | Powered by JetHome®