* [PATCH] Replace __get_free_page() + memset(0) with get_zeroed_page() calls.
@ 2007-01-03 13:51 Robert P. J. Day
2007-01-03 14:19 ` Jiri Slaby
0 siblings, 1 reply; 3+ messages in thread
From: Robert P. J. Day @ 2007-01-03 13:51 UTC (permalink / raw)
To: Linux kernel mailing list
Replace the small number of combinations of __get_free_page() plus a
call to memset(...,0,PAGE_SIZE) with a single call to
get_zeroed_page().
Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
---
all of the following simplifications *look* valid, but i'm happy to
be convinced otherwise.
arch/sparc/mm/sun4c.c | 4 +---
arch/sparc64/kernel/pci_iommu.c | 3 +--
drivers/s390/net/qeth_eddp.c | 3 +--
include/asm-m68k/sun3_pgalloc.h | 3 +--
include/asm-um/pgtable-3level.h | 5 +----
sound/oss/emu10k1/main.c | 3 +--
sound/oss/emu10k1/mixer.c | 3 +--
7 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index 436021c..ccb6d20 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -1946,9 +1946,7 @@ static pte_t *sun4c_pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add
if ((pte = sun4c_pte_alloc_one_fast(mm, address)) != NULL)
return pte;
- pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
- if (pte)
- memset(pte, 0, PAGE_SIZE);
+ pte = (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
return pte;
}
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index 2e7f142..c9c45cc 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -149,12 +149,11 @@ void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset,
/* Allocate and initialize the dummy page which we
* set inactive IO PTEs to point to.
*/
- iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0);
+ iommu->dummy_page = get_zeroed_page(GFP_KERNEL);
if (!iommu->dummy_page) {
prom_printf("PCI_IOMMU: Error, gfp(dummy_page) failed.\n");
prom_halt();
}
- memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
/* Now allocate and setup the IOMMU page table itself. */
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 6bb558a..68c06d0 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -558,14 +558,13 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
return NULL;
}
for (i = 0; i < ctx->num_pages; ++i){
- addr = (u8 *)__get_free_page(GFP_ATOMIC);
+ addr = (u8 *)get_zeroed_page(GFP_ATOMIC);
if (addr == NULL){
QETH_DBF_TEXT(trace, 2, "ceddpcn3");
ctx->num_pages = i;
qeth_eddp_free_context(ctx);
return NULL;
}
- memset(addr, 0, PAGE_SIZE);
ctx->pages[i] = addr;
}
ctx->elements = kcalloc(ctx->num_elements,
diff --git a/include/asm-m68k/sun3_pgalloc.h b/include/asm-m68k/sun3_pgalloc.h
index fd82411..b3932e5 100644
--- a/include/asm-m68k/sun3_pgalloc.h
+++ b/include/asm-m68k/sun3_pgalloc.h
@@ -36,12 +36,11 @@ static inline void pte_free(struct page *page)
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
unsigned long address)
{
- unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
+ unsigned long page = get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
if (!page)
return NULL;
- memset((void *)page, 0, PAGE_SIZE);
return (pte_t *) (page);
}
diff --git a/include/asm-um/pgtable-3level.h b/include/asm-um/pgtable-3level.h
index ca0c2a9..6f43b58 100644
--- a/include/asm-um/pgtable-3level.h
+++ b/include/asm-um/pgtable-3level.h
@@ -61,10 +61,7 @@ static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
{
- pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
-
- if(pmd)
- memset(pmd, 0, PAGE_SIZE);
+ pmd_t *pmd = (pmd_t *) get_zeroed_page(GFP_KERNEL);
return pmd;
}
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
index 6c59df7..c71976c 100644
--- a/sound/oss/emu10k1/main.c
+++ b/sound/oss/emu10k1/main.c
@@ -576,13 +576,12 @@ static int __devinit fx_init(struct emu10k1_card *card)
mgr->current_pages = (11 + PATCHES_PER_PAGE - 1) / PATCHES_PER_PAGE;
for (i = 0; i < mgr->current_pages; i++) {
- mgr->patch[i] = (void *)__get_free_page(GFP_KERNEL);
+ mgr->patch[i] = (void *)get_zeroed_page(GFP_KERNEL);
if (mgr->patch[i] == NULL) {
mgr->current_pages = i;
fx_cleanup(mgr);
return -ENOMEM;
}
- memset(mgr->patch[i], 0, PAGE_SIZE);
}
if (card->is_audigy) {
diff --git a/sound/oss/emu10k1/mixer.c b/sound/oss/emu10k1/mixer.c
index 6419796..53363a9 100644
--- a/sound/oss/emu10k1/mixer.c
+++ b/sound/oss/emu10k1/mixer.c
@@ -369,13 +369,12 @@ static int emu10k1_private_mixer(struct emu10k1_card *card, unsigned int cmd, un
if (page >= card->mgr.current_pages) {
for (i = card->mgr.current_pages; i < page + 1; i++) {
- card->mgr.patch[i] = (void *)__get_free_page(GFP_KERNEL);
+ card->mgr.patch[i] = (void *)get_zeroed_page(GFP_KERNEL);
if(card->mgr.patch[i] == NULL) {
card->mgr.current_pages = i;
ret = -ENOMEM;
break;
}
- memset(card->mgr.patch[i], 0, PAGE_SIZE);
}
card->mgr.current_pages = page + 1;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace __get_free_page() + memset(0) with get_zeroed_page() calls.
2007-01-03 13:51 [PATCH] Replace __get_free_page() + memset(0) with get_zeroed_page() calls Robert P. J. Day
@ 2007-01-03 14:19 ` Jiri Slaby
2007-01-03 14:55 ` Robert P. J. Day
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2007-01-03 14:19 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux kernel mailing list
Robert P. J. Day wrote:
> Replace the small number of combinations of __get_free_page() plus a
> call to memset(...,0,PAGE_SIZE) with a single call to
> get_zeroed_page().
>
> Signed-off-by: Robert P. J. Day <rpjday@mindspring.com>
>
> ---
>
> all of the following simplifications *look* valid, but i'm happy to
> be convinced otherwise.
>
>
> arch/sparc/mm/sun4c.c | 4 +---
> arch/sparc64/kernel/pci_iommu.c | 3 +--
> drivers/s390/net/qeth_eddp.c | 3 +--
> include/asm-m68k/sun3_pgalloc.h | 3 +--
> include/asm-um/pgtable-3level.h | 5 +----
> sound/oss/emu10k1/main.c | 3 +--
> sound/oss/emu10k1/mixer.c | 3 +--
> 7 files changed, 7 insertions(+), 17 deletions(-)
[...]
> index fd82411..b3932e5 100644
> --- a/include/asm-m68k/sun3_pgalloc.h
> +++ b/include/asm-m68k/sun3_pgalloc.h
> @@ -36,12 +36,11 @@ static inline void pte_free(struct page *page)
> static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
> unsigned long address)
> {
> - unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
> + unsigned long page = get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
>
> if (!page)
> return NULL;
>
> - memset((void *)page, 0, PAGE_SIZE);
> return (pte_t *) (page);
> }
perhaps simply
return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
> diff --git a/include/asm-um/pgtable-3level.h b/include/asm-um/pgtable-3level.h
> index ca0c2a9..6f43b58 100644
> --- a/include/asm-um/pgtable-3level.h
> +++ b/include/asm-um/pgtable-3level.h
> @@ -61,10 +61,7 @@ static inline void pgd_mkuptodate(pgd_t pgd) { pgd_val(pgd) &= ~_PAGE_NEWPAGE; }
>
> static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
> {
> - pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
> -
> - if(pmd)
> - memset(pmd, 0, PAGE_SIZE);
> + pmd_t *pmd = (pmd_t *) get_zeroed_page(GFP_KERNEL);
>
> return pmd;
> }
here too, but this is also good.
regards,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace __get_free_page() + memset(0) with get_zeroed_page() calls.
2007-01-03 14:19 ` Jiri Slaby
@ 2007-01-03 14:55 ` Robert P. J. Day
0 siblings, 0 replies; 3+ messages in thread
From: Robert P. J. Day @ 2007-01-03 14:55 UTC (permalink / raw)
To: Jiri Slaby; +Cc: Linux kernel mailing list
On Wed, 3 Jan 2007, Jiri Slaby wrote:
> Robert P. J. Day wrote:
> [...]
> > index fd82411..b3932e5 100644
> > --- a/include/asm-m68k/sun3_pgalloc.h
> > +++ b/include/asm-m68k/sun3_pgalloc.h
> > @@ -36,12 +36,11 @@ static inline void pte_free(struct page *page)
> > static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
> > unsigned long address)
> > {
> > - unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
> > + unsigned long page = get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
> >
> > if (!page)
> > return NULL;
> >
> > - memset((void *)page, 0, PAGE_SIZE);
> > return (pte_t *) (page);
> > }
>
> perhaps simply
> return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
i thought about it, but figured i'd keep the change minimal and not
get into any "editorializing."
rday
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-01-03 15:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-03 13:51 [PATCH] Replace __get_free_page() + memset(0) with get_zeroed_page() calls Robert P. J. Day
2007-01-03 14:19 ` Jiri Slaby
2007-01-03 14:55 ` Robert P. J. Day
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.