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

Commit56993b4

Browse files
Anshuman Khandualtorvalds
Anshuman Khandual
authored andcommitted
mm/sparsemem: enable vmem_altmap support in vmemmap_alloc_block_buf()
There are many instances where vmemap allocation is often switched betweenregular memory and device memory just based on whether altmap is availableor not. vmemmap_alloc_block_buf() is used in various platforms toallocate vmemmap mappings. Lets also enable it to handle altmap baseddevice memory allocation along with existing regular memory allocations.This will help in avoiding the altmap based allocation switch in manyplaces. To summarize there are two different methods to callvmemmap_alloc_block_buf().vmemmap_alloc_block_buf(size, node, NULL) /* Allocate from system RAM */vmemmap_alloc_block_buf(size, node, altmap) /* Allocate from altmap */This converts altmap_alloc_block_buf() into a static function, drops it'sentry from the header and updates Documentation/vm/memory-model.rst.Suggested-by: Robin Murphy <robin.murphy@arm.com>Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Tested-by: Jia He <justin.he@arm.com>Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>Cc: Jonathan Corbet <corbet@lwn.net>Cc: Will Deacon <will@kernel.org>Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>Cc: Paul Mackerras <paulus@samba.org>Cc: Michael Ellerman <mpe@ellerman.id.au>Cc: Dave Hansen <dave.hansen@linux.intel.com>Cc: Andy Lutomirski <luto@kernel.org>Cc: Peter Zijlstra <peterz@infradead.org>Cc: Thomas Gleixner <tglx@linutronix.de>Cc: Ingo Molnar <mingo@redhat.com>Cc: Borislav Petkov <bp@alien8.de>Cc: "H. Peter Anvin" <hpa@zytor.com>Cc: Dan Williams <dan.j.williams@intel.com>Cc: David Hildenbrand <david@redhat.com>Cc: Fenghua Yu <fenghua.yu@intel.com>Cc: Hsin-Yi Wang <hsinyi@chromium.org>Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>Cc: Mark Rutland <mark.rutland@arm.com>Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>Cc: Michal Hocko <mhocko@suse.com>Cc: Mike Rapoport <rppt@linux.ibm.com>Cc: Palmer Dabbelt <palmer@dabbelt.com>Cc: Paul Walmsley <paul.walmsley@sifive.com>Cc: Pavel Tatashin <pasha.tatashin@soleen.com>Cc: Steve Capper <steve.capper@arm.com>Cc: Tony Luck <tony.luck@intel.com>Cc: Yu Zhao <yuzhao@google.com>Link:http://lkml.kernel.org/r/1594004178-8861-3-git-send-email-anshuman.khandual@arm.comSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent1d9cfee commit56993b4

File tree

6 files changed

+20
-25
lines changed

6 files changed

+20
-25
lines changed

‎Documentation/vm/memory-model.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ for persistent memory devices in pre-allocated storage on those
178178
devices. This storage is represented with:c:type:`struct vmem_altmap`
179179
that is eventually passed to vmemmap_populate() through a long chain
180180
of function calls. The vmemmap_populate() implementation may use the
181-
`vmem_altmap` along with:c:func:`altmap_alloc_block_buf` helper to
181+
`vmem_altmap` along with:c:func:`vmemmap_alloc_block_buf` helper to
182182
allocate memory map on the persistent memory device.
183183

184184
ZONE_DEVICE

