system >> [Q] vmalloc and interrupt handler

by bz800k » Thu, 22 Apr 2004 10:37:33 GMT

Hi.
I'm trying to write a simple device driver using a lot of memory.
It seems that vmalloc() is not available in interrupt handler, because
it may sleep.

So, I changed my code such that vmalloc() is only called in driver's open function,
and interrupt handler only access the memory already allocated by vmalloc().

Then I have a question.
Does this memory area allocated by vmalloc() have a possibility to be paged out?
If this area paged out, interrupt handler cannot access the area(because
interrupt handler must sleep until page-in handler done.)

Please help me.
Thanks !!!


system >> [Q] vmalloc and interrupt handler

by Tuukka Toivonen » Thu, 22 Apr 2004 17:48:37 GMT





No... vmalloc differs from kmalloc in that it allocates individual pages and
rearranges page tables so that the memory looks continuous. I don't think
that these pages may be swapped out.

If you would use kmalloc, the returned memory would be really continuous,
and not just look like it as with possibly with vmalloc.



system >> [Q] vmalloc and interrupt handler

by bz800k » Fri, 23 Apr 2004 10:37:42 GMT

Thanks Tuukka !!



Yes, at first I used kmalloc, however
calling kmalloc() many times may cause kernel crash (if allocated areas
are not released by kfree().)
So I decided to get a big memory area at drive open() routine, and
if my driver(include interrupt handler) only access a portion of this memory area
, linux kernel should not hang up (if not paged out).

Max allocatable size of one kmalloc() is 128k, so I decided to use vmalloc().


Thanks for your suggestion
I'll try to test my driver for a long time.


[Q] vmalloc and interrupt handler

by Kasper Dupont » Fri, 23 Apr 2004 12:54:06 GMT





Of course you must free memory when you are done with it.
This is kernel code, there is no-one to clean up after you.


You really should not allocate more than you need. Kernel
memory is a sparse resource.


That depends. In some configurations kmalloc will allow
more than 128k. But if memory has been fragmented, don't
expect requests for more than 8KB to be possible. But even
vmalloc should be used with care. There is a limit of IIRC
64MB on the total amount of memory that can be allocated
using vmalloc.

--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use XXXX@XXXXX.COM and XXXX@XXXXX.COM
/* Would you like fries with that? */


[Q] vmalloc and interrupt handler

by bz800k » Sun, 25 Apr 2004 16:47:33 GMT

Thanks Kasper !!

Currently I'm trying to make a simple protocol stack using
kernel protocol interface such as "struct proto".
Received packets should be saved in this protocol-driver, if application
not yet read packets.
So, my-driver cannot call kfree() until packets are copied to application.

Too many in-coming packets saved by kmalloc(), cause exhaustion of
kernel memory, and in some cases, cause kernel hang up.

So, I decided to make a big memory area to store in-coming packets.



Thank you very much. 64MB is a big size.
I'll try to use vmalloc() and test my-driver.


[Q] vmalloc and interrupt handler

by Kasper Dupont » Sun, 25 Apr 2004 17:05:21 GMT




In case of too many incoming packets, you will need to
drop some of them. There are obviously a lot of possible
ways to know when you will need to start droping packets.

--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use XXXX@XXXXX.COM and XXXX@XXXXX.COM
/* Would you like fries with that? */


[Q] vmalloc and interrupt handler

by bz800k » Mon, 26 Apr 2004 09:18:17 GMT

Dear Kasper


Yes. I think your suggestion is right. However, currently
I have a plan to prepare a linux-machine of exclusive use,
only in order to run my-driver.
So I'd like to use all available kernel-memory for my-driver
by easy method.

Thanks !!


Similar Threads

1. de2104x: interrupts before interrupt handler is registered

2. [PATCH] USB: fix interrupt disabling for HCDs with shared interrupt handlers - Linux

3. [PATCH] USB: fix interrupt disabling for HCDs with shared interrupt handlers

4. semaphores not usable in Linux interrupt handler?

5. execution time in interrupt handler.

Hi all,

May be this is just a stupid question, but I have to ask it. :)

Is there any limitation on execution time in the interrupt handler?
e.g.
In a timer interrupt, I perform some of the tasks like -
1. refreshing the watchdog timer.
2. set user clock
3. calculate process CPU usage

Is is that there is a limit on the tasks performed in the interrupt handler?


Your response highly appreciated.

Thank you.
-Anand

6. Resetting system clock with interrupt handler?

7. Adding a new interrupt handler to the IDT

I have a system which will be creating CPU interrupts via a 
user-supplied IDT value.  I have a kernel module which will handle the 
interrupt - I just need to hook this code into the interrupt handler 
mechanism.  I cannot find any documentation on how to create an entry in 
the IDT or to identify the linkage protocol (assuming I can create an 
IDT entry).

Note: These are NOT IRQs and, therefore, the request_irq() services 
cannot be used.  This would be equivalent to creating a handler for the 
INT instruction.

Any ideas or pointers would be appreciated.

Thanks - Martin

8. fast vs slow interrupt handler in intel processor