From: "Adam J. Richter" <adam@yggdrasil.com>
To: davem@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: Does pci_alloc_consisent really need to zero memory?
Date: Thu, 30 May 2002 04:41:06 -0700 [thread overview]
Message-ID: <200205301141.EAA15864@baldur.yggdrasil.com> (raw)
Dave S. Miller writes:
>pci_alloc_consistent is so rare, I doubt it [clearing the memory it
>returns] matters performance wise.
In my efforts to port almost all of the scsi drivers to your
DMA-mapping interface, I have converted some kmalloc's that
are frequently called with pci_alloc_consistent (I have not
submitted these changes, because I think there is an unrelated
bug in my changes). Come to think of it, you advised me to go
that route, as opposed to using pci_map_single(), when I asked about
it with respect to advansys.c. I'd like to have as little
performance penalty for this as possible. That also makes it
marginally easier to encourge movement to your DMA-mapping interface.
While it is normally good programming practice for
routines to always return deterministic results (same initial
values in memory), I think that in a performance-oriented
software component like the kernel, it's better programming practice
to have primitives that do no more than they need to, that run as
fast as possible, and behave consistently (no other remaining memory
allocators in linux-2.5 do this, right?).
Also as a general practice, I especially would like to
be paranoid about unnecessary memory copying or filling. I like
to grep for memcpy's and memset's and ask "is this call really
necessary?" Core CPU speed improvements have out pace memory bus
improvements. Today, a 2GHz CPU and with a 2GB/sec memory channel
(typical new computer) can only sustain clearing 1 byte per CPU
cycle (although much of that can accumulate in a write-behind
cache, but then you've just flushed a lot of your cache
unnecessarily, and that generates some memory traffic, etc.).
Plus, CPU's often execute more than one instruction per cycle,
so each byte might burn the time in which 1.4 instructions
could be executed, and other devices may want that memory
bandwidth too (I/O devices, another CPU, built-in video).
Maybe if you could point out an example of some
code that actually depends on pci_alloc_consistent return
zeroes, I be able to see what I missed and be able to
track down similar cases. There are plenty of drivers
that do pci_alloc_consistent and then memset. So, whichever
way the semantics of pci_alloc_consistent are defined, some
drivers ought to be modified.
Adam J. Richter __ ______________ 575 Oroville Road
adam@yggdrasil.com \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."
next reply other threads:[~2002-05-30 11:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-30 11:41 Adam J. Richter [this message]
2002-05-30 11:30 ` David S. Miller
2002-06-03 16:45 ` Pavel Machek
-- strict thread matches above, loose matches on Subject: below --
2002-05-30 9:11 Adam J. Richter
2002-05-30 9:49 ` David S. Miller
2002-05-30 11:05 ` Emmanuel Michon
2002-05-30 10:54 ` David S. Miller
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=200205301141.EAA15864@baldur.yggdrasil.com \
--to=adam@yggdrasil.com \
--cc=davem@redhat.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®