Skip to content

Commit ed1f324

Browse files
Christoph Hellwigtorvalds
authored andcommitted
mm: remove map_vm_range
Switch all callers to map_kernel_range, which symmetric to the unmap side (as well as the _noflush versions). Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Cc: Christophe Leroy <christophe.leroy@c-s.fr> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Airlie <airlied@linux.ie> Cc: Gao Xiang <xiang@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Laura Abbott <labbott@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Michael Kelley <mikelley@microsoft.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Robin Murphy <robin.murphy@arm.com> Cc: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: Sumit Semwal <sumit.semwal@linaro.org> Cc: Wei Liu <wei.liu@kernel.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mackerras <paulus@ozlabs.org> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Link: http://lkml.kernel.org/r/20200414131348.444715-17-hch@lst.de Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 60bb446 commit ed1f324

5 files changed

Lines changed: 16 additions & 24 deletions

File tree

‎Documentation/core-api/cachetlb.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Here are the routines, one by one:
213213
there will be no entries in the cache for the kernel address
214214
space for virtual addresses in the range 'start' to 'end-1'.
215215

216-
The first of these two routines is invoked after map_vm_area()
216+
The first of these two routines is invoked after map_kernel_range()
217217
has installed the page table entries. The second is invoked
218218
before unmap_kernel_range() deletes the page table entries.
219219

‎include/linux/vmalloc.h‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ extern struct vm_struct *__get_vm_area_caller(unsigned long size,
168168
extern struct vm_struct *remove_vm_area(const void *addr);
169169
extern struct vm_struct *find_vm_area(const void *addr);
170170

171-
extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
172-
struct page **pages);
173171
#ifdef CONFIG_MMU
174172
extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
175173
pgprot_t prot, struct page **pages);
174+
int map_kernel_range(unsigned long start, unsigned long size, pgprot_t prot,
175+
struct page **pages);
176176
extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
177177
extern void unmap_kernel_range(unsigned long addr, unsigned long size);
178178
static inline void set_vm_flush_reset_perms(void *addr)
@@ -189,14 +189,12 @@ map_kernel_range_noflush(unsigned long start, unsigned long size,
189189
{
190190
return size >> PAGE_SHIFT;
191191
}
192+
#define map_kernel_range map_kernel_range_noflush
192193
static inline void
193194
unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
194195
{
195196
}
196-
static inline void
197-
unmap_kernel_range(unsigned long addr, unsigned long size)
198-
{
199-
}
197+
#define unmap_kernel_range unmap_kernel_range_noflush
200198
static inline void set_vm_flush_reset_perms(void *addr)
201199
{
202200
}

‎mm/vmalloc.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ int map_kernel_range_noflush(unsigned long addr, unsigned long size,
273273
return 0;
274274
}
275275

276-
static int map_kernel_range(unsigned long start, unsigned long size,
277-
pgprot_t prot, struct page **pages)
276+
int map_kernel_range(unsigned long start, unsigned long size, pgprot_t prot,
277+
struct page **pages)
278278
{
279279
int ret;
280280

@@ -2028,16 +2028,6 @@ void unmap_kernel_range(unsigned long addr, unsigned long size)
20282028
flush_tlb_kernel_range(addr, end);
20292029
}
20302030

2031-
int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page **pages)
2032-
{
2033-
unsigned long addr = (unsigned long)area->addr;
2034-
int err;
2035-
2036-
err = map_kernel_range(addr, get_vm_area_size(area), prot, pages);
2037-
2038-
return err > 0 ? 0 : err;
2039-
}
2040-
20412031
static inline void setup_vmalloc_vm_locked(struct vm_struct *vm,
20422032
struct vmap_area *va, unsigned long flags, const void *caller)
20432033
{
@@ -2409,7 +2399,8 @@ void *vmap(struct page **pages, unsigned int count,
24092399
if (!area)
24102400
return NULL;
24112401

2412-
if (map_vm_area(area, prot, pages)) {
2402+
if (map_kernel_range((unsigned long)area->addr, size, prot,
2403+
pages) < 0) {
24132404
vunmap(area->addr);
24142405
return NULL;
24152406
}
@@ -2472,8 +2463,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
24722463
}
24732464
atomic_long_add(area->nr_pages, &nr_vmalloc_pages);
24742465

2475-
if (map_vm_area(area, prot, pages))
2466+
if (map_kernel_range((unsigned long)area->addr, get_vm_area_size(area),
2467+
prot, pages) < 0)
24762468
goto fail;
2469+
24772470
return area->addr;
24782471

24792472
fail:

‎mm/zsmalloc.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,9 @@ static inline void __zs_cpu_down(struct mapping_area *area)
11381138
static inline void *__zs_map_object(struct mapping_area *area,
11391139
struct page *pages[2], int off, int size)
11401140
{
1141-
BUG_ON(map_vm_area(area->vm, PAGE_KERNEL, pages));
1141+
unsigned long addr = (unsigned long)area->vm->addr;
1142+
1143+
BUG_ON(map_kernel_range(addr, PAGE_SIZE * 2, PAGE_KERNEL, pages) < 0);
11421144
area->vm_addr = area->vm->addr;
11431145
return area->vm_addr + off;
11441146
}

‎net/ceph/ceph_common.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ EXPORT_SYMBOL(ceph_compare_options);
190190
* kvmalloc() doesn't fall back to the vmalloc allocator unless flags are
191191
* compatible with (a superset of) GFP_KERNEL. This is because while the
192192
* actual pages are allocated with the specified flags, the page table pages
193-
* are always allocated with GFP_KERNEL. map_vm_area() doesn't even take
194-
* flags because GFP_KERNEL is hard-coded in {p4d,pud,pmd,pte}_alloc().
193+
* are always allocated with GFP_KERNEL.
195194
*
196195
* ceph_kvmalloc() may be called with GFP_KERNEL, GFP_NOFS or GFP_NOIO.
197196
*/

0 commit comments

Comments
 (0)