2.4.32 Fix memory leak in ide-probe
A message that is not in the archive (sent off-list or not yet received): [email protected]
Nick,
If it works please forward the results and other information to everyone
Cheers,
Andre Hedrick
LAD Storage Consulting Group
Quoted 10 lines · Nick Pollitt
Andre, I found this memory leak running a bash loop calling cardctl to insert and eject a single PCMCIA card continuously. Over time the slab-32 and slab-64 caches had consumed all system memory. The memory was full of the IDE settings allocated in
ide_add_generic_settings.It appears that
ide_add_generic_settingsis getting called for interfaces that aren't present, and there are never any calls to free up those resources. The check for the presence of the interface was removed in 2.4.19, and this patch rolls back to the previous behavior.
Quoted 5 lines
If this looks OK I'd like to ask Marcello to include in the next 2.4 rev.
Thank you,
Nick
drivers/ide/ide-probe.c +8 -8
@@ -1241,15 +1241,15 @@ static void init_gendisk (ide_hwif_t *hwadd_gendisk (gd);for (unit =0 ; unit < units; ++unit) { -char name[64 ]; -ide_add_generic_settings (hwif->drives + unit); -// hwif->drives[unit].dn = ((hwif->channel ? 2 : 0) + unit); -sprintf (name,"host%d/bus%d/target%d/lun%d" , - (hwif->channel && hwif->mate) ? - hwif->mate->index : hwif->index, - hwif->channel, unit, hwif->drives[unit].lun); -if (hwif->drives[unit].present) +if (hwif->drives[unit].present) { +char name[64 ]; +ide_add_generic_settings (hwif->drives + unit); +sprintf (name,"host%d/bus%d/target%d/lun%d" , + (hwif->channel && hwif->mate) ? + hwif->mate->index : hwif->index, + hwif->channel, unit, hwif->drives[unit].lun); hwif->drives[unit].de =devfs_mk_dir (ide_devfs_handle, name,NULL ); + } }return ;
Quoted 4 lines · Andre Hedrick
Nick,
If it works please forward the results and other information to everyone
On a stock 2.4.32 kernel, with 64M RAM, I can run my laptop out of memory in about 24 hours with the cardctl loop mentioned previously. The memory is all tied up in size-32 and size-64 caches.
To test the patch I started the cardctl loop last Friday (19th) on a 2.4.32 with the patch applied. Today, after 75000+ pcmcia inserts/ejects the size-32 and size-64 slab caches are still at a reasonable size. At the beginning of the test (fresh reboot) size-32 had 10 total slabs, size-64 had 3. Now, after 5 days of continuous testing, size-32 still has 10, and size-64 still has 3.
So I think this patch addresses the issue of the size-32 and size-64 slabs.
...and the test is still running so I can watch the buffer_head cache.
Does this patch look OK to everyone?
Thanks,
Nick
Quoted 25 lines
Cheers,
Andre Hedrick
LAD Storage Consulting GroupQuoted 15 lines · Nick Pollitt
Andre, I found this memory leak running a bash loop calling cardctl to insert and eject a single PCMCIA card continuously. Over time the slab-32 and slab-64 caches had consumed all system memory. The memory was full of the IDE settings allocated in
ide_add_generic_settings.It appears that
ide_add_generic_settingsis getting called for interfaces that aren't present, and there are never any calls to free up those resources. The check for the presence of the interface was removed in 2.4.19, and this patch rolls back to the previous behavior.If this looks OK I'd like to ask Marcello to include in the next 2.4 rev.
Thank you,
Nick
drivers/ide/ide-probe.c +4 -18
@@ -843,29 +843,15 @@ static void init_gendisk (ide_hwif_t *hwadd_gendisk (gd);for (unit =0 ; unit < units; ++unit) { -#if 1 -char name[64 ]; -ide_add_generic_settings (hwif->drives + unit); - hwif->drives[unit].dn = ((hwif->channel ?2 :0 ) + unit); -sprintf (name,"host%d/bus%d/target%d/lun%d" , - (hwif->channel && hwif->mate) ? - hwif->mate->index : hwif->index, - hwif->channel, unit, hwif->drives[unit].lun); -if (hwif->drives[unit].present) - hwif->drives[unit].de =devfs_mk_dir (ide_devfs_handle, name,NULL ); -#else if (hwif->drives[unit].present) {char name[64 ]; -ide_add_generic_settings (hwif->drives + unit); - hwif->drives[unit].dn = ((hwif->channel ?2 :0 ) + unit);sprintf (name,"host%d/bus%d/target%d/lun%d" , - (hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index, - hwif->channel, unit, hwif->drives[unit].lun); - hwif->drives[unit].de = -devfs_mk_dir (ide_devfs_handle, name,NULL ); + (hwif->channel && hwif->mate) ? + hwif->mate->index : hwif->index, + hwif->channel, unit, hwif->drives[unit].lun); + hwif->drives[unit].de =devfs_mk_dir (ide_devfs_handle, name,NULL ); } -#endif }return ;