bus_alloc_resource() is degrading the system performance

Warner Losh imp at bsdimp.com
Wed Jan 22 05:09:19 UTC 2014


On Jan 21, 2014, at 9:30 PM, vadiraj cs wrote:

> Hi All,
> 
> I'm writing a driver for a PCI device and allocating bus resource through
> call bus_alloc_resource(). I see that doing this is making my system
> performance go down.
> 
> Here is the dd output before loading my module and soon after loading my
> module.
> I'm running dd on a ramdisk before and after loading the module.
> 
> Before module load---
> #dd if=/dev/zero of=/dev/md0 bs=4k count=10k
> 10240+0 records in
> 10240+0 records out
> 41943040 bytes transferred in 0.256835 secs (163307348 bytes/sec)
> 
> 
> After module load-----------
> # dd if=/dev/zero of=/dev/md0 bs=4k count=10k
> 10240+0 records in
> 10240+0 records out
> 41943040 bytes transferred in 5.162754 secs (8124160 bytes/sec)
> 
> 
> Why dd? The device for which I'm writing a driver is a nvram pci card.
> Hence this
> will be storage device. The performance of this disk is way low. I
> suspected the driver. But once the driver is loaded even the ramdisk starts
> performing low.

Perhaps you are swapping?

> After some debugging I realized that allocating bus resource is causing
> this behavior. The size reserved varied from 512 bytes to 512K. There was
> no change in the behavior. So resource size is not an issue.

Having had a lot of experience, I'm pretty sure that you need to keep looking.

> Parameters passed to bus_alloc_resource().
> 
> reg_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &reg_bar_id,
>                                     0UL, ~0UL, 512, RF_ACTIVE);
> 
> Any pointers to this will be of great help.

I'd look to the resources that the nvram PCI card is using apart from those on the bus.

Warner


More information about the freebsd-drivers mailing list