Remove all the open-coded retry loops in various architectures, use
__GFP_REPEAT.

It could be that at some time in the future we change __GFP_REPEAT to give up
after ten seconds or so, so all the checks for failed allocations are
retained.



 arch/alpha/mm/init.c                |   12 +-----------
 arch/i386/mm/pgtable.c              |   32 ++++++++------------------------
 arch/ppc/mm/pgtable.c               |   30 +++++++++++-------------------
 arch/sparc/mm/sun4c.c               |    2 +-
 arch/um/kernel/mem.c                |   26 ++++++--------------------
 include/asm-arm/proc-armv/pgalloc.h |   20 ++------------------
 include/asm-cris/pgalloc.h          |    2 +-
 include/asm-ia64/pgalloc.h          |    4 ++--
 include/asm-m68k/motorola_pgalloc.h |    4 ++--
 include/asm-m68k/sun3_pgalloc.h     |    4 ++--
 include/asm-mips/pgalloc.h          |    2 +-
 include/asm-mips64/pgalloc.h        |    2 +-
 include/asm-parisc/pgalloc.h        |    4 ++--
 include/asm-ppc64/pgalloc.h         |   14 +++-----------
 include/asm-s390/pgalloc.h          |   17 +++++------------
 include/asm-sh/pgalloc.h            |    2 +-
 include/asm-x86_64/pgalloc.h        |    4 ++--
 17 files changed, 51 insertions(+), 130 deletions(-)

diff -puN arch/alpha/mm/init.c~pte_alloc_one-use-gfp_repeat arch/alpha/mm/init.c
--- 25/arch/alpha/mm/init.c~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/arch/alpha/mm/init.c	2003-04-14 19:11:35.000000000 -0700
@@ -66,19 +66,9 @@ pgd_alloc(struct mm_struct *mm)
 pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte;
-	long timeout = 10;
-
- retry:
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
-	else if (--timeout >= 0) {
-		current->state = TASK_UNINTERRUPTIBLE;
-		schedule_timeout(HZ);
-		goto retry;
-	}
-
 	return pte;
 }
 
