Skip to contentSkip to conversation

New: usb_alloc_urb() leaks memory together with uvcvideo driver

Bugme-new Andrew Morton 5 participants 10 messages Feb 24, 2009 – Feb 26, 2009 1 message not in the archive Media (V4L/DVB)

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

(switched to email. Please respond via emailed reply-to-all, not via the bugzilla web interface).

Quoted 1 line · On Mon, 23 Feb 2009 22:08:37 -0800 (PST) [email protected] wrote:

http://bugzilla.kernel.org/show_bug.cgi?id=12768

There's additional info at the link.

Quoted 49 lines
           Summary: usb_alloc_urb() leaks memory together with uvcvideo
                    driver
           Product: Drivers
           Version: 2.5
     KernelVersion: 2.6.28
          Platform: All
        OS/Version: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: USB
        AssignedTo: [email protected]
        ReportedBy: [email protected]

Latest working kernel version:
Earliest failing kernel version:
Distribution:
Hardware Environment: EeePC 901
Software Environment: Debian 5.0
Problem Description:

Steps to reproduce:
1. Boot the system
2. start an xterm window and execute the following command:

$ while true; do clear; cat /proc/slab_allocators |grep usb_alloc; sleep 1;
done

This will print out similar lines each second:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 85 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

3. Start xawtv, this will show the picture of the webcam
4. Exit xawtv

Current result:
In the output of /proc/slab_allocators the number of blocks allocated by usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

#2 lore raw
Quoted 60 lines · Andrew Morton

(switched to email.  Please respond via emailed reply-to-all, not via the bugzilla web interface).

Quoted 1 line · On Mon, 23 Feb 2009 22:08:37 -0800 (PST) [email protected] wrote:

http://bugzilla.kernel.org/show_bug.cgi?id=12768

There's additional info at the link.

Quoted 49 lines

           Summary: usb_alloc_urb() leaks memory together with uvcvideo driver
           Product: Drivers
           Version: 2.5
     KernelVersion: 2.6.28
          Platform: All
        OS/Version: Linux
              Tree: Mainline
            Status: NEW
          Severity: normal
          Priority: P1
         Component: USB
        AssignedTo: [email protected]
        ReportedBy: [email protected]

Latest working kernel version:
Earliest failing kernel version:
Distribution:
Hardware Environment: EeePC 901
Software Environment: Debian 5.0
Problem Description:

Steps to reproduce:
1. Boot the system
2. start an xterm window and execute the following command:

$ while true; do clear; cat /proc/slab_allocators |grep usb_alloc; sleep 1;
done

This will print out similar lines each second:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 85 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

3. Start xawtv, this will show the picture of the webcam
4. Exit xawtv

Current result:
In the output of /proc/slab_allocators the number of blocks allocated by usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 8 lines
Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

the history of this bug is that someone complained that the em28xx driver leaked, Nemeth traced it back and found out that it also happens with uvcvideo - both drivers kinda have an independent implementation and it happens with both.

Markus

#3 lore raw
In reply to Andrew Morton
Quoted 8 lines · On Tue, 24 Feb 2009 13:57:20 -0800 Andrew Morton <[email protected]>…
Quoted 8 lines
Quoted 1 line

In the output of /proc/slab_allocators the number of blocks allocated by

usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 7 lines
Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

I guess this is a v4l bug. We've found several memory leaks on em28xx driver, fixed at the development -git:

http://git.kernel.org/?p=linux/kernel/git/mchehab/devel.git

I'll do some tests again with the latest em28xx driver to double check if it is there any other memory leak. If not, then we could replicate the same approach into uvcvideo.

Cheers,
Mauro

#4 lore raw
Quoted 19 lines · Mauro Carvalho Chehab
Quoted 8 lines · On Tue, 24 Feb 2009 13:57:20 -0800 Andrew Morton <[email protected]>…
Quoted 8 lines
Quoted 1 line

In the output of /proc/slab_allocators the number of blocks allocated by

usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 7 lines
Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

Quoted 9 lines

I guess this is a v4l bug. We've found several memory leaks on em28xx driver, fixed at the development -git:

http://git.kernel.org/?p=linux/kernel/git/mchehab/devel.git

I'll do some tests again with the latest em28xx driver to double check if it is there any other memory leak. If not, then we could replicate the same approach into uvcvideo.

haha you never even had a look at the issue itself.

Markus

Quoted 7 lines

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 24 lines · On Wed, 25 Feb 2009 03:15:35 +0100 Markus Rechberger <[email protected]>…
Quoted 22 lines · Mauro Carvalho Chehab
Quoted 8 lines · On Tue, 24 Feb 2009 13:57:20 -0800 Andrew Morton <[email protected]>…
Quoted 8 lines
Quoted 1 line

In the output of /proc/slab_allocators the number of blocks allocated by

usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 7 lines
Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

I guess this is a v4l bug. We've found several memory leaks on em28xx driver, fixed at the development -git:

