UBI memory leak after creating and removing volumes

John Smith john.smith at pace.com
Sat Feb 21 16:30:44 EST 2009


Previously I said:

> On Tue, 2009-02-17 at 12:01 +0000, John.Smith at pace.com wrote:
> > I am using a 2.6.18 Kernel, patched with MTD from Kernel 2.6.21, and
> > UBI from the mainline kernel a few days later on 1 May 2007.  The
> > whole is running on an embedded MIPS device.
> >

The problem is still present on current versions of Linux. I have
tested on 2.6.28.6 using QEMU to make a virtual x86.

With these settings in the kernel .config file:
   CONFIG_MTD=y
   CONFIG_MTD_BLKDEVS=y
   CONFIG_MTD_MTDRAM=y
   CONFIG_MTD_UBI=y

then a sequence of calls of the form

for ((i=0; i<100; i++)) ; do
   ubimkvol -d 0 -n 2 -N vol2 -s 1000
   ubimkvol -d 0 -n 3 -N vol3 -s 1000
   ubirmvol -d 0 -n 3
   ubirmvol -d 0 -n 2
done
cat /proc/meminfo | grep Slab

shows Slab increasing by about 1.6kB per iteration

The problem can also be demonstrated using MTD modules,
without using UBI. If I build two MTD simulated devices
as kernel modules using these settings in .config:
   CONFIG_MTD_MTDRAM=m
   CONFIG_MTD_NAND_NANDSIM=m

then

   insmod mtdram.ko
   insmod nandsim.ko
   rmmod  nandsim.ko
   rmmod  mtdram.ko

shows a similar leak of about 1.6kB.


The leak does not happen if the calls are not nested. So
   insmod mtdram.ko
   rmmod  mtdram.ko
   insmod nandsim.ko
   rmmod  nandsim.ko
and
   ubimkvol -d 0 -n 2 -N vol2 -s 1000
   ubirmvol -d 0 -n 2
   ubimkvol -d 0 -n 3 -N vol3 -s 1000
   ubirmvol -d 0 -n 3
do not leak.

The leak does not happen if
# CONFIG_MTD_BLKDEVS is not set.

 From /proc/slabinfo it seems that we are leaking sysfs_dir_cache
objects.

John

John Smith

p.s. some automatic system is about to add a silly disclaimer. Ingore it...
This E-mail and any attachments hereto are strictly confidential and intended solely for the addressee. If you are not the intended addressee please notify the sender by return and delete the message. You must not disclose, forward or copy this E-mail or attachments to any third party without the prior consent of the sender. Pace plc is registered in England and Wales (Company no. 1672847) and our Registered Office is at Victoria Road, Saltaire, West Yorkshire, BD18 3LF, UK. Tel +44 (0) 1274 532000 Fax +44 (0) 1274 532010. <http://www.pace.com>
Save where otherwise agreed in writing between you and Pace (i) all orders for goods and/or services placed by you are made pursuant to Pace's standard terms and conditions of sale which may have been provided to you, or in any event are available at http://www.pace.com/uktcsale.pdf (ii) all orders for goods and/or services placed by Pace are subject to Pace's standard terms and conditions of purchase which may have been provided to you, or in any event are available at http://www.pace.com/uktcpurch.pdf. All other inconsistent terms in any other documentation including without limitation any purchase order, reschedule instruction, order acknowledgement, delivery note or invoice are hereby excluded.



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



More information about the linux-mtd mailing list