diff -puN arch/i386/mm/pgtable.c~pte_alloc_one-use-gfp_repeat arch/i386/mm/pgtable.c
--- 25/arch/i386/mm/pgtable.c~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/arch/i386/mm/pgtable.c	2003-04-14 19:11:35.000000000 -0700
@@ -131,39 +131,23 @@ void __set_fixmap (enum fixed_addresses 
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
-	pte_t *pte;
-   
-   	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	struct page *pte;
-   
-   	do {
+
 #if CONFIG_HIGHPTE
-		pte = alloc_pages(GFP_KERNEL | __GFP_HIGHMEM, 0);
+	pte = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT, 0);
 #else
-		pte = alloc_pages(GFP_KERNEL, 0);
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 #endif
-		if (pte)
-			clear_highpage(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -puN arch/ppc/mm/pgtable.c~pte_alloc_one-use-gfp_repeat arch/ppc/mm/pgtable.c
--- 25/arch/ppc/mm/pgtable.c~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/arch/ppc/mm/pgtable.c	2003-04-14 19:11:35.000000000 -0700
@@ -76,15 +76,11 @@ pte_t *pte_alloc_one_kernel(struct mm_st
 	extern void *early_get_page(void);
 	int timeout = 0;
 
-	if (mem_init_done) {
-		while ((pte = (pte_t *) __get_free_page(GFP_KERNEL)) == NULL
-		       && ++timeout < 10) {
-			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_timeout(HZ);
-		}
-	} else
-		pte = (pte_t *) early_get_page();
-	if (pte != NULL)
+	if (mem_init_done)
+		pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	else
+		pte = (pte_t *)early_get_page();
+	if (pte)
 		clear_page(pte);
 	return pte;
 }
@@ -92,20 +88,16 @@ pte_t *pte_alloc_one_kernel(struct mm_st
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
 	struct page *pte;
-	int timeout = 0;
+
 #ifdef CONFIG_HIGHPTE
-	int flags = GFP_KERNEL | __GFP_HIGHMEM;
+	int flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT;
 #else
-	int flags = GFP_KERNEL;
+	int flags = GFP_KERNEL | __GFP_REPEAT;
 #endif
 
-	while ((pte = alloc_pages(flags, 0)) == NULL) {
-		if (++timeout >= 10)
-			return NULL;
-		set_current_state(TASK_UNINTERRUPTIBLE);
-		schedule_timeout(HZ);
-	}
-	clear_highpage(pte);
+	pte = alloc_pages(flags, 0);
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -puN arch/sparc/mm/sun4c.c~pte_alloc_one-use-gfp_repeat arch/sparc/mm/sun4c.c
--- 25/arch/sparc/mm/sun4c.c~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/arch/sparc/mm/sun4c.c	2003-04-14 19:11:35.000000000 -0700
@@ -1901,7 +1901,7 @@ static pte_t *sun4c_pte_alloc_one_kernel
 	if ((pte = sun4c_pte_alloc_one_fast(mm, address)) != NULL)
 		return pte;
 
-	pte = (pte_t *)__get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		memset(pte, 0, PAGE_SIZE);
 	return pte;
diff -puN arch/um/kernel/mem.c~pte_alloc_one-use-gfp_repeat arch/um/kernel/mem.c
--- 25/arch/um/kernel/mem.c~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/arch/um/kernel/mem.c	2003-04-14 19:11:35.000000000 -0700
@@ -810,35 +810,21 @@ void pgd_free(pgd_t *pgd)
 
 pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	pte_t *pte;
 
-   	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
 struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	int count = 0;
 	struct page *pte;
    
-   	do {
-		pte = alloc_pages(GFP_KERNEL, 0);
-		if (pte)
-			clear_highpage(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
+	if (pte)
+		clear_highpage(pte);
 	return pte;
 }
 
diff -puN include/asm-arm/proc-armv/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-arm/proc-armv/pgalloc.h
--- 25/include/asm-arm/proc-armv/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-arm/proc-armv/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -27,17 +27,9 @@
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	int count = 0;
 	pte_t *pte;
 
-	do {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL);
-		if (!pte) {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
-
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte) {
 		clear_page(pte);
 		clean_dcache_area(pte, sizeof(pte_t) * PTRS_PER_PTE);
@@ -51,16 +43,8 @@ static inline struct page *
 pte_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
 	struct page *pte;
-	int count = 0;
-
-	do {
-		pte = alloc_pages(GFP_KERNEL, 0);
-		if (!pte) {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
 
+	pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 	if (pte) {
 		void *page = page_address(pte);
 		clear_page(page);
diff -puN include/asm-cris/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-cris/pgalloc.h
--- 25/include/asm-cris/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-cris/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -62,7 +62,7 @@ static inline pte_t *pte_alloc_one(struc
 {
         pte_t *pte;
 
-        pte = (pte_t *) __get_free_page(GFP_KERNEL);
+        pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
         if (pte)
                 clear_page(pte);
         return pte;
diff -puN include/asm-ia64/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-ia64/pgalloc.h
--- 25/include/asm-ia64/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-ia64/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -125,7 +125,7 @@ pmd_populate_kernel (struct mm_struct *m
 static inline struct page *
 pte_alloc_one (struct mm_struct *mm, unsigned long addr)
 {
-	struct page *pte = alloc_pages(GFP_KERNEL, 0);
+	struct page *pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 
 	if (likely(pte != NULL))
 		clear_page(page_address(pte));
@@ -135,7 +135,7 @@ pte_alloc_one (struct mm_struct *mm, uns
 static inline pte_t *
 pte_alloc_one_kernel (struct mm_struct *mm, unsigned long addr)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (likely(pte != NULL))
 		clear_page(pte);
diff -puN include/asm-m68k/motorola_pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-m68k/motorola_pgalloc.h
--- 25/include/asm-m68k/motorola_pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-m68k/motorola_pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -11,7 +11,7 @@ static inline pte_t *pte_alloc_one_kerne
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte) {
 		clear_page(pte);
 		__flush_page_to_ram(pte);
@@ -30,7 +30,7 @@ static inline void pte_free_kernel(pte_t
 
 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	struct page *page = alloc_pages(GFP_KERNEL, 0);
+	struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 	pte_t *pte;
 
 	if(!page)
diff -puN include/asm-m68k/sun3_pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-m68k/sun3_pgalloc.h
--- 25/include/asm-m68k/sun3_pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-m68k/sun3_pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -39,7 +39,7 @@ static inline void __pte_free_tlb(struct
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 
 					  unsigned long address)
 {
-	unsigned long page = __get_free_page(GFP_KERNEL);
+	unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
 
 	if (!page)
 		return NULL;
@@ -51,7 +51,7 @@ static inline pte_t *pte_alloc_one_kerne
 static inline struct page *pte_alloc_one(struct mm_struct *mm, 
 					 unsigned long address)
 {
-        struct page *page = alloc_pages(GFP_KERNEL, 0);
+        struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
 
 	if (page == NULL)
 		return NULL;
diff -puN include/asm-mips64/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-mips64/pgalloc.h
--- 25/include/asm-mips64/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-mips64/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -93,7 +93,7 @@ static inline pte_t *pte_alloc_one(struc
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
diff -puN include/asm-mips/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-mips/pgalloc.h
--- 25/include/asm-mips/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-mips/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -132,7 +132,7 @@ static inline pte_t *pte_alloc_one(struc
 {
 	pte_t *pte;
 
-	pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte = (pte_t *) __get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
diff -puN include/asm-parisc/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-parisc/pgalloc.h
--- 25/include/asm-parisc/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-parisc/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -73,7 +73,7 @@ pmd_populate_kernel(struct mm_struct *mm
 static inline struct page *
 pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	struct page *page = alloc_page(GFP_KERNEL);
+	struct page *page = alloc_page(GFP_KERNEL|__GFP_REPEAT);
 	if (likely(page != NULL))
 		clear_page(page_address(page));
 	return page;
@@ -82,7 +82,7 @@ pte_alloc_one(struct mm_struct *mm, unsi
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (likely(pte != NULL))
 		clear_page(pte);
 	return pte;
diff -puN include/asm-ppc64/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-ppc64/pgalloc.h
--- 25/include/asm-ppc64/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-ppc64/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -62,19 +62,11 @@ pmd_free(pmd_t *pmd)
 static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr)
 {
-	int count = 0;
 	pte_t *pte;
 
-	do {
-		pte = (pte_t *)__get_free_page(GFP_KERNEL);
-		if (pte)
-			clear_page(pte);
-		else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
-
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte)
+		clear_page(pte);
 	return pte;
 }
 
diff -puN include/asm-s390/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-s390/pgalloc.h
--- 25/include/asm-s390/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:34.000000000 -0700
+++ 25-akpm/include/asm-s390/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -120,20 +120,13 @@ static inline pte_t *
 pte_alloc_one_kernel(struct mm_struct *mm, unsigned long vmaddr)
 {
 	pte_t *pte;
-	int count;
         int i;
 
-	count = 0;
-	do {
-		pte = (pte_t *) __get_free_page(GFP_KERNEL);
-		if (pte != NULL) {
-			for (i=0; i < PTRS_PER_PTE; i++)
-				pte_clear(pte+i);
-		} else {
-			current->state = TASK_UNINTERRUPTIBLE;
-			schedule_timeout(HZ);
-		}
-	} while (!pte && (count++ < 10));
+	pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
+	if (pte != NULL) {
+		for (i=0; i < PTRS_PER_PTE; i++)
+			pte_clear(pte+i);
+	}
 	return pte;
 }
 
diff -puN include/asm-sh/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-sh/pgalloc.h
--- 25/include/asm-sh/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:35.000000000 -0700
+++ 25-akpm/include/asm-sh/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -35,7 +35,7 @@ static inline void pgd_free(pgd_t *pgd)
 
 static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pte_t *pte = (pte_t *) __get_free_page(GFP_KERNEL);
+	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
 	if (pte)
 		clear_page(pte);
 	return pte;
diff -puN include/asm-x86_64/pgalloc.h~pte_alloc_one-use-gfp_repeat include/asm-x86_64/pgalloc.h
--- 25/include/asm-x86_64/pgalloc.h~pte_alloc_one-use-gfp_repeat	2003-04-14 19:11:35.000000000 -0700
+++ 25-akpm/include/asm-x86_64/pgalloc.h	2003-04-14 19:11:35.000000000 -0700
@@ -48,12 +48,12 @@ static inline void pgd_free (pgd_t *pgd)
 
 static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
 {
-	return (pte_t *) get_zeroed_page(GFP_KERNEL);
+	return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 }
 
 static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	void *p = (void *)get_zeroed_page(GFP_KERNEL); 
+	void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
 	if (!p)
 		return NULL;
 	return virt_to_page(p);

_