Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2d6bfe

Browse files
hnaztorvalds
authored andcommitted
thp: add x86 32bit support
Add support for transparent hugepages to x86 32bit.Share the same VM_ bitflag for VM_MAPPED_COPY. mm/nommu.c will neversupport transparent hugepages.Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>Reviewed-by: Rik van Riel <riel@redhat.com>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent5f24ce5 commitf2d6bfe

File tree

7 files changed

+156
-115
lines changed

7 files changed

+156
-115
lines changed

‎arch/x86/include/asm/pgtable-2level.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
4646
#definenative_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp)
4747
#endif
4848

49+
#ifdefCONFIG_SMP
50+
staticinlinepmd_tnative_pmdp_get_and_clear(pmd_t*xp)
51+
{
52+
return__pmd(xchg((pmdval_t*)xp,0));
53+
}
54+
#else
55+
#definenative_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp)
56+
#endif
57+
4958
/*
5059
* Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
5160
* split up the 29 bits of offset into this range:

‎arch/x86/include/asm/pgtable-3level.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ static inline pte_t native_ptep_get_and_clear(pte_t *ptep)
104104
#definenative_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp)
105105
#endif
106106

107+
#ifdefCONFIG_SMP
108+
unionsplit_pmd {
109+
struct {
110+
u32pmd_low;
111+
u32pmd_high;
112+
};
113+
pmd_tpmd;
114+
};
115+
staticinlinepmd_tnative_pmdp_get_and_clear(pmd_t*pmdp)
116+
{
117+
unionsplit_pmdres,*orig= (unionsplit_pmd*)pmdp;
118+
119+
/* xchg acts as a barrier before setting of the high bits */
120+
res.pmd_low=xchg(&orig->pmd_low,0);
121+
res.pmd_high=orig->pmd_high;
122+
orig->pmd_high=0;
123+
124+
returnres.pmd;
125+
}
126+
#else
127+
#definenative_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp)
128+
#endif
129+
107130
/*
108131
* Bits 0, 6 and 7 are taken in the low part of the pte,
109132
* put the 32 bits of offset into the high part.

‎arch/x86/include/asm/pgtable.h‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static inline int pte_young(pte_t pte)
9797
returnpte_flags(pte)&_PAGE_ACCESSED;
9898
}
9999

100+
staticinlineintpmd_young(pmd_tpmd)
101+
{
102+
returnpmd_flags(pmd)&_PAGE_ACCESSED;
103+
}
104+
100105
staticinlineintpte_write(pte_tpte)
101106
{
102107
returnpte_flags(pte)&_PAGE_RW;
@@ -145,6 +150,18 @@ static inline int pmd_large(pmd_t pte)
145150
(_PAGE_PSE |_PAGE_PRESENT);
146151
}
147152

153+
#ifdefCONFIG_TRANSPARENT_HUGEPAGE
154+
staticinlineintpmd_trans_splitting(pmd_tpmd)
155+
{
156+
returnpmd_val(pmd)&_PAGE_SPLITTING;
157+
}
158+
159+
staticinlineintpmd_trans_huge(pmd_tpmd)
160+
{
161+
returnpmd_val(pmd)&_PAGE_PSE;
162+
}
163+
#endif/* CONFIG_TRANSPARENT_HUGEPAGE */
164+
148165
staticinlinepte_tpte_set_flags(pte_tpte,pteval_tset)
149166
{
150167
pteval_tv=native_pte_val(pte);
@@ -219,6 +236,55 @@ static inline pte_t pte_mkspecial(pte_t pte)
219236
returnpte_set_flags(pte,_PAGE_SPECIAL);
220237
}
221238

