aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/percpu-vm.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c
index 47b47bfbcb66..d9e0b615492e 100644
--- a/mm/percpu-vm.c
+++ b/mm/percpu-vm.c
@@ -22,21 +22,22 @@ static struct page *pcpu_chunk_page(struct pcpu_chunk *chunk,
22/** 22/**
23 * pcpu_get_pages - get temp pages array 23 * pcpu_get_pages - get temp pages array
24 * @chunk: chunk of interest 24 * @chunk: chunk of interest
25 * @may_alloc: may allocate the array
26 * 25 *
27 * Returns pointer to array of pointers to struct page which can be indexed 26 * Returns pointer to array of pointers to struct page which can be indexed
28 * with pcpu_page_idx(). Note that there is only one array and access 27 * with pcpu_page_idx(). Note that there is only one array and accesses
29 * exclusion is the caller's responsibility. 28 * should be serialized by pcpu_alloc_mutex.
30 * 29 *
31 * RETURNS: 30 * RETURNS:
32 * Pointer to temp pages array on success. 31 * Pointer to temp pages array on success.
33 */ 32 */
34static struct page **pcpu_get_pages(struct pcpu_chunk *chunk, bool may_alloc) 33static struct page **pcpu_get_pages(struct pcpu_chunk *chunk_alloc)
35{ 34{
36 static struct page **pages; 35 static struct page **pages;
37 size_t pages_size = pcpu_nr_units * pcpu_unit_pages * sizeof(pages[0]); 36 size_t pages_size = pcpu_nr_units * pcpu_unit_pages * sizeof(pages[0]);
38 37
39 if (!pages && may_alloc) 38 lockdep_assert_held(&pcpu_alloc_mutex);
39
40 if (!pages)
40 pages = pcpu_mem_zalloc(pages_size); 41 pages = pcpu_mem_zalloc(pages_size);
41 return pages; 42 return pages;
42} 43}
@@ -287,7 +288,7 @@ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size)
287 /* need to allocate and map pages, this chunk can't be immutable */ 288 /* need to allocate and map pages, this chunk can't be immutable */
288 WARN_ON(chunk->immutable); 289 WARN_ON(chunk->immutable);
289 290
290 pages = pcpu_get_pages(chunk, true); 291 pages = pcpu_get_pages(chunk);
291 if (!pages) 292 if (!pages)
292 return -ENOMEM; 293 return -ENOMEM;
293 294
@@ -358,7 +359,7 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size)
358 * successful population attempt so the temp pages array must 359 * successful population attempt so the temp pages array must
359 * be available now. 360 * be available now.
360 */ 361 */
361 pages = pcpu_get_pages(chunk, false); 362 pages = pcpu_get_pages(chunk);
362 BUG_ON(!pages); 363 BUG_ON(!pages);
363 364
364 /* unmap and free */ 365 /* unmap and free */