mm: flotsam
Subsystems (4)
cover mm: flotsam
Salvage a few damp pieces from the wreckage of my previous mm batch. Against 2.6.15-rc2, shouldn't clash with other work.
Hugh
arch/powerpc/mm/4xx_mmu.c | 4 --- arch/powerpc/mm/hugetlbpage.c | 4 --- arch/powerpc/mm/mem.c | 2 - arch/powerpc/mm/tlb_32.c | 6 ++++ arch/powerpc/mm/tlb_64.c | 4 +-- include/asm-alpha/atomic.h | 7 ++++- include/asm-sparc64/atomic.h | 1 include/asm-x86_64/atomic.h | 51 +++++++++++++++++++++++++++++++----------- kernel/futex.c | 15 ------------ mm/Kconfig | 6 +--- 10 files changed, 56 insertions(+), 44 deletions(-)
PATCH 1/5 mm: update split ptlock Kconfig
Closer attention to the arithmetic shows that neither ppc64 nor sparc really uses one page for multiple page tables: how on earth could they, while pte_alloc_one returns just a struct page pointer, with no offset?
Well, arm26 manages it by returning a pte_t pointer cast to a struct page pointer, harumph, then compensating in its pmd_populate. But arm26 is never SMP, so it's not a problem for split ptlock either.
And the PA-RISC situation has been recently improved: CONFIG_PA20 works without the 16-byte alignment which inflated its spinlock_t. But the current union of spinlock_t with private does make the 7xxx struct page significantly larger, even without debug, so disable its split ptlock.
---
mm/Kconfig | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
mm/Kconfig +2 -4
@@ -125,12 +125,10 @@ comment "Memory hotplug is currently inc # space can be handled with less contention: split it at this NR_CPUS. # Default to 4 for wider testing, though 8 might be more appropriate. # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock. -# PA-RISC's debug spinlock_t is too large for the 32-bit struct page. -# ARM26 and SPARC32 and PPC64 may use one page for multiple page tables. +# PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes. # config SPLIT_PTLOCK_CPUS int default "4096" if ARM && !CPU_CACHE_VIPT - default "4096" if PARISC && DEBUG_SPINLOCK && !64BIT - default "4096" if ARM26 || SPARC32 || PPC64 + default "4096" if PARISC && !PA20 default "4"
PATCH 2/5 mm: unbloat get_futex_key
In reply to Hugh DickinsThe follow_page changes in get_futex_key have left it with two almost identical blocks, when handling the rare case of a futex in a nonlinear vma. get_user_pages will itself do that follow_page, and its additional find_extend_vma is hardly any overhead since the vma is already cached. Let's just delete the follow_page block and let get_user_pages do it.
---
kernel/futex.c | 15 --------------- 1 files changed, 15 deletions(-)
kernel/futex.c +0 -15
@@ -201,21 +201,6 @@ static int get_futex_key(unsigned long u* from swap. But that's a lot of code to duplicate here * for a rare case, so we simply fetch the page. */ - -/* -* Do a quick atomic lookup first - this is the fastpath. -*/ - page =follow_page (mm, uaddr,FOLL_TOUCH |FOLL_GET ); -if (likely (page !=NULL )) { - key->shared.pgoff = - page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); -put_page (page); -return 0 ; - } - -/* -* Do it the general way. -*/ err =get_user_pages (current, mm, uaddr,1 ,0 ,0 , &page,NULL );if (err >=0 ) { key->shared.pgoff =
PATCH 3/5 mm: powerpc ptlock comments
In reply to Hugh DickinsUpdate comments (only) on page_table_lock and mmap_sem in arch/powerpc. Removed the comment on page_table_lock from hash_huge_page: since it's no longer taking page_table_lock itself, it's irrelevant whether others are; but how it is safe (even against huge file truncation?) I can't say.
---
arch/powerpc/mm/hugetlbpage.c | 4 +--- arch/powerpc/mm/mem.c | 2 +- arch/powerpc/mm/tlb_32.c | 6 ++++++ arch/powerpc/mm/tlb_64.c | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/mm/hugetlbpage.c +1 -3
@@ -754,9 +754,7 @@ repeat: }/* -* No need to use ldarx/stdcx here because all who -* might be updating the pte will hold the -* page_table_lock +* No need to use ldarx/stdcx here */ *ptep =__pte (new_pte & ~_PAGE_BUSY);
arch/powerpc/mm/mem.c +1 -1
@@ -495,7 +495,7 @@ EXPORT_SYMBOL(flush_icache_user_range);* We use it to preload an HPTE into the hash table corresponding to * the updated linux PTE. * -* This must always be called with the mm->page_table_lock held +* This must always be called with the pte lock held. */ void update_mmu_cache (struct vm_area_struct *vma,unsigned long address,pte_t pte)
arch/powerpc/mm/tlb_32.c +6 -0
@@ -149,6 +149,12 @@ void flush_tlb_mm(struct mm_struct *mm)return ; } +/* +* It is safe to go down the mm's list of vmas when called +* from dup_mmap, holding mmap_sem. It would also be safe from +* unmap_region or exit_mmap, but not from vmtruncate on SMP - +* but it seems dup_mmap is the only SMP case which gets here. +*/ for (mp = mm->mmap; mp !=NULL ; mp = mp->vm_next)flush_range (mp->vm_mm, mp->vm_start, mp->vm_end);FINISH_FLUSH ;
arch/powerpc/mm/tlb_64.c +2 -2
@@ -95,7 +95,7 @@ static void pte_free_submit(struct pte_fvoid pgtable_free_tlb (struct mmu_gather *tlb,pgtable_free_t pgf) { -/* This is safe as we are holding page_table_lock */ +/* This is safe since tlb_gather_mmu has disabled preemption */ cpumask_t local_cpumask =cpumask_of_cpu (smp_processor_id ());struct pte_freelist_batch **batchp = &__get_cpu_var (pte_freelist_cur);
@@ -206,7 +206,7 @@ void __flush_tlb_pending(struct ppc64_tlvoid pte_free_finish (void ) { -/* This is safe as we are holding page_table_lock */ +/* This is safe since tlb_gather_mmu has disabled preemption */ struct pte_freelist_batch **batchp = &__get_cpu_var (pte_freelist_cur);if (*batchp ==NULL )
Re: [PATCH 3/5] mm: powerpc ptlock comments
Quoted 1 line · Hugh Dickins
Update comments (only) on
page_table_lockandmmap_seminarch/powerpc.
[snip]
arch/powerpc/mm/hugetlbpage.c repeat: · line 758
Quoted 6 lines
arch/powerpc/mm/hugetlbpage.c +1
-3/* -* No need to use ldarx/stdcx here because all who -* might be updating the pte will hold the -* page_table_lock +* No need to use ldarx/stdcx here */
If you're going to remove the because clause you might as well remove the whole comment. What you have left is either redundant or mystifying (according to the depth of knowledge of the reader). And in fact I don't think I could now say why we don't need an atomic update sequence there, so I would appreciate something that updates the "because" part.
Paul.
Re: [PATCH 3/5] mm: powerpc ptlock comments
Quoted 5 lines · Paul Mackerras
Quoted 2 lines
Update comments (only) on
page_table_lockandmmap_seminarch/powerpc.[snip]
Quoted 13 lines
arch/powerpc/mm/hugetlbpage.c repeat: · line 758
Quoted 6 lines
arch/powerpc/mm/hugetlbpage.c +1
-3/* -* No need to use ldarx/stdcx here because all who -* might be updating the pte will hold the -* page_table_lock +* No need to use ldarx/stdcx here */ If you're going to remove the because clause you might as well remove the whole comment. What you have left is either redundant or mystifying (according to the depth of knowledge of the reader). And in fact I don't think I could now say why we don't need an atomic update sequence there, so I would appreciate something that updates the "because" part.
All I'm doing here is tidying up by removing the no-longer-appropriate
Quoted 4 lines · reference to page_table_lock. As my snipped patch comment
Update comments (only) on
page_table_lockandmmap_seminarch/powerpc. Removed the comment onpage_table_lockfromhash_huge_page: since it's no longer takingpage_table_lockitself, it's irrelevant whether others are; but how it is safe (even against huge file truncation?) I can't say.
I'd appreciate something that updates the "because" part too, but don't know the answer. That other patch will need to come from your end - Ben?
Hugh
Re: [PATCH 3/5] mm: powerpc ptlock comments
Quoted 2 lines · Hugh Dickins
I'd appreciate something that updates the "because" part too, but don't know the answer. That other patch will need to come from your end - Ben?
Hrm... same reason as __hash_page(), the code now locks the PTE using the _PAGE_BUSY bit. The last store does the update and unlock and doesn't need to be atomic. However, now that I look at it, it might need an lwsync. Paul ?
Ben.
PATCH 4/5 mm: powerpc init_mm without ptlock
In reply to Hugh DickinsRestore an earlier mod which went missing in the powerpc reshuffle:
the 4xx mmu_mapin_ram does not need to take init_mm.page_table_lock.
---
arch/powerpc/mm/4xx_mmu.c | 4 ---- 1 files changed, 4 deletions(-)
arch/powerpc/mm/4xx_mmu.c +0 -4
@@ -110,13 +110,11 @@ unsigned long __init mmu_mapin_ram(void)pmd_t *pmdp;unsigned long val = p | _PMD_SIZE_16M | _PAGE_HWEXEC | _PAGE_HWWRITE; -spin_lock (&init_mm.page_table_lock); pmdp =pmd_offset (pgd_offset_k (v), v);pmd_val (*pmdp++) = val;pmd_val (*pmdp++) = val;pmd_val (*pmdp++) = val;pmd_val (*pmdp++) = val; -spin_unlock (&init_mm.page_table_lock); v +=LARGE_PAGE_SIZE_16M ; p +=LARGE_PAGE_SIZE_16M ;
@@ -127,10 +125,8 @@ unsigned long __init mmu_mapin_ram(void)pmd_t *pmdp;unsigned long val = p | _PMD_SIZE_4M | _PAGE_HWEXEC | _PAGE_HWWRITE; -spin_lock (&init_mm.page_table_lock); pmdp =pmd_offset (pgd_offset_k (v), v);pmd_val (*pmdp) = val; -spin_unlock (&init_mm.page_table_lock); v +=LARGE_PAGE_SIZE_4M ; p +=LARGE_PAGE_SIZE_4M ;
PATCH 5/5 mm: fill arch atomic64 gaps
In reply to Hugh Dickinsalpha, sparc64, x86_64 are each missing some primitives from their atomic64 support: fill in the gaps I've noticed by extrapolating asm, follow the groupings in each file. But powerpc and parisc still lack atomic64.
---
include/asm-alpha/atomic.h | 7 ++++- include/asm-sparc64/atomic.h | 1 include/asm-x86_64/atomic.h | 51 ++++++++++++++++++++++++++++++++----------- 3 files changed, 44 insertions(+), 15 deletions(-)
include/asm-alpha/atomic.h +5 -2
@@ -118,8 +118,6 @@ static __inline__ long atomic_add_returnreturn result; } -#define atomic_add_negative (a, v) (atomic_add_return((a), (v)) < 0) -static __inline__long atomic64_add_return (long i,atomic64_t * v) {long temp, result;
@@ -189,6 +187,9 @@ static __inline__ long atomic64_sub_retu })#define atomic_inc_not_zero (v) atomic_add_unless((v), 1, 0) +#define atomic_add_negative (a, v) (atomic_add_return((a), (v)) < 0) +#define atomic64_add_negative (a, v) (atomic64_add_return((a), (v)) < 0) +#define atomic_dec_return (v) atomic_sub_return(1,(v))#define atomic64_dec_return (v) atomic64_sub_return(1,(v))
@@ -199,6 +200,8 @@ static __inline__ long atomic64_sub_retu#define atomic64_sub_and_test (i,v) (atomic64_sub_return((i), (v)) == 0)#define atomic_inc_and_test (v) (atomic_add_return(1, (v)) == 0) +#define atomic64_inc_and_test (v) (atomic64_add_return(1, (v)) == 0) +#define atomic_dec_and_test (v) (atomic_sub_return(1, (v)) == 0)#define atomic64_dec_and_test (v) (atomic64_sub_return(1, (v)) == 0)
include/asm-sparc64/atomic.h +1 -0
@@ -54,6 +54,7 @@ extern int atomic64_sub_ret(int, atomic6* other cases. */ #define atomic_inc_and_test (v) (atomic_inc_return(v) == 0) +#define atomic64_inc_and_test (v) (atomic64_inc_return(v) == 0)#define atomic_sub_and_test (i, v) (atomic_sub_ret(i, v) == 0)#define atomic64_sub_and_test (i, v) (atomic64_sub_ret(i, v) == 0)
include/asm-x86_64/atomic.h +38 -13
102 lines not on this page · raw message