Re: replace "memset(...,0,PAGE_SIZE)" calls with "clear_page()"?



On Sat, 30 Dec 2006, Arjan van de Ven wrote:

rday wrote:

... most of the definitions of the clear_page() macro are simply
invocations of memset(). see for yourself:

*MOST*. Not all.

i did notice that. while the majority of the architectures simply
define clear_page() as a macro calling memset(ptr, 0, PAGE_SIZE), the
rest will implement it in assembler code for whatever reason. (i'm
assuming that *every* architecture *must* define clear_page() one way
or the other, is that correct? that would seem fairly obvious, but
i just want to make sure i'm not missing anything obvious.)

clear_page() is supposed to be for full real pages only... for
example it allows the architecture to optimize for alignment, cache
aliasing etc etc.

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);
...

my only point here is that, given that every architecture needs to
supply some kind of definition of a "clear_page()" routine, one would
think that *lots* of those memset() calls could reasonably be
rewritten as a clear_page() call for improved readibility, no?

and there are a *lot* of memset() calls like that.

rday
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • RE: generic strncpy - off-by-one error
    ... And here are some benchmarking numbers for the CRIS ... "Multi copy & fill" is the code above. ... Then whether using memset() or your filling is a win depends ... on the architecture and how many bytes needs to be filled. ...
    (Linux-Kernel)
  • Re: Duplication in events mechanisms in java?
    ... > No, they are not ok for non trivial event systems, because: ... architecture that is going to be based on them (or on the other kind ... So that means that regarding the main reason: Main reason: Observable ... by building my own infrastracture upon the observer/observabale ... ...
    (comp.lang.java.programmer)
  • Re: To CS or not to CS?
    ... Sorry, I was misleading there. ... > network strained for bandwidth? ... I had thought that it WAS a reason, ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Difference Between .com & .local
    ... Rick K typed: ... So it is part of a typical AD Architecture?? ... The reason I ask is I inherited a 2003SBS network that I performed a ...
    (microsoft.public.windows.server.networking)
  • Re: Preempt-RT patch for 2.6.25
    ... no reason to hamper forward development just to keep old architecture ... ports in the tree. ... that it's a bug. ... for no good reason. ...
    (Linux-Kernel)