Skip to content

Commit d8fe4ac

Browse files
committed
Merge branch 'akpm' (patch-bomb from Andrew Morton)
Merge patches from Andrew Morton: - memstick fixes - the rest of MM - various misc bits that were awaiting merges from linux-next into mainline: seq_file, printk, rtc, completions, w1, softirqs, llist, kfifo, hfsplus * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (72 commits) cmdline-parser: fix build hfsplus: Fix undefined __divdi3 in hfsplus_init_header_node() kfifo API type safety kfifo: kfifo_copy_{to,from}_user: fix copied bytes calculation sound/core/memalloc.c: use gen_pool_dma_alloc() to allocate iram buffer llists-move-llist_reverse_order-from-raid5-to-llistc-fix llists: move llist_reverse_order from raid5 to llist.c kernel: fix generic_exec_single indentation kernel-provide-a-__smp_call_function_single-stub-for-config_smp-fix kernel: provide a __smp_call_function_single stub for !CONFIG_SMP kernel: remove CONFIG_USE_GENERIC_SMP_HELPERS revert "softirq: Add support for triggering softirq work on softirqs" drivers/w1/masters/w1-gpio.c: use dev_get_platdata() sched: remove INIT_COMPLETION tree-wide: use reinit_completion instead of INIT_COMPLETION sched: replace INIT_COMPLETION with reinit_completion drivers/rtc/rtc-hid-sensor-time.c: enable HID input processing early drivers/rtc/rtc-hid-sensor-time.c: use dev_get_platdata() vsprintf: ignore %n again seq_file: remove "%n" usage from seq_file users ...
2 parents 3aeb58a + 8d3ef55 commit d8fe4ac

213 files changed

Lines changed: 1164 additions & 889 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
Split page table lock
2+
=====================
3+
4+
Originally, mm->page_table_lock spinlock protected all page tables of the
5+
mm_struct. But this approach leads to poor page fault scalability of
6+
multi-threaded applications due high contention on the lock. To improve
7+
scalability, split page table lock was introduced.
8+
9+
With split page table lock we have separate per-table lock to serialize
10+
access to the table. At the moment we use split lock for PTE and PMD
11+
tables. Access to higher level tables protected by mm->page_table_lock.
12+
13+
There are helpers to lock/unlock a table and other accessor functions:
14+
- pte_offset_map_lock()
15+
maps pte and takes PTE table lock, returns pointer to the taken
16+
lock;
17+
- pte_unmap_unlock()
18+
unlocks and unmaps PTE table;
19+
- pte_alloc_map_lock()
20+
allocates PTE table if needed and take the lock, returns pointer
21+
to taken lock or NULL if allocation failed;
22+
- pte_lockptr()
23+
returns pointer to PTE table lock;
24+
- pmd_lock()
25+
takes PMD table lock, returns pointer to taken lock;
26+
- pmd_lockptr()
27+
returns pointer to PMD table lock;
28+
29+
Split page table lock for PTE tables is enabled compile-time if
30+
CONFIG_SPLIT_PTLOCK_CPUS (usually 4) is less or equal to NR_CPUS.
31+
If split lock is disabled, all tables guaded by mm->page_table_lock.
32+
33+
Split page table lock for PMD tables is enabled, if it's enabled for PTE
34+
tables and the architecture supports it (see below).
35+
36+
Hugetlb and split page table lock
37+
---------------------------------
38+
39+
Hugetlb can support several page sizes. We use split lock only for PMD
40+
level, but not for PUD.
41+
42+
Hugetlb-specific helpers:
43+
- huge_pte_lock()
44+
takes pmd split lock for PMD_SIZE page, mm->page_table_lock
45+
otherwise;
46+
- huge_pte_lockptr()
47+
returns pointer to table lock;
48+
49+
Support of split page table lock by an architecture
50+
---------------------------------------------------
51+
52+
There's no need in special enabling of PTE split page table lock:
53+
everything required is done by pgtable_page_ctor() and pgtable_page_dtor(),
54+
which must be called on PTE table allocation / freeing.
55+
56+
Make sure the architecture doesn't use slab allocator for page table
57+
allocation: slab uses page->slab_cache and page->first_page for its pages.
58+
These fields share storage with page->ptl.
59+
60+
PMD split lock only makes sense if you have more than two page table
61+
levels.
62+
63+
PMD split lock enabling requires pgtable_pmd_page_ctor() call on PMD table
64+
allocation and pgtable_pmd_page_dtor() on freeing.
65+
66+
Allocation usually happens in pmd_alloc_one(), freeing in pmd_free(), but
67+
make sure you cover all PMD table allocation / freeing paths: i.e X86_PAE
68+
preallocate few PMDs on pgd_alloc().
69+
70+
With everything in place you can set CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK.
71+
72+
NOTE: pgtable_page_ctor() and pgtable_pmd_page_ctor() can fail -- it must
73+
be handled properly.
74+
75+
page->ptl
76+
---------
77+
78+
page->ptl is used to access split page table lock, where 'page' is struct
79+
page of page containing the table. It shares storage with page->private
80+
(and few other fields in union).
81+
82+
To avoid increasing size of struct page and have best performance, we use a
83+
trick:
84+
- if spinlock_t fits into long, we use page->ptr as spinlock, so we
85+
can avoid indirect access and save a cache line.
86+
- if size of spinlock_t is bigger then size of long, we use page->ptl as
87+
pointer to spinlock_t and allocate it dynamically. This allows to use
88+
split lock with enabled DEBUG_SPINLOCK or DEBUG_LOCK_ALLOC, but costs
89+
one more cache line for indirect access;
90+
91+
The spinlock_t allocated in pgtable_page_ctor() for PTE table and in
92+
pgtable_pmd_page_ctor() for PMD table.
93+
94+
Please, never access page->ptl directly -- use appropriate helper.