239+
staticinlinepmd_tpmd_set_flags(pmd_tpmd,pmdval_tset)
240+
{
241+
pmdval_tv=native_pmd_val(pmd);
242+
243+
return__pmd(v |set);
244+
}
245+
246+
staticinlinepmd_tpmd_clear_flags(pmd_tpmd,pmdval_tclear)
247+
{
248+
pmdval_tv=native_pmd_val(pmd);
249+
250+
return__pmd(v& ~clear);
251+
}
252+
253+
staticinlinepmd_tpmd_mkold(pmd_tpmd)
254+
{
255+
returnpmd_clear_flags(pmd,_PAGE_ACCESSED);
256+
}
257+
258+
staticinlinepmd_tpmd_wrprotect(pmd_tpmd)
259+
{
260+
returnpmd_clear_flags(pmd,_PAGE_RW);
261+
}
262+
263+
staticinlinepmd_tpmd_mkdirty(pmd_tpmd)
264+
{
265+
returnpmd_set_flags(pmd,_PAGE_DIRTY);
266+
}
267+
268+
staticinlinepmd_tpmd_mkhuge(pmd_tpmd)
269+
{
270+
returnpmd_set_flags(pmd,_PAGE_PSE);
271+
}
272+
273+
staticinlinepmd_tpmd_mkyoung(pmd_tpmd)
274+
{
275+
returnpmd_set_flags(pmd,_PAGE_ACCESSED);
276+
}
277+
278+
staticinlinepmd_tpmd_mkwrite(pmd_tpmd)
279+
{
280+
returnpmd_set_flags(pmd,_PAGE_RW);
281+
}
282+
283+
staticinlinepmd_tpmd_mknotpresent(pmd_tpmd)
284+
{
285+
returnpmd_clear_flags(pmd,_PAGE_PRESENT);
286+
}
287+
222288
/*
223289
* Mask out unsupported bits in a present pgprot. Non-present pgprots
224290
* can use those bits for other purposes, so leave them be.
@@ -527,6 +593,14 @@ static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
527593
returnres;
528594
}
529595

596+
staticinlinepmd_tnative_local_pmdp_get_and_clear(pmd_t*pmdp)
597+
{
598+
pmd_tres=*pmdp;
599+
600+
native_pmd_clear(pmdp);
601+
returnres;
602+
}
603+
530604
staticinlinevoidnative_set_pte_at(structmm_struct*mm,unsigned longaddr,
531605
pte_t*ptep ,pte_tpte)
532606
{
@@ -616,6 +690,49 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm,
616690

617691
#defineflush_tlb_fix_spurious_fault(vma,address)
618692

693+
#definemk_pmd(page,pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
694+
695+
#define__HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
696+
externintpmdp_set_access_flags(structvm_area_struct*vma,
697+
unsigned longaddress,pmd_t*pmdp,
698+
pmd_tentry,intdirty);
699+
700+
#define__HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
701+
externintpmdp_test_and_clear_young(structvm_area_struct*vma,
702+
unsigned longaddr,pmd_t*pmdp);
703+
704+
#define__HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
705+
externintpmdp_clear_flush_young(structvm_area_struct*vma,
706+
unsigned longaddress,pmd_t*pmdp);
707+
708+
709+
#define__HAVE_ARCH_PMDP_SPLITTING_FLUSH
710+
externvoidpmdp_splitting_flush(structvm_area_struct*vma,
711+
unsigned longaddr,pmd_t*pmdp);
712+
713+
#define__HAVE_ARCH_PMD_WRITE
714+
staticinlineintpmd_write(pmd_tpmd)
715+
{
716+
returnpmd_flags(pmd)&_PAGE_RW;
717+
}
718+
719+
#define__HAVE_ARCH_PMDP_GET_AND_CLEAR
720+
staticinlinepmd_tpmdp_get_and_clear(structmm_struct*mm,unsigned longaddr,
721+
pmd_t*pmdp)
722+
{
723+
pmd_tpmd=native_pmdp_get_and_clear(pmdp);
724+
pmd_update(mm,addr,pmdp);
725+
returnpmd;
726+
}
727+
728+
#define__HAVE_ARCH_PMDP_SET_WRPROTECT
729+
staticinlinevoidpmdp_set_wrprotect(structmm_struct*mm,
730+
unsigned longaddr,pmd_t*pmdp)
731+
{
732+
clear_bit(_PAGE_BIT_RW, (unsigned long*)pmdp);
733+
pmd_update(mm,addr,pmdp);
734+
}
735+
619736
/*
620737
* clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
621738
*

‎arch/x86/include/asm/pgtable_64.h‎

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -182,115 +182,6 @@ extern void cleanup_highmap(void);
182182

183183
#define__HAVE_ARCH_PTE_SAME
184184

185-
#ifdefCONFIG_TRANSPARENT_HUGEPAGE
186-
staticinlineintpmd_trans_splitting(pmd_tpmd)
187-
{
188-
returnpmd_val(pmd)&_PAGE_SPLITTING;
189-
}
190-
191-
staticinlineintpmd_trans_huge(pmd_tpmd)
192-
{
193-
returnpmd_val(pmd)&_PAGE_PSE;
194-
}
195-
#endif/* CONFIG_TRANSPARENT_HUGEPAGE */
196-
197-
#definemk_pmd(page,pgprot) pfn_pmd(page_to_pfn(page), (pgprot))
198-
199-
#define__HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
200-
externintpmdp_set_access_flags(structvm_area_struct*vma,
201-
unsigned longaddress,pmd_t*pmdp,
202-
pmd_tentry,intdirty);
203-
204-
#define__HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
205-
externintpmdp_test_and_clear_young(structvm_area_struct*vma,
206-
unsigned longaddr,pmd_t*pmdp);
207-
208-
#define__HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
209-
externintpmdp_clear_flush_young(structvm_area_struct*vma,
210-
unsigned longaddress,pmd_t*pmdp);
211-
212-
213-
#define__HAVE_ARCH_PMDP_SPLITTING_FLUSH
214-
externvoidpmdp_splitting_flush(structvm_area_struct*vma,
215-
unsigned longaddr,pmd_t*pmdp);
216-
217-
#define__HAVE_ARCH_PMD_WRITE
218-
staticinlineintpmd_write(pmd_tpmd)
219-
{
220-
returnpmd_flags(pmd)&_PAGE_RW;
221-
}
222-
223-
#define__HAVE_ARCH_PMDP_GET_AND_CLEAR
224-
staticinlinepmd_tpmdp_get_and_clear(structmm_struct*mm,unsigned longaddr,
225-
pmd_t*pmdp)
226-
{
227-
pmd_tpmd=native_pmdp_get_and_clear(pmdp);
228-
pmd_update(mm,addr,pmdp);
229-
returnpmd;
230-
}
231-
232-
#define__HAVE_ARCH_PMDP_SET_WRPROTECT
233-
staticinlinevoidpmdp_set_wrprotect(structmm_struct*mm,
234-
unsigned longaddr,pmd_t*pmdp)
235-
{
236-
clear_bit(_PAGE_BIT_RW, (unsigned long*)&pmdp->pmd);
237-
pmd_update(mm,addr,pmdp);
238-
}
239-
240-
staticinlineintpmd_young(pmd_tpmd)
241-
{
242-
returnpmd_flags(pmd)&_PAGE_ACCESSED;
243-
}
244-
245-
staticinlinepmd_tpmd_set_flags(pmd_tpmd,pmdval_tset)
246-
{
247-
pmdval_tv=native_pmd_val(pmd);
248-
249-
returnnative_make_pmd(v |set);
250-
}
251-
252-
staticinlinepmd_tpmd_clear_flags(pmd_tpmd,pmdval_tclear)
253-
{
254-
pmdval_tv=native_pmd_val(pmd);
255-
256-
returnnative_make_pmd(v& ~clear);
257-
}
258-
259-
staticinlinepmd_tpmd_mkold(pmd_tpmd)
260-
{
261-
returnpmd_clear_flags(pmd,_PAGE_ACCESSED);
262-
}
263-
264-
staticinlinepmd_tpmd_wrprotect(pmd_tpmd)
265-
{
266-
returnpmd_clear_flags(pmd,_PAGE_RW);
267-
}
268-
269-
staticinlinepmd_tpmd_mkdirty(pmd_tpmd)
270-
{
271-
returnpmd_set_flags(pmd,_PAGE_DIRTY);
272-
}
273-
274-
staticinlinepmd_tpmd_mkhuge(pmd_tpmd)
275-
{
276-
returnpmd_set_flags(pmd,_PAGE_PSE);
277-
}
278-
279-
staticinlinepmd_tpmd_mkyoung(pmd_tpmd)
280-
{
281-
returnpmd_set_flags(pmd,_PAGE_ACCESSED);
282-
}
283-
284-
staticinlinepmd_tpmd_mkwrite(pmd_tpmd)
285-
{
286-
returnpmd_set_flags(pmd,_PAGE_RW);
287-
}
288-
289-
staticinlinepmd_tpmd_mknotpresent(pmd_tpmd)
290-
{
291-
returnpmd_clear_flags(pmd,_PAGE_PRESENT);
292-
}
293-
294185
#endif/* !__ASSEMBLY__ */
295186

296187
#endif/* _ASM_X86_PGTABLE_64_H */

‎arch/x86/mm/pgtable.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ int pmdp_test_and_clear_young(struct vm_area_struct *vma,
362362

363363
if (pmd_young(*pmdp))
364364
ret=test_and_clear_bit(_PAGE_BIT_ACCESSED,
365-
(unsigned long*)&pmdp->pmd);
365+
(unsigned long*)pmdp);
366366

367367
if (ret)
368368
pmd_update(vma->vm_mm,addr,pmdp);
@@ -404,7 +404,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma,
404404
intset;
405405
VM_BUG_ON(address& ~HPAGE_PMD_MASK);
406406
set= !test_and_set_bit(_PAGE_BIT_SPLITTING,
407-
(unsigned long*)&pmdp->pmd);
407+
(unsigned long*)pmdp);
408408
if (set) {
409409
pmd_update(vma->vm_mm,address,pmdp);
410410
/* need tlb flush only to serialize against gup-fast */

‎include/linux/mm.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ extern unsigned int kobjsize(const void *objp);
102102
#defineVM_NORESERVE0x00200000/* should the VM suppress accounting */
103103
#defineVM_HUGETLB0x00400000/* Huge TLB Page VM */
104104
#defineVM_NONLINEAR0x00800000/* Is non-linear (remap_file_pages) */
105+
#ifndefCONFIG_TRANSPARENT_HUGEPAGE
105106
#defineVM_MAPPED_COPY0x01000000/* T if mapped copy of data (nommu mmap) */
107+
#else
108+
#defineVM_HUGEPAGE0x01000000/* MADV_HUGEPAGE marked this vma */
109+
#endif
106110
#defineVM_INSERTPAGE0x02000000/* The vma has had "vm_insert_page()" done on it */
107111
#defineVM_ALWAYSDUMP0x04000000/* Always include in core dumps */
108112

@@ -111,9 +115,6 @@ extern unsigned int kobjsize(const void *objp);
111115
#defineVM_SAO0x20000000/* Strong Access Ordering (powerpc) */
112116
#defineVM_PFN_AT_MMAP0x40000000/* PFNMAP vma that is fully mapped at mmap time */
113117
#defineVM_MERGEABLE0x80000000/* KSM may merge identical pages */
114-
#ifBITS_PER_LONG>32
115-
#defineVM_HUGEPAGE0x100000000UL/* MADV_HUGEPAGE marked this vma */
116-
#endif
117118

118119
/* Bits set in the VMA until the stack is in its final location */
119120
#defineVM_STACK_INCOMPLETE_SETUP(VM_RAND_READ | VM_SEQ_READ)

‎mm/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ config NOMMU_INITIAL_TRIM_EXCESS
304304

305305
config TRANSPARENT_HUGEPAGE
306306
bool "Transparent Hugepage Support" if EMBEDDED
307-
depends onX86_64 && MMU
307+
depends onX86 && MMU
308308
default y
309309
help
310310
Transparent Hugepages allows the kernel to use huge pages and

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp