Skip to content

Commit 32d6bd9

Browse files
Michal Hockotorvalds
authored andcommitted
tree wide: get rid of __GFP_REPEAT for order-0 allocations part I
This is the third version of the patchset previously sent [1]. I have basically only rebased it on top of 4.7-rc1 tree and dropped "dm: get rid of superfluous gfp flags" which went through dm tree. I am sending it now because it is tree wide and chances for conflicts are reduced considerably when we want to target rc2. I plan to send the next step and rename the flag and move to a better semantic later during this release cycle so we will have a new semantic ready for 4.8 merge window hopefully. Motivation: While working on something unrelated I've checked the current usage of __GFP_REPEAT in the tree. It seems that a majority of the usage is and always has been bogus because __GFP_REPEAT has always been about costly high order allocations while we are using it for order-0 or very small orders very often. It seems that a big pile of them is just a copy&paste when a code has been adopted from one arch to another. I think it makes some sense to get rid of them because they are just making the semantic more unclear. Please note that GFP_REPEAT is documented as * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt * _might_ fail. This depends upon the particular VM implementation. while !costly requests have basically nofail semantic. So one could reasonably expect that order-0 request with __GFP_REPEAT will not loop for ever. This is not implemented right now though. I would like to move on with __GFP_REPEAT and define a better semantic for it. $ git grep __GFP_REPEAT origin/master | wc -l 111 $ git grep __GFP_REPEAT | wc -l 36 So we are down to the third after this patch series. The remaining places really seem to be relying on __GFP_REPEAT due to large allocation requests. This still needs some double checking which I will do later after all the simple ones are sorted out. I am touching a lot of arch specific code here and I hope I got it right but as a matter of fact I even didn't compile test for some archs as I do not have cross compiler for them. Patches should be quite trivial to review for stupid compile mistakes though. The tricky parts are usually hidden by macro definitions and thats where I would appreciate help from arch maintainers. [1] http://lkml.kernel.org/r/1461849846-27209-1-git-send-email-mhocko@kernel.org This patch (of 19): __GFP_REPEAT has a rather weak semantic but since it has been introduced around 2.6.12 it has been ignored for low order allocations. Yet we have the full kernel tree with its usage for apparently order-0 allocations. This is really confusing because __GFP_REPEAT is explicitly documented to allow allocation failures which is a weaker semantic than the current order-0 has (basically nofail). Let's simply drop __GFP_REPEAT from those places. This would allow to identify place which really need allocator to retry harder and formulate a more specific semantic for what the flag is supposed to do actually. Link: http://lkml.kernel.org/r/1464599699-30131-2-git-send-email-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: Andy Lutomirski <luto@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chen Liqin <liqin.linux@gmail.com> Cc: Chris Metcalf <cmetcalf@mellanox.com> [for tile] Cc: Guan Xuetao <gxt@mprc.pku.edu.cn> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: John Crispin <blogic@openwrt.org> Cc: Lennox Wu <lennox.wu@gmail.com> Cc: Ley Foon Tan <lftan@altera.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Fleming <matt@codeblueprint.co.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@arm.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b9b4bb2 commit 32d6bd9

27 files changed

Lines changed: 47 additions & 52 deletions

File tree

‎arch/alpha/include/asm/pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pgd_free(struct mm_struct *mm, pgd_t *pgd)
4040
static inline pmd_t *
4141
pmd_alloc_one(struct mm_struct *mm, unsigned long address)
4242
{
43-
pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
43+
pmd_t *ret = (pmd_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
4444
return ret;
4545
}
4646

@@ -53,7 +53,7 @@ pmd_free(struct mm_struct *mm, pmd_t *pmd)
5353
static inline pte_t *
5454
pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
5555
{
56-
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
56+
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
5757
return pte;
5858
}
5959

‎arch/arm/include/asm/pgalloc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
3131
{
32-
return (pmd_t *)get_zeroed_page(GFP_KERNEL | __GFP_REPEAT);
32+
return (pmd_t *)get_zeroed_page(GFP_KERNEL);
3333
}
3434

3535
static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)

‎arch/avr32/include/asm/pgalloc.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static inline void pgd_ctor(void *x)
4343
*/
4444
static inline pgd_t *pgd_alloc(struct mm_struct *mm)
4545
{
46-
return quicklist_alloc(QUICK_PGD, GFP_KERNEL | __GFP_REPEAT, pgd_ctor);
46+
return quicklist_alloc(QUICK_PGD, GFP_KERNEL, pgd_ctor);
4747
}
4848