‎arch/arm64/mm/mmu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
11021102
if (pmd_none(READ_ONCE(*pmdp))) {
11031103
void*p=NULL;
11041104

1105-
p=vmemmap_alloc_block_buf(PMD_SIZE,node);
1105+
p=vmemmap_alloc_block_buf(PMD_SIZE,node,NULL);
11061106
if (!p)
11071107
return-ENOMEM;
11081108

‎arch/powerpc/mm/init_64.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
225225
* fall back to system memory if the altmap allocation fail.
226226
*/
227227
if (altmap&& !altmap_cross_boundary(altmap,start,page_size)) {
228-
p=altmap_alloc_block_buf(page_size,altmap);
228+
p=vmemmap_alloc_block_buf(page_size,node,altmap);
229229
if (!p)
230230
pr_debug("altmap block allocation failed, falling back to system memory");
231231
}
232232
if (!p)
233-
p=vmemmap_alloc_block_buf(page_size,node);
233+
p=vmemmap_alloc_block_buf(page_size,node,NULL);
234234
if (!p)
235235
return-ENOMEM;
236236

‎arch/x86/mm/init_64.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,7 @@ static int __meminit vmemmap_populate_hugepages(unsigned long start,
15151515
if (pmd_none(*pmd)) {
15161516
void*p;
15171517

1518-
if (altmap)
1519-
p=altmap_alloc_block_buf(PMD_SIZE,altmap);
1520-
else
1521-
p=vmemmap_alloc_block_buf(PMD_SIZE,node);
1518+
p=vmemmap_alloc_block_buf(PMD_SIZE,node,altmap);
15221519
if (p) {
15231520
pte_tentry;
15241521

‎include/linux/mm.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,8 +2982,8 @@ pte_t *vmemmap_pte_populate(pmd_t *pmd, unsigned long addr, int node,
29822982
structvmem_altmap*altmap);
29832983
void*vmemmap_alloc_block(unsigned longsize,intnode);
29842984
structvmem_altmap;
2985-
void*vmemmap_alloc_block_buf(unsigned longsize,intnode);
2986-
void*altmap_alloc_block_buf(unsigned longsize,structvmem_altmap*altmap);
2985+
void*vmemmap_alloc_block_buf(unsigned longsize,intnode,
2986+
structvmem_altmap*altmap);
29872987
voidvmemmap_verify(pte_t*,int,unsigned long,unsigned long);
29882988
intvmemmap_populate_basepages(unsigned longstart,unsigned longend,
29892989
intnode,structvmem_altmap*altmap);

‎mm/sparse-vmemmap.c‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ void * __meminit vmemmap_alloc_block(unsigned long size, int node)
6969
__pa(MAX_DMA_ADDRESS));
7070
}
7171

72+
staticvoid*__meminitaltmap_alloc_block_buf(unsigned longsize,
73+
structvmem_altmap*altmap);
74+
7275
/* need to make sure size is all the same during early stage */
73-
void*__meminitvmemmap_alloc_block_buf(unsigned longsize,intnode)
76+
void*__meminitvmemmap_alloc_block_buf(unsigned longsize,intnode,
77+
structvmem_altmap*altmap)
7478
{
75-
void*ptr=sparse_buffer_alloc(size);
79+
void*ptr;
80+
81+
if (altmap)
82+
returnaltmap_alloc_block_buf(size,altmap);
7683

84+
ptr=sparse_buffer_alloc(size);
7785
if (!ptr)
7886
ptr=vmemmap_alloc_block(size,node);
7987
returnptr;
@@ -94,15 +102,8 @@ static unsigned long __meminit vmem_altmap_nr_free(struct vmem_altmap *altmap)
94102
return0;
95103
}
96104

97-
/**
98-
* altmap_alloc_block_buf - allocate pages from the device page map
99-
* @altmap:device page map
100-
* @size:size (in bytes) of the allocation
101-
*
102-
* Allocations are aligned to the size of the request.
103-
*/
104-
void*__meminitaltmap_alloc_block_buf(unsigned longsize,
105-
structvmem_altmap*altmap)
105+
staticvoid*__meminitaltmap_alloc_block_buf(unsigned longsize,
106+
structvmem_altmap*altmap)
106107
{
107108
unsigned longpfn,nr_pfns,nr_align;
108109

@@ -147,10 +148,7 @@ pte_t * __meminit vmemmap_pte_populate(pmd_t *pmd, unsigned long addr, int node,
147148
pte_tentry;
148149
void*p;
149150

150-
if (altmap)
151-
p=altmap_alloc_block_buf(PAGE_SIZE,altmap);
152-
else
153-
p=vmemmap_alloc_block_buf(PAGE_SIZE,node);
151+
p=vmemmap_alloc_block_buf(PAGE_SIZE,node,altmap);
154152
if (!p)
155153
returnNULL;
156154
entry=pfn_pte(__pa(p) >>PAGE_SHIFT,PAGE_KERNEL);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp