vmalloc, kmalloc - 2.4.x
few days ago i started to port driver for our hardware in company from windows to linux. It is simple ISA card, which gives me interrupt each 8ms. So i can check it state and latch some sort of watchdog on it - saying that i am still running (just for security, if system hangs card is blocking all inputs/outputs).
But anyway, i was collecting all data from the card in dynamically allocated memory. This gives me at least 300 * 20 bytes allocated. i have sigle small allocation running on each interrupt.
Driver is working fine under win2k even if i collect as much as 10000 allocations, afterwards system uses loads of processor.
Linux (2.4.19 ,2.4.20, 2.4.21-pre[1,2,3,4] i tried so far) gives me oups arount 80th allocation.
Quoted 1 line
From http://hit-six.co.uk/~gj/testmod.tar.bz2 you can download simple
module that shows what happends. But be carefull, it oupses very fast !
system is running up2dated Debian(stable), and i am using gcc version:
gcc version 2.95.4 20011002
Signature · 2 lines
Grzegorz Jaskiewicz <[email protected]> K4 Labs
Quoted 7 lines · Grzegorz Jaskiewicz
few days ago i started to port driver for our hardware in company from windows to linux. It is simple ISA card, which gives me interrupt each 8ms. So i can check it state and latch some sort of watchdog on it - saying that i am still running (just for security, if system hangs card is blocking all inputs/outputs).
#include <
linux/modversions.h>
don't do that. ever.
Quoted 3 lines
#ifdef
CONFIG_KMOD
#include <linux/kmod.h>
#endif
bullshit ifdef's (and the surrounding code has a whole bunch too
btw you do know you can't do vmalloc (or vfree) from interrupt context ? And that every vmalloc eats at minimum 8Kb of virtual memory space? Of which you can't count on having more than 64Mb on x86 ?
Quoted 5 lines · Grzegorz Jaskiewicz
few days ago i started to port driver for our hardware in company from windows to linux. It is simple ISA card, which gives me interrupt each 8ms. So i can check it state and latch some sort of watchdog on it - saying that i am still running (just for security, if system hangs card is blocking all inputs/outputs).
forgot to tell you that
ttimer.expires = jiffies+(HZ/150.0);
you CANNOT use floating point in kernel mode! And that for HZ=100 this gives you a timer that expires immediatly.
and that
printk("<1>%d\n", TimerIntrpt);you shouldn't use <1> in printk strings ever.
Am Montag, 3. Februar 2003 16:13 schrieb Grzegorz Jaskiewicz:
Quoted 6 lines
few days ago i started to port driver for our hardware in company from windows to linux. It is simple ISA card, which gives me interrupt each 8ms. So i can check it state and latch some sort of watchdog on it - saying that i am still running (just for security, if system hangs card is blocking all inputs/outputs).
Quoted 6 lines
But anyway, i was collecting all data from the card in dynamically allocated memory. This gives me at least 300 * 20 bytes allocated. i have sigle small allocation running on each interrupt.
Driver is working fine under win2k even if i collect as much as 10000 allocations, afterwards system uses loads of processor.
It seems that you are using vmalloc in an interrupt handler. That you must not do. To allocate memory in an interrupt handler you have to use kmalloc() with GFP_ATOMIC as a second argument.
HTH
Oliver
Quoted 2 lines · Arjan van de Ven
Quoted 1 line
#include <
linux/modversions.h>don't do that. ever.
why ?
Quoted 5 lines
Quoted 3 lines
#ifdef
CONFIG_KMOD
#include <linux/kmod.h>
#endifbullshit ifdef's (and the surrounding code has a whole bunch too
this has been taken from first from edge module, just to put it into example ;)
Quoted 3 lines
btw you do know you can't do vmalloc (or vfree) from interrupt context ? And that every vmalloc eats at minimum 8Kb of virtual memory space? Of which you can't count on having more than 64Mb on x86 ?
I didn't knew that. I have at least as i said 300 of those, if user space software is doing something else. In practice i have around 30. even if 1000 it gives 1000*8kb=8MB so it is not that bad. This mashine has 128MB atleast.
Whatver, should i consider timer as interrupt too ?
Signature · 2 lines
Grzegorz Jaskiewicz <[email protected]> K4 Labs
Quoted 4 lines · Grzegorz Jaskiewicz
Quoted 2 lines · Arjan van de Ven
Quoted 1 line
#include <
linux/modversions.h>don't do that. ever.
why ?
because if you ever need it, modules.h will automatically include it for you already. And if it doesn't you don't need it and it does more harm than good.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
#ifdef
CONFIG_KMOD
#include <linux/kmod.h>
#endifbullshit ifdef's (and the surrounding code has a whole bunch too
this has been taken from first from edge module, just to put it into example ;)
it's wrong, for the same reason as the modversions include is wrong
Quoted 6 lines
Quoted 3 lines
btw you do know you can't do vmalloc (or vfree) from interrupt context ? And that every vmalloc eats at minimum 8Kb of virtual memory space? Of which you can't count on having more than 64Mb on x86 ?
I didn't knew that. I have at least as i said 300 of those, if user space software is doing something else. In practice i have around 30. even if 1000 it gives 1000*8kb=8MB so it is not that bad.
the 64Mb vmalloc limit is a system wide one... and shared between threads allocating their LDT etc etc.
Quoted 1 line
Whatver, should i consider timer as interrupt too ?
timers are run in interrupt context yes... so you can't do vmalloc or vfree there.
Greetings,
Arjan van de Ven
Signature · 4 lines
But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. [sect.2 GPL]
Quoted 9 lines · Arjan van de Ven
On Mon, 2003-02-03 at 16:13, Grzegorz Jaskiewicz wrote:
forgot to tell you that
ttimer.expires = jiffies+(HZ/150.0);you CANNOT use floating point in kernel mode! And that for HZ=100 this gives you a timer that expires immediatly.
In real world i am NOT using this timer that way, so please don't even bother yourself telling me that this way is wrong, becouse i know it is not completly ok.
Quoted 4 lines
and that
printk("<1>%d\n", TimerIntrpt);you shouldn't use <1> in printk strings ever.
<1>gives me messages on screen on my box, thats why.
the same effect is while using kmalloc, just change vmalloc to kmalloc.
Signature · 2 lines
Grzegorz Jaskiewicz <[email protected]> K4 Labs
Quoted 13 lines · Grzegorz Jaskiewicz
few days ago i started to port driver for our hardware in company from windows to linux. It is simple ISA card, which gives me interrupt each 8ms. So i can check it state and latch some sort of watchdog on it - saying that i am still running (just for security, if system hangs card is blocking all inputs/outputs).
But anyway, i was collecting all data from the card in dynamically allocated memory. This gives me at least 300 * 20 bytes allocated. i have sigle small allocation running on each interrupt.
Driver is working fine under win2k even if i collect as much as 10000 allocations, afterwards system uses loads of processor.
Quoted 8 lines
Linux (2.4.19 ,2.4.20, 2.4.21-pre[1,2,3,4] i tried so far) gives me oups arount 80th allocation.
Quoted 1 line
From http://hit-six.co.uk/~gj/testmod.tar.bz2 you can download simple
module that shows what happends. But be carefull, it oupses very fast !
system is running up2dated Debian(stable), and i am using gcc version:
gcc version 2.95.4 20011002
I doubt that there is a bug in vmalloc or kmalloc as you state because the machine wouldn't work at all. So, I tried to download your sources. The file web-page claims that it's a ".bz2" file. However, once downloaded, it becomes a "*.tar.tar" file (whatever that is). An attempt to extract it with tar as tar -xzf fails, as does tar -xf. Attempts to un-bz2 it with bzip2 or even bzip2recover fails also.
So, if you want some help finding the problems, please email me a 'tar.gz` file directly.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips). Why is the government concerned about the lunatic fringe? Think about it.
Quoted 6 lines · Grzegorz Jaskiewicz
Quoted 3 lines
and that
printk("<1>%d\n", TimerIntrpt);you shouldn't use <1> in printk strings ever.
<1>gives me messages on screen on my box, thats why.
the same effect is while using kmalloc, just change vmalloc to kmalloc.
#include <linux/kernel.h>
and then use
printk(KERN_CRIT "%d\n", TimerIntrpt);
We have these definitions for a reason. 8)
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html
Em Mon, Feb 03, 2003 at 03:52:25PM +0000, Russell King escreveu:
Quoted 5 lines · Grzegorz Jaskiewicz
Quoted 4 lines
Quoted 3 lines
and that
printk("<1>%d\n", TimerIntrpt);you shouldn't use <1> in printk strings ever.
<1>gives me messages on screen on my box, thats why.
Also look at /proc/sys/kernel/printk andDocumentation/sysctl/kernel.txt
- Arnaldo
Quoted 8 lines · Russell King
Quoted 6 lines · Grzegorz Jaskiewicz
Quoted 3 lines
and that
printk("<1>%d\n", TimerIntrpt);you shouldn't use <1> in printk strings ever.
<1>gives me messages on screen on my box, thats why.
the same effect is while using kmalloc, just change vmalloc to kmalloc.
Quoted 7 lines
#include <
linux/kernel.h>and then use
printk(KERN_CRIT "%d\n", TimerIntrpt);We have these definitions for a reason. 8)
Thx guys, i am concidering this as my lack of information. But anyway, i am really impressed in spead of response.
Chears :)
Signature · 2 lines
Grzegorz Jaskiewicz <[email protected]> K4 Labs
Quoted 9 lines · Arjan van de Ven
Quoted 4 lines · Grzegorz Jaskiewicz
Quoted 2 lines · Arjan van de Ven
Quoted 1 line
#include <
linux/modversions.h>don't do that. ever.
why ?
because if you ever need it,
modules.hwill automatically include it for you already. And if it doesn't you don't need it and it does more harm than good.
Is that true? I thought the kernel build system added it with the -include argument to gcc? And so it works properly _only_ if you're using the correct way of building out-of-tree modules, which as discussed recently on this list is
make -C $LINUXDIR SUBDIRS=pwd
where LINUXDIR defaults to /lib/modules/uname -r/build unless the user specifies otherwise.
Some distributions ship a kernel-source package which is broken and does not work like this. File that as a bug if you encounter it.
/me runs from Arjan :)
Signature · 1 line
dwmw2