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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 31 Dec 2006, Arjan van de Ven wrote:

> So... yes I fully agree with you that it's worth looking at the
> memset( , PAGE_SIZE) users. If they are page aligned, yes absolutely
> make it a clear_page(), I think that's a very good idea. However
> also please check if they've been very recently allocated in that
> code, and if maybe the zeroing allocators are better suited there..
> (or maybe there's even double zeroing going on.. that's be a nice
> gain)

  there's certainly some cleanup/speedup that could be done regarding
these numerous "memset(...,0,PAGE_SIZE) calls.

  first, there the obvious 1:1 replacement with a call to
"clear_page()" ***if that's appropriate***.

  second, there's some possible simplification, given snippets like
this one from arch/sparc/mm/sun4c.c

	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
        if (pte)
                memset(pte, 0, PAGE_SIZE);

which seems to be an obvious candidate for replacement with:

	pte = get_zeroed_page(GFP_KERNEL|__GFP_REPEAT)

no?

  finally, there is certainly some "double zeroing" going on, as with
this snippet from drivers/atm/eni.c:

	...
	eni_dev->rx_map = (struct atm_vcc **) get_zeroed_page(GFP_KERNEL);
                                              ^^^^^^^^^^^^^^^
        if (!eni_dev->rx_map) {
                printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n",
                    dev->number);
                free_page((unsigned long) eni_dev->free_list);
                return -ENOMEM;
        }
        memset(eni_dev->rx_map,0,PAGE_SIZE);	// redundant, no?
	...

  so, yes, there does appear to be room for cleanup/speedup.

rday


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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux