From owner-freebsd-drivers@FreeBSD.ORG Wed Jan 22 04:30:29 2014 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 030A26B for ; Wed, 22 Jan 2014 04:30:29 +0000 (UTC) Received: from mail-oa0-x244.google.com (mail-oa0-x244.google.com [IPv6:2607:f8b0:4003:c02::244]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C1E111AC6 for ; Wed, 22 Jan 2014 04:30:28 +0000 (UTC) Received: by mail-oa0-f68.google.com with SMTP id h16so2282214oag.7 for ; Tue, 21 Jan 2014 20:30:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=/i8igi+jmeyw/N44B1J0uCdw2E0ohs1jZ0zitAdO5Kg=; b=A+1FnNRU1jbq/CCr8um1lpWrKeEizTMRgRHDOSpp0dVkVwiw4cZEhfCwwO/4aoYF9w e0SwHORHxX+YggW145+DdVq9cNCWJqKwUJeXohBOxXoxvkCbNv0WaTLj7xepVSxjQifx CblVFeloFGRWVwElBTX2nUkz+SQI0RYf1jT59/ii6FXbrpuuLyz4SN2mBQg57aikliQ6 xI1uOHqMde+u0VUOyyUJqC6s27eb+UvhOnD1lKWSHvix2jc4/cTNUnuHpkSWn1F7uaN/ xY+9kyRMGjKT0jvbQhKoBqHzFmO+XV4CuroHMJeyoazujJBHSmzzCcGkVsrX8vPPrn0D FJRA== MIME-Version: 1.0 X-Received: by 10.60.119.70 with SMTP id ks6mr11332965oeb.45.1390365028002; Tue, 21 Jan 2014 20:30:28 -0800 (PST) Received: by 10.76.168.170 with HTTP; Tue, 21 Jan 2014 20:30:27 -0800 (PST) Date: Wed, 22 Jan 2014 10:00:27 +0530 Message-ID: Subject: bus_alloc_resource() is degrading the system performance From: vadiraj cs To: freebsd-drivers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.17 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jan 2014 04:30:29 -0000 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. 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. Parameters passed to bus_alloc_resource(). reg_res = bus_alloc_resource(dev, SYS_RES_MEMORY, ®_bar_id, 0UL, ~0UL, 512, RF_ACTIVE); Any pointers to this will be of great help. Thanks,