aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-09-02 14:46:01 -0400
committerTejun Heo <tj@kernel.org>2014-09-02 14:46:01 -0400
commitcdb4cba5a3c9fa27240d04f4f8dad316b10d995b (patch)
tree6238aeb94660eda94e9bb37f227a6531bb4a8e22
parentfbbb7f4e149f6dd19a8dbebc9fa5c5b72173c6de (diff)
percpu: remove @may_alloc from pcpu_get_pages()
pcpu_get_pages() creates the temp pages array if not already allocated and returns the pointer to it. As the function is called from both [de]population paths and depopulation can only happen after at least one successful population, the param doesn't make any difference - the allocation will always happen on the population path anyway. Remove @may_alloc from pcpu_get_pages(). Also, add an lockdep assertion pcpu_alloc_mutex instead of vaguely stating that the exclusion is the caller's responsibility. Signed-off-by: Tejun Heo <tj@kernel.org>
-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 */