mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
mm/percpu: make cached pages lookup explicit
pcpu_depopulate_chunk() only needs the temporary pages array that was already allocated by an earlier successful population attempt. Passing GFP_KERNEL to pcpu_get_pages() in this path is misleading because the depopulation path is not expected to allocate the array. Teach pcpu_get_pages() to treat a zero gfp mask as a cached-only lookup and add pcpu_get_pages_cached() for that use case. This keeps allocation on the populate path tied to the caller supplied GFP mask while making the depopulate path's dependency on the cached array explicit. Link: https://lore.kernel.org/20260618130414.96383-4-kaitao.cheng@linux.dev Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn> Suggested-by: Dennis Zhou <dennis@kernel.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Christoph Lameter <cl@gentwo.org> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Shivam Kalra <shivamkalra98@zohomail.in> Cc: Tejun Heo <tj@kernel.org> Cc: Uladzislau Rezki (Sony) <urezki@gmail.com> Cc: Vlastimil Babka <vbabka@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
881adc51b2
commit
17fcdd8699
@@ -21,7 +21,8 @@ static struct page *pcpu_chunk_page(struct pcpu_chunk *chunk,
|
||||
|
||||
/**
|
||||
* pcpu_get_pages - get temp pages array
|
||||
* @gfp: allocation flags passed to the underlying allocator
|
||||
* @gfp: allocation flags passed to the underlying allocator, 0 to only
|
||||
* return the cached array
|
||||
*
|
||||
* Returns pointer to array of pointers to struct page which can be indexed
|
||||
* with pcpu_page_idx(). Note that there is only one array and accesses
|
||||
@@ -37,11 +38,16 @@ static struct page **pcpu_get_pages(gfp_t gfp)
|
||||
|
||||
lockdep_assert_held(&pcpu_alloc_mutex);
|
||||
|
||||
if (!pages)
|
||||
if (!pages && gfp)
|
||||
pages = pcpu_mem_zalloc(pages_size, gfp);
|
||||
return pages;
|
||||
}
|
||||
|
||||
static struct page **pcpu_get_pages_cached(void)
|
||||
{
|
||||
return pcpu_get_pages(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* pcpu_free_pages - free pages which were allocated for @chunk
|
||||
* @chunk: chunk pages were allocated for
|
||||
@@ -333,7 +339,7 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk,
|
||||
* successful population attempt so the temp pages array must
|
||||
* be available now.
|
||||
*/
|
||||
pages = pcpu_get_pages(GFP_KERNEL);
|
||||
pages = pcpu_get_pages_cached();
|
||||
BUG_ON(!pages);
|
||||
|
||||
/* unmap and free */
|
||||
|
||||
Reference in New Issue
Block a user