propagate gfp_t to page table alloc functions
Subsystems (9)
RFC 1/1 propagate gfp_t to page table alloc functions
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is __vmalloc calls map_vm_area which calls pud/pmd_alloc without gfp_t. so although we call __vmalloc with GFP_ATOMIC or GFP_NOIO, it ends up allocating pages with GFP_KERNEL. The should be a BUG. This patch fixes it by passing gfp_to to low page table allocate functions.
---
NOTE!
This isn't perfect patch but I send this patch which only works for x86 to listen opinion from others. If it's best, I will fix other architectures and resend it. Maybe the patch would become a all-in-one patch which changes all architectures all at once. If you have better idea not to break bisectability, please advise me.
arch/x86/include/asm/pgalloc.h | 15 ++++++---- arch/x86/kernel/tboot.c | 4 +-- arch/x86/mm/hugetlbpage.c | 4 +-- arch/x86/mm/pgtable.c | 8 +++-- include/asm-generic/4level-fixup.h | 7 +++-- include/asm-generic/pgtable-nopmd.h | 2 +- include/asm-generic/pgtable-nopud.h | 2 +- include/linux/mm.h | 29 +++++++++++------- lib/ioremap.c | 6 ++-- mm/memory.c | 36 ++++++++++++----------- mm/mremap.c | 4 +-- mm/vmalloc.c | 55 +++++++++++++++++++++++++---------- 12 files changed, 106 insertions(+), 66 deletions(-)
arch/x86/include/asm/pgalloc.h +10 -5
@@ -33,7 +33,8 @@ extern gfp_t __userpte_alloc_gfp;extern pgd_t *pgd_alloc (struct mm_struct *);extern void pgd_free (struct mm_struct *mm,pgd_t *pgd); -extern pte_t *pte_alloc_one_kernel (struct mm_struct *,unsigned long ); +extern pte_t *pte_alloc_one_kernel (struct mm_struct *, +unsigned long ,gfp_t );extern pgtable_t pte_alloc_one (struct mm_struct *,unsigned long );/* Should really implement gc for free page table pages. This could be
@@ -78,9 +79,11 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,#define pmd_pgtable (pmd) pmd_page(pmd)#if PAGETABLE_LEVELS >2 -static inline pmd_t *pmd_alloc_one (struct mm_struct *mm,unsigned long addr) +static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, +unsigned long addr,gfp_t gfp_mask) { -return (pmd_t *)get_zeroed_page (GFP_KERNEL |__GFP_REPEAT); +return (pmd_t *)get_zeroed_page (__GFP_REPEAT | + (gfp_mask & ~__GFP_HIGHMEM)); }static inline void pmd_free (struct mm_struct *mm,pmd_t *pmd)
@@ -114,9 +117,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)set_pgd (pgd,__pgd (_PAGE_TABLE |__pa (pud))); } -static inline pud_t *pud_alloc_one (struct mm_struct *mm,unsigned long addr) +static inline pud_t *pud_alloc_one (struct mm_struct *mm, +unsigned long addr,gfp_t gfp_mask) { -return (pud_t *)get_zeroed_page (GFP_KERNEL |__GFP_REPEAT); +return (pud_t *)get_zeroed_page (__GFP_REPEAT | + (gfp_mask & ~__GFP_HIGHMEM)); }static inline void pud_free (struct mm_struct *mm,pud_t *pud)
arch/x86/kernel/tboot.c +2 -2
@@ -128,10 +128,10 @@ static int map_tboot_page(unsigned long vaddr, unsigned long pfn,pte_t *pte; pgd =pgd_offset (&tboot_mm, vaddr); - pud =pud_alloc (&tboot_mm, pgd, vaddr); + pud =pud_alloc (&tboot_mm, pgd, vaddr,GFP_KERNEL );if (!pud)return -1 ; - pmd =pmd_alloc (&tboot_mm, pud, vaddr); + pmd =pmd_alloc (&tboot_mm, pud, vaddr,GFP_KERNEL );if (!pmd)return -1 ; pte =pte_alloc_map (&tboot_mm,NULL , pmd, vaddr);
arch/x86/mm/hugetlbpage.c +2 -2
@@ -135,7 +135,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,pte_t *pte =NULL ; pgd =pgd_offset (mm, addr); - pud =pud_alloc (mm, pgd, addr); + pud =pud_alloc (mm, pgd, addr,GFP_KERNEL );if (pud) {if (sz ==PUD_SIZE ) { pte = (pte_t *)pud;
@@ -143,7 +143,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,BUG_ON (sz !=PMD_SIZE );if (pud_none (*pud))huge_pmd_share (mm, addr, pud); - pte = (pte_t *)pmd_alloc (mm, pud, addr); + pte = (pte_t *)pmd_alloc (mm, pud, addr,GFP_KERNEL ); } }BUG_ON (pte && !pte_none (*pte) && !pte_huge (*pte));
arch/x86/mm/pgtable.c +5 -3
@@ -5,7 +5,7 @@#include <asm/tlb.h> #include <asm/fixmap.h> -#define PGALLOC_GFP GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO +#define PGALLOC_GFP (GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO)#ifdef CONFIG_HIGHPTE #define PGALLOC_USER_GFP __GFP_HIGHMEM
@@ -15,9 +15,11 @@gfp_t __userpte_alloc_gfp =PGALLOC_GFP |PGALLOC_USER_GFP ; -pte_t *pte_alloc_one_kernel (struct mm_struct *mm,unsigned long address) +pte_t *pte_alloc_one_kernel (struct mm_struct *mm, +unsigned long address,gfp_t gfp_mask) { -return (pte_t *)__get_free_page (PGALLOC_GFP ); +return (pte_t *)__get_free_page (PGALLOC_GFP & ~GFP_KERNEL | + (gfp_mask & ~__GFP_HIGHMEM)); }pgtable_t pte_alloc_one (struct mm_struct *mm,unsigned long address)
include/asm-generic/4level-fixup.h +4 -3
@@ -10,11 +10,12 @@#define pud_t pgd_t -#define pmd_alloc (mm, pud, address) \ - ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \ +#define pmd_alloc (mm, pud, address, gfp_mask) \ + ((unlikely(pgd_none(*(pud))) && \ + __pmd_alloc(mm, pud, address, gfp_mask))? \ NULL: pmd_offset(pud, address)) -#define pud_alloc (mm, pgd, address) (pgd) +#define pud_alloc (mm, pgd, address, gfp_mask) (pgd)#define pud_offset (pgd, start) (pgd)#define pud_none (pud) 0#define pud_bad (pud) 0
include/asm-generic/pgtable-nopmd.h +1 -1
@@ -55,7 +55,7 @@ static inline pmd_t * pmd_offset(pud_t * pud, unsigned long address)* allocating and freeing a pmd is trivial: the 1-entry pmd is * inside the pud, so has no extra memory associated with it. */ -#define pmd_alloc_one (mm, address) NULL +#define pmd_alloc_one (mm, address, gfp_mask) NULLstatic inline void pmd_free (struct mm_struct *mm,pmd_t *pmd) { }
include/asm-generic/pgtable-nopud.h +1 -1
@@ -50,7 +50,7 @@ static inline pud_t * pud_offset(pgd_t * pgd, unsigned long address)* allocating and freeing a pud is trivial: the 1-entry pud is * inside the pgd, so has no extra memory associated with it. */ -#define pud_alloc_one (mm, address) NULL +#define pud_alloc_one (mm, address, gfp_mask) NULL#define pud_free (mm, x) do { } while (0)#define __pud_free_tlb (tlb, x, a) do { } while (0)
include/linux/mm.h +18 -11
@@ -1153,42 +1153,48 @@ static inline pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,#ifdef __PAGETABLE_PUD_FOLDEDstatic inline int __pud_alloc (struct mm_struct *mm,pgd_t *pgd, -unsigned long address) +unsigned long address,gfp_t gfp_mask) {return 0 ; }#else -int __pud_alloc (struct mm_struct *mm,pgd_t *pgd,unsigned long address); +int __pud_alloc (struct mm_struct *mm,pgd_t *pgd, +unsigned long address,gfp_t gfp_mask);#endif #ifdef __PAGETABLE_PMD_FOLDEDstatic inline int __pmd_alloc (struct mm_struct *mm,pud_t *pud, -unsigned long address) +unsigned long address,gfp_t gfp_mask) {return 0 ; }#else -int __pmd_alloc (struct mm_struct *mm,pud_t *pud,unsigned long address); +int __pmd_alloc (struct mm_struct *mm,pud_t *pud, +unsigned long address,gfp_t gfp_mask);#endif int __pte_alloc (struct mm_struct *mm,struct vm_area_struct *vma,pmd_t *pmd,unsigned long address); -int __pte_alloc_kernel (pmd_t *pmd,unsigned long address); +int __pte_alloc_kernel (pmd_t *pmd,unsigned long address,gfp_t gfp_mask);/* * The following ifdef needed to get the 4level-fixup.h header to work. * Remove it when 4level-fixup.h has been removed. */ #if defined(CONFIG_MMU ) && !defined(__ARCH_HAS_4LEVEL_HACK) -static inline pud_t *pud_alloc (struct mm_struct *mm,pgd_t *pgd,unsigned long address) +static inline pud_t *pud_alloc (struct mm_struct *mm,pgd_t *pgd, +unsigned long address,gfp_t gfp_mask) { -return (unlikely (pgd_none (*pgd)) &&__pud_alloc (mm, pgd, address))? +return (unlikely (pgd_none (*pgd)) && +__pud_alloc (mm, pgd, address, gfp_mask))?NULL :pud_offset (pgd, address); } -static inline pmd_t *pmd_alloc (struct mm_struct *mm,pud_t *pud,unsigned long address) +static inline pmd_t *pmd_alloc (struct mm_struct *mm,pud_t *pud, +unsigned long address,gfp_t gfp_mask) { -return (unlikely (pud_none (*pud)) &&__pmd_alloc (mm, pud, address))? +return (unlikely (pud_none (*pud)) && +__pmd_alloc (mm, pud, address, gfp_mask))?NULL :pmd_offset (pud, address); }#endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
@@ -1251,8 +1257,9 @@ static inline void pgtable_page_dtor(struct page *page) pmd, address))? \ NULL: pte_offset_map_lock(mm, pmd, address, ptlp)) -#define pte_alloc_kernel (pmd, address) \ - ((unlikely(pmd_none(*(pmd))) && __pte_alloc_kernel(pmd, address))? \ +#define pte_alloc_kernel (pmd, address, gfp_mask) \ + ((unlikely(pmd_none(*(pmd))) && \ + __pte_alloc_kernel(pmd, address, gfp_mask))? \ NULL: pte_offset_kernel(pmd, address))extern void free_area_init (unsigned long * zones_size);
lib/ioremap.c +3 -3
@@ -20,7 +20,7 @@ static int ioremap_pte_range(pmd_t *pmd, unsigned long addr,u64 pfn; pfn = phys_addr >>PAGE_SHIFT ; - pte =pte_alloc_kernel (pmd, addr); + pte =pte_alloc_kernel (pmd, addr,GFP_KERNEL );if (!pte)return -ENOMEM ; do {
@@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,unsigned long next; phys_addr -= addr; - pmd =pmd_alloc (&init_mm, pud, addr); + pmd =pmd_alloc (&init_mm, pud, addr,GFP_KERNEL );if (!pmd)return -ENOMEM ; do {
@@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,unsigned long next; phys_addr -= addr; - pud =pud_alloc (&init_mm, pgd, addr); + pud =pud_alloc (&init_mm, pgd, addr,GFP_KERNEL );if (!pud)return -ENOMEM ; do {
mm/memory.c +19 -17
@@ -608,9 +608,9 @@ int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,return 0 ; } -int __pte_alloc_kernel (pmd_t *pmd,unsigned long address) +int __pte_alloc_kernel (pmd_t *pmd,unsigned long address,gfp_t gfp_mask) { -pte_t *new =pte_alloc_one_kernel (&init_mm, address); +pte_t *new =pte_alloc_one_kernel (&init_mm, address, gfp_mask);if (!new)return -ENOMEM ;
@@ -980,7 +980,7 @@ static inline int copy_pmd_range(struct mm_struct *dst_mm, struct mm_struct *srcpmd_t *src_pmd, *dst_pmd;unsigned long next; - dst_pmd =pmd_alloc (dst_mm, dst_pud, addr); + dst_pmd =pmd_alloc (dst_mm, dst_pud, addr,GFP_KERNEL );if (!dst_pmd)return -ENOMEM ; src_pmd =pmd_offset (src_pud, addr);
@@ -1013,7 +1013,7 @@ static inline int copy_pud_range(struct mm_struct *dst_mm, struct mm_struct *srcpud_t *src_pud, *dst_pud;unsigned long next; - dst_pud =pud_alloc (dst_mm, dst_pgd, addr); + dst_pud =pud_alloc (dst_mm, dst_pgd, addr,GFP_KERNEL );if (!dst_pud)return -ENOMEM ; src_pud =pud_offset (src_pgd, addr);
@@ -1997,9 +1997,9 @@ pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl) {pgd_t * pgd =pgd_offset (mm, addr); -pud_t * pud =pud_alloc (mm, pgd, addr); +pud_t * pud =pud_alloc (mm, pgd, addr,GFP_KERNEL );if (pud) { -pmd_t * pmd =pmd_alloc (mm, pud, addr); +pmd_t * pmd =pmd_alloc (mm, pud, addr,GFP_KERNEL );if (pmd) {VM_BUG_ON (pmd_trans_huge (*pmd));return pte_alloc_map_lock (mm, pmd, addr, ptl);
@@ -2219,7 +2219,7 @@ static inline int remap_pmd_range(struct mm_struct *mm, pud_t *pud,unsigned long next; pfn -= addr >>PAGE_SHIFT ; - pmd =pmd_alloc (mm, pud, addr); + pmd =pmd_alloc (mm, pud, addr,GFP_KERNEL );if (!pmd)return -ENOMEM ;VM_BUG_ON (pmd_trans_huge (*pmd));
@@ -2240,7 +2240,7 @@ static inline int remap_pud_range(struct mm_struct *mm, pgd_t *pgd,unsigned long next; pfn -= addr >>PAGE_SHIFT ; - pud =pud_alloc (mm, pgd, addr); + pud =pud_alloc (mm, pgd, addr,GFP_KERNEL );if (!pud)return -ENOMEM ; do {
@@ -2337,7 +2337,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,spinlock_t *uninitialized_var (ptl ); pte = (mm == &init_mm) ? -pte_alloc_kernel (pmd, addr) : +pte_alloc_kernel (pmd, addr,GFP_KERNEL ) :pte_alloc_map_lock (mm, pmd, addr, &ptl);if (!pte)return -ENOMEM ;
@@ -2371,7 +2371,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,BUG_ON (pud_huge (*pud)); - pmd =pmd_alloc (mm, pud, addr); + pmd =pmd_alloc (mm, pud, addr,GFP_KERNEL );if (!pmd)return -ENOMEM ; do {
@@ -2391,7 +2391,7 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,unsigned long next;int err; - pud =pud_alloc (mm, pgd, addr); + pud =pud_alloc (mm, pgd, addr,GFP_KERNEL );if (!pud)return -ENOMEM ; do {
@@ -3493,10 +3493,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,return hugetlb_fault (mm, vma, address, flags); pgd =pgd_offset (mm, address); - pud =pud_alloc (mm, pgd, address); + pud =pud_alloc (mm, pgd, address,GFP_KERNEL );if (!pud)return VM_FAULT_OOM ; - pmd =pmd_alloc (mm, pud, address); + pmd =pmd_alloc (mm, pud, address,GFP_KERNEL );if (!pmd)return VM_FAULT_OOM ;if (pmd_none (*pmd) &&transparent_hugepage_enabled (vma)) {
@@ -3542,9 +3542,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,* Allocate page upper directory. * We've already handled the fast-path in-line. */ -int __pud_alloc (struct mm_struct *mm,pgd_t *pgd,unsigned long address) +int __pud_alloc (struct mm_struct *mm,pgd_t *pgd, +unsigned long address,gfp_t gfp_mask) { -pud_t *new =pud_alloc_one (mm, address); +pud_t *new =pud_alloc_one (mm, address, gfp_mask);if (!new)return -ENOMEM ;
@@ -3565,9 +3566,10 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)* Allocate page middle directory. * We've already handled the fast-path in-line. */ -int __pmd_alloc (struct mm_struct *mm,pud_t *pud,unsigned long address) +int __pmd_alloc (struct mm_struct *mm,pud_t *pud, +unsigned long address,gfp_t gfp_mask) { -pmd_t *new =pmd_alloc_one (mm, address); +pmd_t *new =pmd_alloc_one (mm, address, gfp_mask);if (!new)return -ENOMEM ;
mm/mremap.c +2 -2
@@ -55,11 +55,11 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,pmd_t *pmd; pgd =pgd_offset (mm, addr); - pud =pud_alloc (mm, pgd, addr); + pud =pud_alloc (mm, pgd, addr,GFP_KERNEL );if (!pud)return NULL ; - pmd =pmd_alloc (mm, pud, addr); + pmd =pmd_alloc (mm, pud, addr,GFP_KERNEL );if (!pmd)return NULL ;
mm/vmalloc.c +39 -16
146 lines not on this page · raw message
Signature · 8 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Signed-off-by Minchan Kim <[email protected]>
Hmm ? vmalloc should support GFP_ATOMIC ?
And, do we need to change all pud_,pgd_,pmd_,pte_alloc() for users pgtables ?
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · KAMEZAWA Hiroyuki
Quoted 7 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.
Quoted 4 lines
Quoted 1 line
Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?
I'm not sure but alloc_large_system_hash already has used. And it's not specific on GFP_ATOMIC.
We have to care of GFP_NOFS and GFP_NOIO to prevent deadlock on reclaim context.
There are some places to use GFP_NOFS and we don't emit any warning message in case of that.
Quoted 2 lines
And, do we need to change all pud_,pgd_,pmd_,pte_alloc() for users pgtables ?
Maybe.
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
2012/4/24 Minchan Kim <[email protected]>:
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 10 lines
Quoted 7 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Quoted 4 lines
Quoted 1 line
Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?
Quoted 6 lines
I'm not sure but
alloc_large_system_hashalready has used. And it's not specific onGFP_ATOMIC.
We have to care ofGFP_NOFSandGFP_NOIOto prevent deadlock on reclaim context.
There are some places to useGFP_NOFSand we don't emit any warning message in case of that.
What's the lockdep warning?
vmalloc was never supposed to use gfp flags for allocation "context" restriction. I.e., it
was always supposed to have blocking, fs, and io capable allocation context. The flags
were supposed to be a memory type modifier.
These different classes of flags is a bit of a problem and source of confusion we have.
We should be doing more checks for them, of course.
I suspect you need to fix the caller?
Thanks,
Nick
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 18 lines · Nick Piggin
2012/4/24 Minchan Kim <[email protected]>:
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines
Quoted 8 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?
Quoted 8 lines
Quoted 6 lines
I'm not sure but
alloc_large_system_hashalready has used. And it's not specific onGFP_ATOMIC.
We have to care ofGFP_NOFSandGFP_NOIOto prevent deadlock on reclaim context.
There are some places to useGFP_NOFSand we don't emit any warning message in case of that.What's the lockdep warning?
It's just some private-test code, not-mainlined and lockdep warning is like this.
[ INFO: inconsistent lock state ] 3.4.0-rc3-next-20120417+ #80 Not tainted
---------------------------------
inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.
It seems test code calls vmalloc inside reclaim context so that it enters reclaim context, again by map_vm_area which allocates pages with GFP_KERNEL.
Of course, I can avoid this problem by fixing the caller but during I look into this problem, found other places to use gfp_t with "context restriction".
Quoted 7 lines
vmalloc was never supposed to use gfp flags for allocation "context" restriction. I.e., it
was always supposed to have blocking, fs, and io capable allocation context. The flags
were supposed to be a memory type modifier.
You mean "zone modifiers"?
Quoted 4 lines
These different classes of flags is a bit of a problem and source of confusion we have.
We should be doing more checks for them, of course.
It might need some warning in __vmalloc and family which use gfp_t if the caller use context flags.
Quoted 2 lines
I suspect you need to fix the caller?
Hmm, there are several places to use GFP_NOIO and GFP_NOFS even, GFP_ATOMIC. I believe it's not trivial now.
Quoted 11 lines
Thanks,
Nick--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 46 lines · Minchan Kim
Quoted 18 lines · Nick Piggin
2012/4/24 Minchan Kim <[email protected]>:
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines
Quoted 8 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?Quoted 8 lines
Quoted 6 lines
I'm not sure but
alloc_large_system_hashalready has used. And it's not specific onGFP_ATOMIC.
We have to care ofGFP_NOFSandGFP_NOIOto prevent deadlock on reclaim context.
There are some places to useGFP_NOFSand we don't emit any warning message in case of that.What's the lockdep warning?
It's just some private-test code, not-mainlined and lockdep warning is like this.
[ INFO: inconsistent lock state ] 3.4.0-rc3-next-20120417+ #80 Not tainted
---------------------------------
inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.It seems test code calls vmalloc inside reclaim context so that it enters reclaim context, again by
map_vm_areawhich allocates pages withGFP_KERNEL.Of course, I can avoid this problem by fixing the caller but during I look into this problem, found other places to use
gfp_twith "context restriction".Quoted 1 line
Quoted 8 lines
Quoted 5 lines
vmalloc was never supposed to use gfp flags for allocation "context" restriction. I.e., it
was always supposed to have blocking, fs, and io capable allocation context. The flags
were supposed to be a memory type modifier.You mean "zone modifiers"?
Yeah, things like that.
Quoted 7 lines
Quoted 3 lines
These different classes of flags is a bit of a problem and source of confusion we have.
We should be doing more checks for them, of course.It might need some warning in
__vmallocand family which usegfp_tif the caller use context flags.
I think that would be a good idea.
Quoted 5 lines
Quoted 1 line
I suspect you need to fix the caller?
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.
They're all buggy then. Unfortunately not through any real fault of their own.
I would say add a bit of warnings and documentation, and see what can be done about callers.
We should not take lightly the decision to make the API more permissive, because as you can see it's more work for implementation. Making it ATOMIC safe is even harder, requiring irqsafe locks and such, and it might be tricky for some architectures.
Thanks,
Nick
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 69 lines · Nick Piggin
Quoted 46 lines · Minchan Kim
Quoted 18 lines · Nick Piggin
2012/4/24 Minchan Kim <[email protected]>:
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines
Quoted 8 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?Quoted 8 lines
Quoted 6 lines
I'm not sure but
alloc_large_system_hashalready has used. And it's not specific onGFP_ATOMIC.
We have to care ofGFP_NOFSandGFP_NOIOto prevent deadlock on reclaim context.
There are some places to useGFP_NOFSand we don't emit any warning message in case of that.What's the lockdep warning?
It's just some private-test code, not-mainlined and lockdep warning is like this.
[ INFO: inconsistent lock state ] 3.4.0-rc3-next-20120417+ #80 Not tainted
---------------------------------
inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.It seems test code calls vmalloc inside reclaim context so that it enters reclaim context, again by
map_vm_areawhich allocates pages withGFP_KERNEL.Of course, I can avoid this problem by fixing the caller but during I look into this problem, found other places to use
gfp_twith "context restriction".Quoted 1 line
Quoted 8 lines
Quoted 5 lines
vmalloc was never supposed to use gfp flags for allocation "context" restriction. I.e., it
was always supposed to have blocking, fs, and io capable allocation context. The flags
were supposed to be a memory type modifier.You mean "zone modifiers"?
Yeah, things like that.
Quoted 7 lines
Quoted 3 lines
These different classes of flags is a bit of a problem and source of confusion we have.
We should be doing more checks for them, of course.It might need some warning in
__vmallocand family which usegfp_tif the caller use context flags.I think that would be a good idea.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I suspect you need to fix the caller?
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
That's why I send it with RFC before I have to make all architecture change. Nick, Thanks!
Quoted 8 lines
I would say add a bit of warnings and documentation, and see what can be done about callers.
We should not take lightly the decision to make the API more permissive, because as you can see it's more work for implementation. Making it ATOMIC safe is even
Agree. Will add waring and Cced all maintainers.
Quoted 1 line
harder, requiring irqsafe locks and such, and it might be tricky for some
irqsafe? Why should we consider it?
Just out of curiosity.
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 89 lines · Minchan Kim
Quoted 69 lines · Nick Piggin
Quoted 46 lines · Minchan Kim
Quoted 18 lines · Nick Piggin
2012/4/24 Minchan Kim <[email protected]>:
Quoted 17 lines · KAMEZAWA Hiroyuki
Quoted 14 lines
Quoted 8 lines · Minchan Kim
As I test some code, I found a problem about deadlock by lockdep. The reason I saw the message is
__vmalloccallsmap_vm_areawhich calls pud/pmd_alloc withoutgfp_t. so although we call__vmallocwithGFP_ATOMICorGFP_NOIO, it ends up allocating pages withGFP_KERNEL. The should be a BUG. This patch fixes it by passinggfp_toto low page table allocate functions.Signed-off-by Minchan Kim <[email protected]>Hmm ? vmalloc should support
GFP_ATOMIC?Quoted 8 lines
Quoted 6 lines
I'm not sure but
alloc_large_system_hashalready has used. And it's not specific onGFP_ATOMIC.
We have to care ofGFP_NOFSandGFP_NOIOto prevent deadlock on reclaim context.
There are some places to useGFP_NOFSand we don't emit any warning message in case of that.What's the lockdep warning?
It's just some private-test code, not-mainlined and lockdep warning is like this.
[ INFO: inconsistent lock state ] 3.4.0-rc3-next-20120417+ #80 Not tainted
---------------------------------
inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.It seems test code calls vmalloc inside reclaim context so that it enters reclaim context, again by
map_vm_areawhich allocates pages withGFP_KERNEL.Of course, I can avoid this problem by fixing the caller but during I look into this problem, found other places to use
gfp_twith "context restriction".Quoted 1 line
Quoted 8 lines
Quoted 5 lines
vmalloc was never supposed to use gfp flags for allocation "context" restriction. I.e., it
was always supposed to have blocking, fs, and io capable allocation context. The flags
were supposed to be a memory type modifier.You mean "zone modifiers"?
Yeah, things like that.
Quoted 7 lines
Quoted 3 lines
These different classes of flags is a bit of a problem and source of confusion we have.
We should be doing more checks for them, of course.It might need some warning in
__vmallocand family which usegfp_tif the caller use context flags.I think that would be a good idea.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I suspect you need to fix the caller?
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
That's why I send it with RFC before I have to make all architecture change. Nick, Thanks!
Quoted 5 lines
I would say add a bit of warnings and documentation, and see what can be done about callers.
Quoted 5 lines
Quoted 2 lines
We should not take lightly the decision to make the API more permissive, because as you can see it's more work for implementation. Making it ATOMIC safe is even
Agree. Will add waring and Cced all maintainers.
Thanks very much!
Quoted 6 lines
Quoted 2 lines
harder, requiring irqsafe locks and such, and it might be tricky for some
irqsafe? Why should we consider it?
Just out of curiosity.
I don't think we should just yet. It is an example of something that callers have wanted in the past, but have solved in other ways when we have objected.
Thanks,
Nick
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in block/blk-throttle.c (thread "mempool, percpu, blkcg: fix percpu stat allocation and remove stats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, under GFP_NOIO.
Changing vmalloc() to take a gfp_t does make lots of sense, although I worry a bit about making vmalloc() easier to use!
I do wonder whether the whole scheme of explicitly passing a gfp_t was a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current. As a handy side-effect that would probably save quite some code where functions are receiving a gfp_t arg then simply passing it on to the next callee.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · Andrew Morton
Quoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.
Quoted 6 lines
Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current.
yes...that's very interesting.
Regards,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 15 lines · KAMEZAWA Hiroyuki
Quoted 13 lines · Andrew Morton
Quoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.
Quoted 8 lines
Quoted 6 lines
Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current.yes...that's very interesting.
I think GFP_ATOMIC is used non task context too. ;-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 20 lines · KOSAKI Motohiro
Quoted 18 lines · KAMEZAWA Hiroyuki
Quoted 16 lines · Andrew Morton
Quoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current.yes...that's very interesting.
I think
GFP_ATOMICis used non task context too. ;-)
Hmm, in interrupt context or some ? Can't we detect it ?
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 26 lines · On Wed, 25 Apr 2012 09:05:12 +0900 KAMEZAWA Hiroyuki…
Quoted 24 lines · KOSAKI Motohiro
Quoted 22 lines · KAMEZAWA Hiroyuki
Quoted 19 lines · Andrew Morton
Quoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
yes...that's very interesting.
I think
GFP_ATOMICis used non task context too. ;-)Hmm, in interrupt context or some ? Can't we detect it ?
There are lots of practical details and I haven't begun to think it through, mainly because it Isn't Going To Happen!
For example how do we handle spin_lock()? Does spin_lock() now do
gfp_t spin_lock_2(spinlock_t *lock)
{
gfp_t old_gfp = set_current_gfp(GFP_ATOMIC);
spin_lock(lock);
return old_gfp;
}void spin_unlock_2(spinlock_t *lock, gfp_t old_gfp)
{
spin_unlock(lock);
set_current_gfp(old_gfp);
}Well that's bad. Currently we require programmers to keep track of what context they're running in. So they think about what they're doing. If we made it this easy, we'd see a big proliferation of GFP_ATOMIC allocations, which is bad.
Requiring the spin_lock() caller to run set_current_gfp() would have the same effect.
Or do we instead do this:
- some_function(foo, bar, GFP_NOIO);
+ old_gfp = set_current_gfp(GFP_NOIO);
+ some_function(foo, bar);
+ set_current_gfp(old_gfp);
So the rule is "if the code was using an explicit GFP_foo then convert it to use set_current_gfp(). If the code was receiving a gfp_t variable from the caller then delete that arg".
Or something like that. It's all too hopelessly impractical to bother discussing - 20 years too late!
otoh, maybe a constrained version of this could be used to address the vmalloc() problem alone.
otoh2, I didn't *want* blk-throttle.c to use GFP_NOIO for vmalloc(). GFP_NOIO is weak, unreliable and lame. blk-throttle should find a way of using GFP_KERNEL!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 74 lines · Andrew Morton
Quoted 26 lines · On Wed, 25 Apr 2012 09:05:12 +0900 KAMEZAWA Hiroyuki…
Quoted 24 lines · KOSAKI Motohiro
Quoted 22 lines · KAMEZAWA Hiroyuki
Quoted 19 lines · Andrew Morton
Quoted 4 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current.Quoted 5 lines
Quoted 3 lines
Quoted 1 line
yes...that's very interesting.
I think
GFP_ATOMICis used non task context too. ;-)Hmm, in interrupt context or some ? Can't we detect it ?
There are lots of practical details and I haven't begun to think it through, mainly because it Isn't Going To Happen!
For example how do we handle
spin_lock()? Doesspin_lock()now do
gfp_tspin_lock_2(spinlock_t *lock){ gfp_t old_gfp = set_current_gfp(GFP_ATOMIC); spin_lock(lock); return old_gfp; }void
spin_unlock_2(spinlock_t *lock, gfp_t old_gfp){ spin_unlock(lock); set_current_gfp(old_gfp); }Well that's bad. Currently we require programmers to keep track of what context they're running in. So they think about what they're doing. If we made it this easy, we'd see a big proliferation of
GFP_ATOMICallocations, which is bad.Requiring the
spin_lock()caller to runset_current_gfp()would have the same effect.Or do we instead do this:
(quoted diff) +3
-1- some_function(foo, bar, GFP_NOIO); + old_gfp = set_current_gfp(GFP_NOIO); + some_function(foo, bar); + set_current_gfp(old_gfp);So the rule is "if the code was using an explicit
GFP_foothen convert it to useset_current_gfp(). If the code was receiving agfp_tvariable from the caller then delete that arg".
Quoted 7 lines
Or something like that. It's all too hopelessly impractical to bother discussing - 20 years too late!
otoh, maybe a constrained version of this could be used to address the
vmalloc()problem alone.
Yes, I think it will be good start.
Quoted 4 lines
otoh2, I didn't *want*
blk-throttle.cto useGFP_NOIOforvmalloc().GFP_NOIOis weak, unreliable and lame. blk-throttle should find a way of usingGFP_KERNEL!
I agree.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 15 lines · KAMEZAWA Hiroyuki
Quoted 15 lines
Or do we instead do this:
(quoted diff) +3
-1- some_function(foo, bar, GFP_NOIO); + old_gfp = set_current_gfp(GFP_NOIO); + some_function(foo, bar); + set_current_gfp(old_gfp);So the rule is "if the code was using an explicit
GFP_foothen convert it to useset_current_gfp(). If the code was receiving agfp_tvariable from the caller then delete that arg".Or something like that. It's all too hopelessly impractical to bother discussing - 20 years too late!
Quoted 6 lines
Quoted 3 lines
otoh, maybe a constrained version of this could be used to address the
vmalloc()problem alone.Yes, I think it will be good start.
Maybe a per-thread_info variant of gfp_allowed_mask? So Andrew's set_current_gfp() becomes set_current_gfp_allowed() that does
void set_current_gfp_allowed(gfp_t gfp_mask)
{
current->gfp_allowed = gfp_mask & gfp_allowed_mask;
}and then the page allocator does
gfp_mask &= current->gfp_allowed;
rather than how it currently does
gfp_mask &= gfp_allowed_mask;
and then the caller of set_current_gfp_allowed() cleans up with set_current_gfp_allowed(__GFP_BITS_MASK).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 34 lines · David Rientjes
Quoted 15 lines · KAMEZAWA Hiroyuki
Quoted 15 lines
Or do we instead do this:
(quoted diff) +3
-1- some_function(foo, bar, GFP_NOIO); + old_gfp = set_current_gfp(GFP_NOIO); + some_function(foo, bar); + set_current_gfp(old_gfp);So the rule is "if the code was using an explicit
GFP_foothen convert it to useset_current_gfp(). If the code was receiving agfp_tvariable from the caller then delete that arg".Or something like that. It's all too hopelessly impractical to bother discussing - 20 years too late!
Quoted 6 lines
Quoted 3 lines
otoh, maybe a constrained version of this could be used to address the
vmalloc()problem alone.Yes, I think it will be good start.
Maybe a per-thread_info variant of
gfp_allowed_mask? So Andrew'sset_current_gfp()becomesset_current_gfp_allowed()that doesvoid set_current_gfp_allowed(gfp_t gfp_mask) { current->gfp_allowed = gfp_mask & gfp_allowed_mask; }and then the page allocator does
Quoted 8 lines
gfp_mask &= current->gfp_allowed;rather than how it currently does
gfp_mask &= gfp_allowed_mask;and then the caller of
set_current_gfp_allowed()cleans up withset_current_gfp_allowed(__GFP_BITS_MASK).
Caller should restore old gfp_mask instead of __GFP_BITS_MASK in case of nesting.And how do we care of atomic context?
I was about to add warning in __vmalloc internal if caller uses GFP_NOIO, GFP_NOFS, GFP_ATOMIC with Nick's comment and let them make to fix it. But it seems Andrew doesn't agree.
Andrew, please tell me your opinion for fixing this problem.
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 2 lines · On Fri, 27 Apr 2012 11:24:32 +0900 Minchan Kim <[email protected]> wrote:
I was about to add warning in
__vmallocinternal if caller usesGFP_NOIO,GFP_NOFS,GFP_ATOMICwith Nick's comment and let them make to fix it. But it seems Andrew doesn't agree.
I do, actually.
Quoted 1 line
Andrew, please tell me your opinion for fixing this problem.
Only call vmalloc() from GFP_KERNEL contexts. Go ahead, add the WARN_ONCE() and let's see what happens.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Minchan Kim
Quoted 10 lines
Maybe a per-thread_info variant of
gfp_allowed_mask? So Andrew'sset_current_gfp()becomesset_current_gfp_allowed()that doesvoid set_current_gfp_allowed(gfp_t gfp_mask) { current->gfp_allowed = gfp_mask & gfp_allowed_mask; }and then the page allocator does
Quoted 9 lines
Quoted 8 lines
gfp_mask &= current->gfp_allowed;rather than how it currently does
gfp_mask &= gfp_allowed_mask;and then the caller of
set_current_gfp_allowed()cleans up withset_current_gfp_allowed(__GFP_BITS_MASK).
[trimmed the newsgroups from the reply, not sure what the point is?]
Quoted 3 lines
Caller should restore old
gfp_maskinstead of__GFP_BITS_MASKin case of nesting.And how do we care of atomic context?
Eek, I'm hoping these aren't going to be nested but sure that seems appropraite if they are. (I'm also hoping these will only be either __GFP_HIGH or __GFP_BITS_MASK and no other combinations.)
Forcing atomic context would just be set_current_gfp_allowed(__GFP_HIGH).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 28 lines · David Rientjes
Quoted 10 lines · Minchan Kim
Quoted 10 lines
Maybe a per-thread_info variant of
gfp_allowed_mask? So Andrew'sset_current_gfp()becomesset_current_gfp_allowed()that doesvoid set_current_gfp_allowed(gfp_t gfp_mask) { current->gfp_allowed = gfp_mask & gfp_allowed_mask; }and then the page allocator does
Quoted 9 lines
Quoted 8 lines
gfp_mask &= current->gfp_allowed;rather than how it currently does
gfp_mask &= gfp_allowed_mask;and then the caller of
set_current_gfp_allowed()cleans up withset_current_gfp_allowed(__GFP_BITS_MASK).[trimmed the newsgroups from the reply, not sure what the point is?]
Quoted 3 lines
Caller should restore old
gfp_maskinstead of__GFP_BITS_MASKin case of nesting.And how do we care of atomic context?
Quoted 5 lines
Eek, I'm hoping these aren't going to be nested but sure that seems appropraite if they are. (I'm also hoping these will only be either
__GFP_HIGHor__GFP_BITS_MASKand no other combinations.)Forcing atomic context would just be
set_current_gfp_allowed(__GFP_HIGH).
I mean it's not legal to access _current_ in atomic context so that (gfp_mask &= current->gfp_allowed in page allocator) shouldn't.
Signature · 9 lines
Kind regards, Minchan Kim -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Tue, 24 Apr 2012 17:48:29 +1000 Nick Piggin <[email protected]> wrote:
Quoted 2 lines
Hmm, there are several places to use
GFP_NOIOandGFP_NOFSeven,GFP_ATOMIC. I believe it's not trivial now.
Quoted 6 lines
Quoted 1 line
They're all buggy then. Unfortunately not through any real fault of their own.
There are gruesome problems in
block/blk-throttle.c(thread "mempool, percpu, blkcg: fix percpu stat allocation and removestats_lock"). It wants to do an alloc_percpu()->vmalloc() from the IO submission path, underGFP_NOIO.
Yeah, that sucks. CFQ has something similar.
Should just allocate it up front when creating a throttled group. Allocate and init when it first gets used schemes are usually pretty problematic. Is it *really* warranted to do it lazily like this?
Quoted 9 lines
Changing
vmalloc()to take agfp_tdoes make lots of sense, although I worry a bit about makingvmalloc()easier to use!I do wonder whether the whole scheme of explicitly passing a
gfp_twas a mistake and that the allocation context should be part of the task context. ie: pass the allocation mode via *current. As a handy side-effect that would probably save quite some code where functions are receiving agfp_targ then simply passing it on to the next callee.
Both paragraphs make a lot of sense. Conceptually. :)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>