linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julian Calaby <julian.calaby@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	linux-arch@vger.kernel.org,
	linux-scsi <linux-scsi@vger.kernel.org>,
	iss_storagedev@hp.com, linux-rdma@vger.kernel.org,
	netdev <netdev@vger.kernel.org>,
	linux-atm-general@lists.sourceforge.net,
	linux-wireless <linux-wireless@vger.kernel.org>,
	dri-devel@lists.freedesktop.org, linux-crypto@vger.kernel.org,
	linux-eata@i-connect.net, linux-media@vger.kernel.org
Subject: Re: [PATCH 00/22] Add and use pci_zalloc_consistent
Date: Tue, 24 Jun 2014 09:27:25 +1000	[thread overview]
Message-ID: <CAGRGNgVD2f0S-v8YZ-qABEhDJAwk5pp71FU9uLR8aSZ+DhABjg@mail.gmail.com> (raw)
In-Reply-To: <1403550809.15811.13.camel@joe-AO725>

Hi Joe,

On Tue, Jun 24, 2014 at 5:13 AM, Joe Perches <joe@perches.com> wrote:
> On Mon, 2014-06-23 at 10:25 -0700, Luis R. Rodriguez wrote:
>> On Mon, Jun 23, 2014 at 06:41:28AM -0700, Joe Perches wrote:
>> > Adding the helper reduces object code size as well as overall
>> > source size line count.
>> >
>> > It's also consistent with all the various zalloc mechanisms
>> > in the kernel.
>> >
>> > Done with a simple cocci script and some typing.
>>
>> Awesome, any chance you can paste in the SmPL? Also any chance
>> we can get this added to a make coccicheck so that maintainers
>> moving forward can use that to ensure that no new code is
>> added that uses the old school API?
>
> Not many of these are recent.
>
> Arnd Bergmann reasonably suggested that the pci_alloc_consistent
> api be converted the the more widely used dma_alloc_coherent.
>
> https://lkml.org/lkml/2014/6/23/513
>
>> Shouldn't these drivers just use the normal dma-mapping API now?
>
> and I replied:
>
> https://lkml.org/lkml/2014/6/23/525
>
>> Maybe.  I wouldn't mind.
>> They do seem to have a trivial bit of unnecessary overhead for
>> hwdev == NULL ? NULL : &hwdev->dev
>
> Anyway, here's the little script.
> I'm not sure it's worthwhile to add it though.
>
> $ cat ./scripts/coccinelle/api/alloc/pci_zalloc_consistent.cocci
> ///
> /// Use pci_zalloc_consistent rather than
> ///     pci_alloc_consistent followed by memset with 0
> ///
> /// This considers some simple cases that are common and easy to validate
> /// Note in particular that there are no ...s in the rule, so all of the
> /// matched code has to be contiguous
> ///
> /// Blatantly cribbed from: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
>
> @@
> type T, T2;
> expression x;
> expression E1,E2,E3;
> statement S;
> @@
>
> - x = (T)pci_alloc_consistent(E1,E2,E3);
> + x = pci_zalloc_consistent(E1,E2,E3);
>   if ((x==NULL) || ...) S
> - memset((T2)x,0,E2);

I don't know much about SmPL, but wouldn't having that if statement
there reduce your matches?

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/

  reply	other threads:[~2014-06-23 23:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 13:41 [PATCH 00/22] Add and use pci_zalloc_consistent Joe Perches
2014-06-23 13:41 ` [PATCH 19/22] scsi: Use pci_zalloc_consistent Joe Perches
2014-06-23 17:25 ` [PATCH 00/22] Add and use pci_zalloc_consistent Luis R. Rodriguez
2014-06-23 19:13   ` Joe Perches
2014-06-23 23:27     ` Julian Calaby [this message]
2014-06-24 11:32       ` Johannes Berg
     [not found] ` <cover.1403530604.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2014-06-23 21:49   ` David Miller
2014-06-25 19:41 ` John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGRGNgVD2f0S-v8YZ-qABEhDJAwk5pp71FU9uLR8aSZ+DhABjg@mail.gmail.com \
    --to=julian.calaby@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=iss_storagedev@hp.com \
    --cc=joe@perches.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-atm-general@lists.sourceforge.net \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-eata@i-connect.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mcgrof@do-not-panic.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).