‎arch/Kconfig‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,6 @@ config HAVE_DMA_ATTRS
207207
config HAVE_DMA_CONTIGUOUS
208208
bool
209209

210-
config USE_GENERIC_SMP_HELPERS
211-
bool
212-
213210
config GENERIC_SMP_IDLE_THREAD
214211
bool
215212

‎arch/alpha/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ config ARCH_MAY_HAVE_PC_FDC
522522
config SMP
523523
bool "Symmetric multi-processing support"
524524
depends on ALPHA_SABLE || ALPHA_LYNX || ALPHA_RAWHIDE || ALPHA_DP264 || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_GENERIC || ALPHA_SHARK || ALPHA_MARVEL
525-
select USE_GENERIC_SMP_HELPERS
526525
---help---
527526
This enables support for systems with more than one CPU. If you have
528527
a system with only one CPU, like most personal computers, say N. If

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ pte_alloc_one(struct mm_struct *mm, unsigned long address)
7272
if (!pte)
7373
return NULL;
7474
page = virt_to_page(pte);
75-
pgtable_page_ctor(page);
75+
if (!pgtable_page_ctor(page)) {
76+
__free_page(page);
77+
return NULL;
78+
}
7679
return page;
7780
}
7881

‎arch/arc/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ config ARC_PLAT_NEEDS_CPU_TO_DMA
125125
config SMP
126126
bool "Symmetric Multi-Processing (Incomplete)"
127127
default n
128-
select USE_GENERIC_SMP_HELPERS
129128
help
130129
This enables support for systems with more than one CPU. If you have
131130
a system with only one CPU, like most personal computers, say N. If

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ static inline pgtable_t
105105
pte_alloc_one(struct mm_struct *mm, unsigned long address)
106106
{
107107
pgtable_t pte_pg;
108+
struct page *page;
108109

109110
pte_pg = __get_free_pages(GFP_KERNEL | __GFP_REPEAT, __get_order_pte());
110-
if (pte_pg) {
111-
memzero((void *)pte_pg, PTRS_PER_PTE * 4);
112-
pgtable_page_ctor(virt_to_page(pte_pg));
111+
if (!pte_pg)
112+
return 0;
113+
memzero((void *)pte_pg, PTRS_PER_PTE * 4);
114+
page = virt_to_page(pte_pg);
115+
if (!pgtable_page_ctor(page)) {
116+
__free_page(page);
117+
return 0;
113118
}
114119

115120
return pte_pg;

‎arch/arm/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,6 @@ config SMP
14321432
depends on GENERIC_CLOCKEVENTS
14331433
depends on HAVE_SMP
14341434
depends on MMU || ARM_MPU
1435-
select USE_GENERIC_SMP_HELPERS
14361435
help
14371436
This enables support for systems with more than one CPU. If you have
14381437
a system with only one CPU, like most personal computers, say N. If

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr)
102102
#else
103103
pte = alloc_pages(PGALLOC_GFP, 0);
104104
#endif
105-
if (pte) {
106-
if (!PageHighMem(pte))
107-
clean_pte_table(page_address(pte));
108-
pgtable_page_ctor(pte);
105+
if (!pte)
106+
return NULL;
107+
if (!PageHighMem(pte))
108+
clean_pte_table(page_address(pte));
109+
if (!pgtable_page_ctor(pte)) {
110+
__free_page(pte);
111+
return NULL;
109112
}
110-
111113
return pte;
112114
}
113115

‎arch/arm/mach-tegra/apbio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static int do_dma_transfer(unsigned long apb_add,
114114
dma_desc->callback = apb_dma_complete;
115115
dma_desc->callback_param = NULL;
116116

117-
INIT_COMPLETION(tegra_apb_wait);
117+
reinit_completion(&tegra_apb_wait);
118118

119119
dmaengine_submit(dma_desc);
120120
dma_async_issue_pending(tegra_apb_dma_chan);

‎arch/arm/mm/fault-armv.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int do_adjust_pte(struct vm_area_struct *vma, unsigned long address,
6565
return ret;
6666
}
6767

68-
#if USE_SPLIT_PTLOCKS
68+
#if USE_SPLIT_PTE_PTLOCKS
6969
/*
7070
* If we are using split PTE locks, then we need to take the page
7171
* lock here. Otherwise we are using shared mm->page_table_lock
@@ -84,10 +84,10 @@ static inline void do_pte_unlock(spinlock_t *ptl)
8484
{
8585
spin_unlock(ptl);
8686
}
87-
#else /* !USE_SPLIT_PTLOCKS */
87+
#else /* !USE_SPLIT_PTE_PTLOCKS */
8888
static inline void do_pte_lock(spinlock_t *ptl) {}
8989
static inline void do_pte_unlock(spinlock_t *ptl) {}
90-
#endif /* USE_SPLIT_PTLOCKS */
90+
#endif /* USE_SPLIT_PTE_PTLOCKS */
9191

9292
static int adjust_pte(struct vm_area_struct *vma, unsigned long address,
9393
unsigned long pfn)

0 commit comments

Comments
 (0)