linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Killing kernel threads
@ 2002-11-19 16:58 Super user
  2002-11-19 17:57 ` Richard B. Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Super user @ 2002-11-19 16:58 UTC (permalink / raw)
  To: linux-kernel

Hi,

Is there any guaranted way to kill kernel threads
started from loadable modules. I've written a kernel
module that starts 8 kernel threads and sometimes one
of them goes into uninterruptible sleep. Is there
anyway to flush away such threads while unloading
modules.

I've tried using kill_proc with SIGKILL but it doesn't
seem to help.

BTW, I am using the code for handling kernel threads
at http://www.scs.ch/~frey/linux/kernelthreads.html

Any pointers regarding the same are highly
appreciated.

Thanks,



__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Killing kernel threads
  2002-11-19 16:58 Killing kernel threads Super user
@ 2002-11-19 17:57 ` Richard B. Johnson
  2002-11-29 12:30   ` Size limitation for the module Super user
  0 siblings, 1 reply; 4+ messages in thread
From: Richard B. Johnson @ 2002-11-19 17:57 UTC (permalink / raw)
  To: Super user; +Cc: linux-kernel

On Tue, 19 Nov 2002, Super user wrote:

> Hi,
> 
> Is there any guaranted way to kill kernel threads
> started from loadable modules. I've written a kernel
> module that starts 8 kernel threads and sometimes one
> of them goes into uninterruptible sleep. Is there
> anyway to flush away such threads while unloading
> modules.
> 
> I've tried using kill_proc with SIGKILL but it doesn't
> seem to help.


#ifdef NEW_THREAD_EXIT
	struct completion quit;
#else
	struct semaphore quit;
#endif


In the kernel thread, someplace it can be awakened by a signal:

#ifdef NEW_THREAD_EXIT
	complete_and_exit(&quit, 0);
#else
        up_and_exit(&quit, 0);
#endif


In cleanup_module:

#ifdef NEW_THREAD_EXIT
	wait_for_completion(&quit);
#else
	down(&quit);
#endif


You define NEW_THREAD_EXIT based upon the kernel version. 2.4.18
uses the new syntax.

If you have a lot of threads, you need to have one of these constructs
for each of the threads and don't forget to initialize the semaphores.
Last I knew, this was the way to do it (and it works).


Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
   Bush : The Fourth Reich of America



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Size limitation for the module
  2002-11-19 17:57 ` Richard B. Johnson
@ 2002-11-29 12:30   ` Super user
  2002-12-02 13:13     ` Richard B. Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Super user @ 2002-11-29 12:30 UTC (permalink / raw)
  To: linux-kernel

Hi All,

I have a kernel module which is a huge one. Around 1.5
MB. Is there any known problems in having a such a big
module.

The problem is after inserting the module, the box
freezes after some time. Some times it crashes.I
analyzed the oops message, but it does'nt make much
sense, since the trace leads me to some other kernel
code. So it looks like my module is corrupting the
memory , which leads to this crash.Appreciate if
someone can send me a link to fix these types of
problems. Also is there any tool which can do a
memwatch on the kernel space.

Thanks,
lnxuser2002.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Size limitation for the module
  2002-11-29 12:30   ` Size limitation for the module Super user
@ 2002-12-02 13:13     ` Richard B. Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard B. Johnson @ 2002-12-02 13:13 UTC (permalink / raw)
  To: Super user; +Cc: linux-kernel

On Fri, 29 Nov 2002, Super user wrote:

> Hi All,
> 
> I have a kernel module which is a huge one. Around 1.5
> MB. Is there any known problems in having a such a big
> module.
> 
> The problem is after inserting the module, the box
> freezes after some time.

[SNIPPED...]

There might not be 1.5 MB available from kmalloc() and there
may be a bug in kmalloc() when it gets to allocating more
memory than it has (these boundary conditions may not have been
tested very well, or your module isn't checking returned results).

Normally, if you need lots of memory for a module, you tell
the kernel upon boot that there is less memory than there is.
IOW, you reserve it. Then, in your module you use ioremap() to
allocate it exclusively for your module.

This method has many advantages as well. FYI, the memory is
never paged, it's always immediately available for your module.

In principle, you are supposed to use copy/from/to/io and
read/b/w/l/write/b/w/l to access it, but on ix86 (only), you
can initialize a pointer with the value returned from ioremap().

This, of course is not portable, but a module allocation of 1.5 MB
is not portable anyway, so doit2it.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
   Bush : The Fourth Reich of America



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-12-02 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-19 16:58 Killing kernel threads Super user
2002-11-19 17:57 ` Richard B. Johnson
2002-11-29 12:30   ` Size limitation for the module Super user
2002-12-02 13:13     ` Richard B. Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).