Skip to contentSkip to conversation

ohci1394: dma_pool_destroy while in_atomic() && irqs_disabled()

PATCH David Brownell 3 participants 4 messages Feb 19, 2005

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines
Quoted 4 lines

Jody - Is the 200K waste for sure or do you want me to verify it by some means? ( Reason I am asking is firstly, Dave Brownell was quite sure it wasn't that costly and secondly, I am hoping it isn't.. ;)

Quoted 8 lines

I'm not sure, but I looked through the code and it seems to allocate:
- 16 buffers of 2x PAGE_SIZE (= 131072 on i386)
- 16 buffers of PAGE_SIZE (= 65536 on i386)
- various other smaller structures.

I'm not sure how to actually _measure_ how much memory this is using. slabinfo isn't useful, at least on my system, because the 1394 allocations get lost in the noise of other activity.

Those allocations could be from _using_ a dma pool ... but they're not from just creating one!

The cost of creating the dma_pool is the cost of one small kmalloc() plus (the expensive part) the /sys/devices/.../pools sysfs attribute is created along with the first pool. (Use that instead of slabinfo for those pool allocations.) That's why the normal spot to create and destroy dma pools is in driver probe() and remove() methods.

If you want to allocate gobs of other stuff at the same time, that's your choice ... but it'd be a separate issue. Cost to create a dma_pool is significantly less than PAGE_SIZE, and there's no good reason to allocate or destroy those pools anywhere near an IRQ context.

- Dave

#1 lore raw
Quoted 5 lines · David Brownell

The cost of creating the dma_pool is the cost of one small kmalloc() plus (the expensive part) the /sys/devices/.../pools sysfs attribute is created along with the first pool.  (Use that instead of slabinfo for those pool allocations.)  That's why the normal spot to create and destroy dma pools is in driver probe() and remove() methods.

What's the format of /sys/devices/.../pools (Name of pool, ? ? ? ?) ? Can the memory consumption be derived from it?
Here is what the ohci pools look during data read (Kino->Capture) and after closing Kino -

During Kino Capture
[root@localhost pci0000:00]# cat ./0000:00:0a.0/0000:02:00.0/pools poolinfo - 0.1

ohci1394 rcv prg   16  256   16  1 ------------------> This one is in question
ohci1394 trm prg   32   64   64  1
ohci1394 trm prg   32   64   64  1
ohci1394 rcv prg    4  256   16  1
ohci1394 rcv prg    4  256   16  1

After Closing Kino
[root@localhost pci0000:00]# cat ./0000:00:0a.0/0000:02:00.0/pools poolinfo - 0.1

ohci1394 trm prg   32   64   64  1
ohci1394 trm prg   32   64   64  1
ohci1394 rcv prg    4  256   16  1
ohci1394 rcv prg    4  256   16  1

Parag

#2 lore raw
Quoted 9 lines · Parag Warudkar
Quoted 5 lines · David Brownell

The cost of creating the dma_pool is the cost of one small kmalloc() plus (the expensive part) the /sys/devices/.../pools sysfs attribute is created along with the first pool.  (Use that instead of slabinfo for those pool allocations.)  That's why the normal spot to create and destroy dma pools is in driver probe() and remove() methods.

What's the format of /sys/devices/.../pools (Name of pool, ? ? ? ?) ? Can the memory consumption be derived from it?

See what drivers/base/dmapool.c tells you; yes that consumption can be derived from the pool statistics.

Quoted 11 lines

Here is what the ohci pools look during data read (Kino->Capture) and after closing Kino -

During Kino Capture
[root@localhost pci0000:00]# cat ./0000:00:0a.0/0000:02:00.0/pools poolinfo - 0.1

ohci1394 rcv prg   16  256   16  1 ------------------> This one is in question
ohci1394 trm prg   32   64   64  1
ohci1394 trm prg   32   64   64  1
ohci1394 rcv prg    4  256   16  1
ohci1394 rcv prg    4  256   16  1

I suggest you get rid of the spaces in those names, to make it easier to use things like "awk" to massage those numbers. The "ohci1394" is implied by the fact that no other driver could be bound to that device, for example.

In this case, other than the fact that you've created multiple pools with the same names (!), that line translates to 16 blocks in use out of 256 available, 16 bytes per block, just one page.

I suspect that on some systems it should be bumping up the minimum block size to match the CPU cacheline size.

- Dave

#3 lore raw
In reply to David Brownell
Quoted 9 lines · David Brownell

Those allocations could be from _using_ a dma pool ... but they're not from just creating one!

The cost of creating the dma_pool is the cost of one small kmalloc() plus (the expensive part) the /sys/devices/.../pools sysfs attribute is created along with the first pool. (Use that instead of slabinfo for those pool allocations.) That's why the normal spot to create and destroy dma pools is in driver probe() and remove() methods.

OK, then I misread drivers/base/pool.c and my objection to the patch is unfounded.

Quoted 4 lines

If you want to allocate gobs of other stuff at the same time, that's your choice ... but it'd be a separate issue. Cost to create a dma_pool is significantly less than PAGE_SIZE, and there's no good reason to allocate or destroy those pools anywhere near an IRQ context.

I agree. raw1394 does far too much with irqs disabled, and moving this stuff to probe() will fix part of that problem.

Jody

Quoted 7 lines

- Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/