From owner-freebsd-drivers@FreeBSD.ORG Wed Jan 22 05:09:19 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 EA03C56B for ; Wed, 22 Jan 2014 05:09:18 +0000 (UTC) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B1C4E1E15 for ; Wed, 22 Jan 2014 05:09:17 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id ar20so6365647iec.34 for ; Tue, 21 Jan 2014 21:09:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=FK6jWCWJGDEjraV3DWRqPzv9Y0WiFIybppjVyZGJbrQ=; b=cfs4o1ViTEQoWPEeKuDieXhsSBczaAQ/XUXtvpOpC2hWnb9ghQw/i/hceH9EbIR4io f/h+BPwt2cEnoihiqudLRCTIQKcs+nzFRR5GWwuldjnIwW3qd+v3gbdwK2E7d5qCjPfB zjtfpN/jpTX5x3ACFlgInxRNScyApDnoFkQr2F4DY1HHdydac8W5RNvLe3+oo8bFy6Wh i7iWb83ny6752GwWdu6IeGlzFfMnKATe5/pX2h+LQz0wdRrzFp8Vah37h2ev7dll9Sh0 gkbgrf20oOWhlE/86D2DE4d023/gGpxoTyA4MTGfgrknGHCrDHOrdE91Ya3DCwI2S8Tv mTyg== X-Gm-Message-State: ALoCoQnMZ2/877LRjMN8BjvfFfcfCXmxaTHxfsXUTLgnTkMg/9k4N3tYLw5+ZlWkYGLJ2fXASJGj X-Received: by 10.50.50.70 with SMTP id a6mr1148563igo.1.1390367351187; Tue, 21 Jan 2014 21:09:11 -0800 (PST) Received: from fusion-mac.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPSA id f15sm18719259igd.3.2014.01.21.21.09.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Jan 2014 21:09:10 -0800 (PST) Sender: Warner Losh Subject: Re: bus_alloc_resource() is degrading the system performance Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: Date: Tue, 21 Jan 2014 22:09:09 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: vadiraj cs X-Mailer: Apple Mail (2.1085) Cc: freebsd-drivers@freebsd.org 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 05:09:19 -0000 On Jan 21, 2014, at 9:30 PM, vadiraj cs wrote: > Hi All, >=20 > 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. >=20 > 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. >=20 > Before module load--- > #dd if=3D/dev/zero of=3D/dev/md0 bs=3D4k count=3D10k > 10240+0 records in > 10240+0 records out > 41943040 bytes transferred in 0.256835 secs (163307348 bytes/sec) >=20 >=20 > After module load----------- > # dd if=3D/dev/zero of=3D/dev/md0 bs=3D4k count=3D10k > 10240+0 records in > 10240+0 records out > 41943040 bytes transferred in 5.162754 secs (8124160 bytes/sec) >=20 >=20 > 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(). >=20 > reg_res =3D bus_alloc_resource(dev, SYS_RES_MEMORY, ®_bar_id, > 0UL, ~0UL, 512, RF_ACTIVE); >=20 > 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=