Quoted 8 lines
Quoted 6 lines

http://git.kernel.org/?p=linux/kernel/git/mchehab/devel.git

I'll do some tests again with the latest em28xx driver to double check if it is there any other memory leak. If not, then we could replicate the same approach into uvcvideo.

haha you never even had a look at the issue itself.

What a perfectly useless comment.

#6 lore raw
Quoted 28 lines · Andrew Morton
Quoted 26 lines · On Wed, 25 Feb 2009 03:15:35 +0100 Markus Rechberger <[email protected]>…
Quoted 24 lines · Mauro Carvalho Chehab
Quoted 8 lines · On Tue, 24 Feb 2009 13:57:20 -0800 Andrew Morton <[email protected]>…
Quoted 8 lines
Quoted 1 line

In the output of /proc/slab_allocators the number of blocks allocated by

usb_alloc_urb() increases, however, the xawtv is no longer running:

size-2048: 18 usb_alloc_dev+0x1d/0x212 [usbcore]
size-2048: 2280 usb_alloc_urb+0xc/0x2b [usbcore]
size-1024: 100 usb_alloc_urb+0xc/0x2b [usbcore]
size-128: 10 usb_alloc_urb+0xc/0x2b [usbcore]

Quoted 7 lines
Quoted 5 lines

Each time xawtv is started and stopped the value increases at the usb_alloc_urb().

Expected result: the same memory usage is reached again after xawtv exited.

I assume this is a v4l bug and not a USB core bug?

I guess this is a v4l bug. We've found several memory leaks on em28xx driver, fixed at the development -git:

http://git.kernel.org/?p=linux/kernel/git/mchehab/devel.git

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

I'll do some tests again with the latest em28xx driver to double check if it is there any other memory leak. If not, then we could replicate the same approach into uvcvideo.

haha you never even had a look at the issue itself.

What a perfectly useless comment.

not more or less useless than the one before

http://mcentral.de/pipermail/em28xx/2009-February/002446.html

I followed the other em28xx work too and there has not been anything which addressed that issue.

Markus

#7 lore raw

Please, please, please, can we concentrate on the subject?

What I did with the other out-of-tree em28xx-new driver was that I printed out the urb->kref.refcount before and after each urb operation.

The result was that when the urb->complete function is called, the reference count was still 2, instead of 1.

I could imagine three possible errors:
1. there is a bug in uvcvideo driver
2. there is a bug in v4l framework
3. there is a bug in usb subsystem

It would be good if someone who have a deeper knowledge than me on these fields could give some hints or debug patches which would lead us closer to the solution.

Regards,

Márton Németh

#8 lore raw
Quoted 6 lines · On Wed, 25 Feb 2009 08:44:00 +0100 Németh Márton <[email protected]> wrote:

What I did with the other out-of-tree em28xx-new driver was that I printed out the urb->kref.refcount before and after each urb operation.

The result was that when the urb->complete function is called, the reference count was still 2, instead of 1.

Quoted 7 lines

I could imagine three possible errors:
1. there is a bug in uvcvideo driver
2. there is a bug in v4l framework
3. there is a bug in usb subsystem

It would be good if someone who have a deeper knowledge than me on these fields could give some hints or debug patches which would lead us closer to the solution.

Márton,

I did a test yesterday night with 2.6.29-rc6. The em28xx in-kernel still has same problem we focused a while ago (except that, before, memory were going exausted on a much higher rate, and we had memory leaks for every close() call).

What happens is that, sometimes, memory are not being freed by usb_kill_urb()/usb_unlink_urb(). I'm trying to debug it right now, to understand what's happening.

Cheers,
Mauro

#9 lore raw
Quoted 13 lines · On Wednesday 25 February 2009 13:49:29 Mauro Carvalho Chehab wrote:

On Wed, 25 Feb 2009 08:44:00 +0100

Quoted 10 lines · Németh Márton

What I did with the other out-of-tree em28xx-new driver was that I printed out the urb->kref.refcount before and after each urb operation.

The result was that when the urb->complete function is called, the reference count was still 2, instead of 1.

I could imagine three possible errors:
1. there is a bug in uvcvideo driver
2. there is a bug in v4l framework
3. there is a bug in usb subsystem

I'd vote for 3 (with an option on 1, just in case).

Quoted 6 lines
Quoted 3 lines

It would be good if someone who have a deeper knowledge than me on these fields could give some hints or debug patches which would lead us closer to the solution.

Márton,

Quoted 8 lines

I did a test yesterday night with 2.6.29-rc6. The em28xx in-kernel still has same problem we focused a while ago (except that, before, memory were going exausted on a much higher rate, and we had memory leaks for every close() call).

What happens is that, sometimes, memory are not being freed by usb_kill_urb()/usb_unlink_urb(). I'm trying to debug it right now, to understand what's happening.

Could this

http://article.gmane.org/gmane.linux.usb.general/15315/match=urb+leak

be related ?

Cheers,

Laurent Pinchart