mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@mindspring.com>
To: Paul Mundt <lethal@linux-sh.org>
Cc: Arjan van de Ven <arjan@infradead.org>,
	Denis Vlasenko <vda.linux@googlemail.com>,
	Linux kernel mailing list <linux-kernel@vger.kernel.org>
Subject: Re: replace "memset(...,0,PAGE_SIZE)" calls with "clear_page()"?
Date: Sun, 31 Dec 2006 14:04:16 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0612311355520.17978@localhost.localdomain> (raw)
In-Reply-To: <20061231183949.GA8323@linux-sh.org>

On Mon, 1 Jan 2007, Paul Mundt wrote:

> On Sat, Dec 30, 2006 at 06:04:14PM -0500, Robert P. J. Day wrote:
> > fair enough.  *technically*, not every call of the form
> > "memset(ptr,0,PAGE_SIZE)" necessarily represents an address that's on
> > a page boundary.  but, *realistically*, i'm guessing most of them do.
> > just grabbing a random example from some grep output:
> >
> > arch/sh/mm/init.c:
> >   ...
> >   /* clear the zero-page */
> >   memset(empty_zero_page, 0, PAGE_SIZE);
> >   ...
> >
> The problem with random grepping is that it doesn't give you any
> context. clear_page() isn't available in this case since we have a
> couple of different ways of implementing it, and the optimal
> approach is selected later on. There are also additional assumptions
> regarding alignment that don't allow clear_page() to be used
> directly as replacement for the memset() callsites (as has already
> been pointed out for some of the other architectures). While the
> empty_zero_page in this case sits on a full page boundary, others do
> not.
>
> You might find some places in drivers that do this where you might
> be able to optimize things slightly with a clear_page() (or
> copy_page() in the memcpy() case), but it's going to need a lot of
> manual auditing rather than a find and replace. Any sort of wins you
> get out of this would be marginal at best, anyways.
>
> The more interesting case would be page clustering/bulk page
> clearing with offload engines, and there's certainly room to build
> on the SGI patches for this.

your point is well taken -- i wasn't trying to suggest that a blind
cut-and-replace would be appropriate, only that there were an awful
lot of places where it wasn't clear that that kind of replacement
*wasn't* appropriate.  or perhaps even recommended.  (doing that kind
of search in the drivers/ directory would perhaps be more meaningful
than in the arch/ directory.  just my luck i picked a bad example.)

clearly, that kind of replacement might require manual intervention in
a lot of cases, no question.  as with other examples i've brought up
here, i'm just looking at this from a relatively newbie perspective,
where i'm perusing the code and, in this case, got to thinking, "gee,
given that every architecture defines a clear_page() macro, i wonder
why all these people keep calling memset()."  that's all.

kind of like how, given that include/linux/gfp.h defines the macro
__get_dma_pages(), so many people persist in calling
__get_free_pages() with a GFP_DMA setting.  that sort of thing.  :-)

rday

  reply	other threads:[~2006-12-31 19:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-29  6:16 Robert P. J. Day
2006-12-30 20:49 ` Denis Vlasenko
2006-12-30 22:08   ` Robert P. J. Day
2006-12-30 22:40     ` Denis Vlasenko
2007-01-03  6:23       ` dean gaudet
2006-12-30 22:45     ` Arjan van de Ven
2006-12-30 23:04       ` Robert P. J. Day
2006-12-31 18:39         ` Paul Mundt
2006-12-31 19:04           ` Robert P. J. Day [this message]
2007-01-01  1:59             ` Folkert van Heusden
2007-01-01  8:33               ` Robert P. J. Day
2007-01-01 10:14                 ` Arjan van de Ven
2007-01-01 10:27                   ` Robert P. J. Day
2007-01-01 19:05                     ` Dave Jones
2007-01-01  8:42               ` Paul Mundt
2007-01-01 17:09                 ` Randy Dunlap
2006-12-31 13:39       ` Folkert van Heusden
2006-12-31 13:45         ` Arjan van de Ven
2006-12-31 16:39           ` Robert P. J. Day
2006-12-31 17:43             ` Arjan van de Ven
2007-01-03 13:20               ` Robert P. J. Day

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=Pine.LNX.4.64.0612311355520.17978@localhost.localdomain \
    --to=rpjday@mindspring.com \
    --cc=arjan@infradead.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda.linux@googlemail.com \
    /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®