Memory leak in I2C (ticket #1898)
Hi James,
I am moving this to the mailing-list since it is likely to require some investigation before we can find out what's going on, and our current ticket system is not meant for this. (Philip, Axel, where is the new Bugzilla system going?)
Most things in the i2c core in linux 2.4 are static, so I doubt that there can be a leak in i2c-core itself. i2c-proc OTOH is likely to allocate memory for various things, so this is a candidate. And, as you suggested yourself, individual drivers are candidates as well.
Please tell us:
* Which i2c drivers you are using.
* What your test script is. Which modules are you cycling exactly, in which order, at which rate? I'd be happy to do the same on my own machines (with different bus and chip drivers) and see if I can reproduce the problem.
Once we know in which kernel module the leak is, it shouldn't be too hard to find out where the leak is exactly. There aren't that many memory allocations in there.
BTW, thanks a lot for reporting.
--
Jean Delvare
Hi Mark,
Quoted 4 lines
were there any hints in dmesg?
hitting table size limits in i2c-core can also return ENOMEM, but should also generate a message about increasingI2C_xxx_MAX. I'd say this is more likely than running your whole box out of memory.
I don't agree. James' script unloads and reloads a limited number of modules (less than I2C_xxx_MAX), and repeats the process forever. If there is a memory leak somewhere, it comes to no surprise that this script hits it.
Signature · 1 line
Jean Delvare
Hi James,
Quoted 6 lines
Here is the list in the order they are loaded:
i2c-core i2c-dev i2c-proc i2c-i801 lm87b lm93 eeprom pcf8574When I found the appearant memory leak I was only loading and unloading modules lm93, eeprom, pcf8574.
Tried with i2c-core, i2c-proc, i2c-viapro and w83781d, with only w83781d cycling. I noticed that the "free" memory as reported by top would decrease almost to 0. However it would NOT generate a memory shortage. If I run Firefox at this point, it'll get all the memory it needs (and I disabled swap for the test). So I don't think I am able to reproduce what you described.
Can you possibly try with each of the three modules (lm93, eeprom, pcf8574) individually and see if all cause the trouble, or only one of them?
How much memory do you have on your system?
Quoted 3 lines
Not a problem. Thanks for looking into this. One of these days I'll get my head around the I2C and
lm_sensorsarchitecture in the kernel, and maybe I can send you patches instead (-;
This would indeed be very welcome :)
Signature · 1 line
Jean Delvare
were there any hints in dmesg?
hitting table size limits in i2c-core can also return ENOMEM, but should also generate a message about increasing I2C_xxx_MAX. I'd say this is more likely than running your whole box out of memory. mds
Quoted 75 lines · James Olin Oden
Quoted 7 lines · Jean Delvare
Hi James,
I am moving this to the mailing-list since it is likely to require some investigation before we can find out what's going on, and our current ticket system is not meant for this. (Philip, Axel, where is the new Bugzilla system going?)
Fine by me.
Quoted 9 lines
Most things in the i2c core in linux 2.4 are static, so I doubt that there can be a leak in i2c-core itself. i2c-proc OTOH is likely to allocate memory for various things, so this is a candidate. And, as you suggested yourself, individual drivers are candidates as well.
Please tell us:
* Which i2c drivers you are using.
Here is the list in the order they are loaded:
i2c-core i2c-dev i2c-proc i2c-i801 lm87b lm93 eeprom pcf8574When I found the appearant memory leak I was only loading and unloading modules lm93, eeprom, pcf8574.
Quoted 4 lines
* What your test script is. Which modules are you cycling exactly, in which order, at which rate? I'd be happy to do the same on my own machines (with different bus and chip drivers) and see if I can reproduce the problem.
I have attached the script. As far as rate, I was trying to force an
oops (which I could do with a previous release) so the only throttling was system itself. Basically I ran the test sc ript with this shell snippet:while test.i2c.oops do : doneAs I said earlier in the bug report, its not a likely scenario, but IMHO it is a valid test case, if only if it stresses the registration
deregistration process. On the system I was running this on we have
a program that kicks off about every 30 seconds and runs the sensors command. I don't think you needed that to produce the memory leak, but it probably was requried to produce the oops that you guys seemed to have fixed.The test script is fairly simple. It has an internal list of modules that it loads in one order, and then unloads in the opposite order. You can pass the arg --modcount=$number to tell it starting from the
back only load and unload $number modules. You can override its
default module list by using --modules=$mod1,...,$modN. I use depmod
to load and unload the modules, if dependent modules are not loaded they should be loaded (not tested that though).Quoted 5 lines
Once we know in which kernel module the leak is, it shouldn't be too hard to find out where the leak is exactly. There aren't that many memory allocations in there.
BTW, thanks a lot for reporting.
Not a problem. Thanks for looking into this. One of these days I'll get my head around the I2C and
lm_sensorsarchitecture in the kernel, and maybe I can send you patches instead (-;Cheers...james
Quoted 8 lines · Jean Delvare
Hi James,
I am moving this to the mailing-list since it is likely to require some investigation before we can find out what's going on, and our current ticket system is not meant for this. (Philip, Axel, where is the new Bugzilla system going?)
Fine by me.
Quoted 9 lines
Most things in the i2c core in linux 2.4 are static, so I doubt that there can be a leak in i2c-core itself. i2c-proc OTOH is likely to allocate memory for various things, so this is a candidate. And, as you suggested yourself, individual drivers are candidates as well.
Please tell us:
* Which i2c drivers you are using.
Here is the list in the order they are loaded:
i2c-core i2c-dev i2c-proc i2c-i801 lm87b lm93 eeprom pcf8574
When I found the appearant memory leak I was only loading and unloading modules lm93, eeprom, pcf8574.
Quoted 4 lines
* What your test script is. Which modules are you cycling exactly, in which order, at which rate? I'd be happy to do the same on my own machines (with different bus and chip drivers) and see if I can reproduce the problem.
I have attached the script. As far as rate, I was trying to force an
oops (which I could do with a previous release) so the only throttling was system itself. Basically I ran the test sc ript with this shell snippet:
while test.i2c.oops
do
:
doneAs I said earlier in the bug report, its not a likely scenario, but IMHO it is a valid test case, if only if it stresses the registration
deregistration process. On the system I was running this on we have
a program that kicks off about every 30 seconds and runs the sensors command. I don't think you needed that to produce the memory leak, but it probably was requried to produce the oops that you guys seemed to have fixed.
The test script is fairly simple. It has an internal list of modules that it loads in one order, and then unloads in the opposite order. You can pass the arg --modcount=$number to tell it starting from the
back only load and unload $number modules. You can override its
default module list by using --modules=$mod1,...,$modN. I use depmod
to load and unload the modules, if dependent modules are not loaded they should be loaded (not tested that though).
Quoted 6 lines
Once we know in which kernel module the leak is, it shouldn't be too hard to find out where the leak is exactly. There aren't that many memory allocations in there.
BTW, thanks a lot for reporting.
Not a problem. Thanks for looking into this. One of these days I'll get my head around the I2C and lm_sensors architecture in the kernel, and maybe I can send you patches instead (-;
Cheers...james
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.i2c.oops
Type: application/octet-stream
Size: 3437 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050215/1adecdb4/test.i2c.obj
Quoted 16 lines · Jean Delvare
Hi James,
Quoted 6 lines
Here is the list in the order they are loaded:
i2c-core i2c-dev i2c-proc i2c-i801 lm87b lm93 eeprom pcf8574When I found the appearant memory leak I was only loading and unloading modules lm93, eeprom, pcf8574.
Tried with i2c-core, i2c-proc, i2c-viapro and w83781d, with only w83781d cycling. I noticed that the "free" memory as reported by top would decrease almost to 0. However it would NOT generate a memory shortage. If I run Firefox at this point, it'll get all the memory it needs (and I disabled swap for the test). So I don't think I am able to reproduce what you described.
Quoted 4 lines
Can you possibly try with each of the three modules (lm93, eeprom, pcf8574) individually and see if all cause the trouble, or only one of them?
Sure. It will have to wait till Tuesday, when I get back into work, but yeah I can do that. I was merely working other tasks until I could see if you could reproduce.
Quoted 2 lines
How much memory do you have on your system?
Between 4-16 gig (don't remember what was on that particular system, but all of our systems have between 4-16gig). I'll get you the precise figure when I get back in to work.
Cheers...james
Quoted 17 lines · James Olin Oden
Quoted 16 lines · Jean Delvare
Hi James,
Quoted 6 lines
Here is the list in the order they are loaded:
i2c-core i2c-dev i2c-proc i2c-i801 lm87b lm93 eeprom pcf8574When I found the appearant memory leak I was only loading and unloading modules lm93, eeprom, pcf8574.
Tried with i2c-core, i2c-proc, i2c-viapro and w83781d, with only w83781d cycling. I noticed that the "free" memory as reported by top would decrease almost to 0. However it would NOT generate a memory shortage. If I run Firefox at this point, it'll get all the memory it needs (and I disabled swap for the test). So I don't think I am able to reproduce what you described.
Quoted 8 lines
Quoted 4 lines
Can you possibly try with each of the three modules (lm93, eeprom, pcf8574) individually and see if all cause the trouble, or only one of them?
Sure. It will have to wait till Tuesday, when I get back into work, but yeah I can do that. I was merely working other tasks until I could see if you could reproduce.
OK, it took much longer than expected (I was wrestling with a much
more difficult and significant problem). At anyrate, I can
reproduce, with just the eeprom chip driver. It takes I think between 30 minutes and an hour to reproduce. Also, I have observed the occasional (far less than before going to 2.9.0) panic while unloading drivers as something was invoking the sysctl functionality of the driver.
What is rather odd, if I make several connections to the box, and load and unload different drivers in each session (lm93 in one, eeprom in another, ect), I tend to get the out of memory errors much faster. I need to do this again, though just to make sure I hadn't already tainted the system with other tests.
Just so you know I can reproduce the memory leaks on both E7501 and E7520 based systems. I did not think it would be system specific but this pretty much tells me its not.
I still need to find out if I can get it to cause the out memory errors with other drivers or not.
I will send more info when I have it.
Cheers...james
Quoted 5 lines
I still need to find out if I can get it to cause the out memory errors with other drivers or not.
I will send more info when I have it.
This is still with eeprom driver, but here is the output from the latest run, that I modifed to actually give the runtime when it died, and how many times the driver was loaded and unloaded:
<<< LOADING eeprom >>>
/sbin/insmod/lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o
Using /lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o Symbol version prefix 'smp_'
--> /lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o:init_module: Cannot allocate memory
Hint: insmod errors can be caused by incorrect module parameters,
including invalid IO or IRQ parameters.
You may find more information in syslog or the output from dmesg /lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o:
insmod
/lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o
failed
/lib/modules/2.4.21-27.0.2.ELprerel2.0.0_50.2.0smp/kernel/drivers/i2c/chips/eeprom.o:
insmod eeprom failed
ERROR: Failed to load module!
ERROR: MODULE eeprom
RC: 255
ERROR: Failed to load all sensors modules!
Test Started: 1110314178
Test Stopped: 1110316517
Elapsed Time: 2339 seconds
Test Passes: 12980
So it runs for about 40 minutes and then runs out of memory. Is
there anything I can do to look at kernel memory consumtion that would be helpful for you?
Also, I have attached the new test script. It now has a loop option so you don't have to do the little while loop. It also tries to handle Ctrl-C cleanly, but its still broken (-;
Wait, just got results from only doing the lm93 driver. It took reach
the out of memory condition. I was trying to see if I could also
force a panic on this system also, so I don't have the time (but it took quite a while). Output of the error is basically the same (i.e. s/eeprom/lm93/g).
Cheers...james
Quoted 4 lines
Also, I have attached the new test script. It now has a loop option so you don't have to do the little while loop. It also tries to handle Ctrl-C cleanly, but its still broken (-;
OK, I did this time...james
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.i2c.oops
Type: application/octet-stream
Size: 5457 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050308/e046e577/test.i2c.obj