4949
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
@@ -54,7 +54,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
5454
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
5555
unsigned long address)
5656
{
57-
return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
57+
return quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL);
5858
}
5959

6060
static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
@@ -63,7 +63,7 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
6363
struct page *page;
6464
void *pg;
6565

66-
pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL);
66+
pg = quicklist_alloc(QUICK_PT, GFP_KERNEL, NULL);
6767
if (!pg)
6868
return NULL;
6969

‎arch/cris/include/asm/pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
2424

2525
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
2626
{
27-
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
27+
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
2828
return pte;
2929
}
3030

3131
static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
3232
{
3333
struct page *pte;
34-
pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
34+
pte = alloc_pages(GFP_KERNEL|__GFP_ZERO, 0);
3535
if (!pte)
3636
return NULL;
3737
if (!pgtable_page_ctor(pte)) {

‎arch/frv/mm/pgalloc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE)));
2222

2323
pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
2424
{
25-
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
25+
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL);
2626
if (pte)
2727
clear_page(pte);
2828
return pte;
@@ -33,9 +33,9 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
3333
struct page *page;
3434

3535
#ifdef CONFIG_HIGHPTE
36-
page = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM|__GFP_REPEAT, 0);
36+
page = alloc_pages(GFP_KERNEL|__GFP_HIGHMEM, 0);
3737
#else
38-
page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
38+
page = alloc_pages(GFP_KERNEL, 0);
3939
#endif
4040
if (!page)
4141
return NULL;

‎arch/hexagon/include/asm/pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
6464
{
6565
struct page *pte;
6666

67-
pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
67+
pte = alloc_page(GFP_KERNEL | __GFP_ZERO);
6868
if (!pte)
6969
return NULL;
7070
if (!pgtable_page_ctor(pte)) {
@@ -78,7 +78,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
7878
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
7979
unsigned long address)
8080
{
81-
gfp_t flags = GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO;
81+
gfp_t flags = GFP_KERNEL | __GFP_ZERO;
8282
return (pte_t *) __get_free_page(flags);
8383
}
8484

‎arch/m68k/include/asm/mcf_pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern const char bad_pmd_string[];
1414
extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
1515
unsigned long address)
1616
{
17-
unsigned long page = __get_free_page(GFP_DMA|__GFP_REPEAT);
17+
unsigned long page = __get_free_page(GFP_DMA);
1818

1919
if (!page)
2020
return NULL;
@@ -51,7 +51,7 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page,
5151
static inline struct page *pte_alloc_one(struct mm_struct *mm,
5252
unsigned long address)
5353
{
54-
struct page *page = alloc_pages(GFP_DMA|__GFP_REPEAT, 0);
54+
struct page *page = alloc_pages(GFP_DMA, 0);
5555
pte_t *pte;
5656

5757
if (!page)

‎arch/m68k/include/asm/motorola_pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long ad
1111
{
1212
pte_t *pte;
1313

14-
pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
14+
pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
1515
if (pte) {
1616
__flush_page_to_ram(pte);
1717
flush_tlb_kernel_page(pte);
@@ -32,7 +32,7 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addres
3232
struct page *page;
3333
pte_t *pte;
3434

35-
page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
35+
page = alloc_pages(GFP_KERNEL|__GFP_ZERO, 0);
3636
if(!page)
3737
return NULL;
3838
if (!pgtable_page_ctor(page)) {

‎arch/m68k/include/asm/sun3_pgalloc.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ do { \
3737
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
3838
unsigned long address)
3939
{
40-
unsigned long page = __get_free_page(GFP_KERNEL|__GFP_REPEAT);
40+
unsigned long page = __get_free_page(GFP_KERNEL);
4141

4242
if (!page)
4343
return NULL;
@@ -49,7 +49,7 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
4949
static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
5050
unsigned long address)
5151
{
52-
struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0);
52+
struct page *page = alloc_pages(GFP_KERNEL, 0);
5353

5454
if (page == NULL)
5555
return NULL;

‎arch/metag/include/asm/pgalloc.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
4242
static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
4343
unsigned long address)
4444
{
45-
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT |
46-
__GFP_ZERO);
45+
pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
4746
return pte;
4847
}
4948

5049
static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
5150
unsigned long address)
5251
{
5352
struct page *pte;
54-
pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO, 0);
53+
pte = alloc_pages(GFP_KERNEL | __GFP_ZERO, 0);
5554
if (!pte)
5655
return NULL;
5756
if (!pgtable_page_ctor(pte)) {

0 commit comments

Comments
 (0)