Commit 9487ca60 authored by Mike Kravetz's avatar Mike Kravetz Committed by Linus Torvalds

hugetlb: add lockdep_assert_held() calls for hugetlb_lock

After making hugetlb lock irq safe and separating some functionality
done under the lock, add some lockdep_assert_held to help verify
locking.

Link: https://lkml.kernel.org/r/20210409205254.242291-9-mike.kravetz@oracle.comSigned-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Cc: Barry Song <song.bao.hua@hisilicon.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: HORIGUCHI NAOYA <naoya.horiguchi@nec.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent db71ef79
...@@ -1069,6 +1069,8 @@ static bool vma_has_reserves(struct vm_area_struct *vma, long chg) ...@@ -1069,6 +1069,8 @@ static bool vma_has_reserves(struct vm_area_struct *vma, long chg)
static void enqueue_huge_page(struct hstate *h, struct page *page) static void enqueue_huge_page(struct hstate *h, struct page *page)
{ {
int nid = page_to_nid(page); int nid = page_to_nid(page);
lockdep_assert_held(&hugetlb_lock);
list_move(&page->lru, &h->hugepage_freelists[nid]); list_move(&page->lru, &h->hugepage_freelists[nid]);
h->free_huge_pages++; h->free_huge_pages++;
h->free_huge_pages_node[nid]++; h->free_huge_pages_node[nid]++;
...@@ -1080,6 +1082,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) ...@@ -1080,6 +1082,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid)
struct page *page; struct page *page;
bool nocma = !!(current->flags & PF_MEMALLOC_NOCMA); bool nocma = !!(current->flags & PF_MEMALLOC_NOCMA);
lockdep_assert_held(&hugetlb_lock);
list_for_each_entry(page, &h->hugepage_freelists[nid], lru) { list_for_each_entry(page, &h->hugepage_freelists[nid], lru) {
if (nocma && is_migrate_cma_page(page)) if (nocma && is_migrate_cma_page(page))
continue; continue;
...@@ -1351,6 +1354,7 @@ static void remove_hugetlb_page(struct hstate *h, struct page *page, ...@@ -1351,6 +1354,7 @@ static void remove_hugetlb_page(struct hstate *h, struct page *page,
VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page); VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page);
VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page); VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page);
lockdep_assert_held(&hugetlb_lock);
if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
return; return;
...@@ -1701,6 +1705,7 @@ static struct page *remove_pool_huge_page(struct hstate *h, ...@@ -1701,6 +1705,7 @@ static struct page *remove_pool_huge_page(struct hstate *h,
int nr_nodes, node; int nr_nodes, node;
struct page *page = NULL; struct page *page = NULL;
lockdep_assert_held(&hugetlb_lock);
for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) {
/* /*
* If we're returning unused surplus pages, only examine * If we're returning unused surplus pages, only examine
...@@ -1950,6 +1955,7 @@ static int gather_surplus_pages(struct hstate *h, long delta) ...@@ -1950,6 +1955,7 @@ static int gather_surplus_pages(struct hstate *h, long delta)
long needed, allocated; long needed, allocated;
bool alloc_ok = true; bool alloc_ok = true;
lockdep_assert_held(&hugetlb_lock);
needed = (h->resv_huge_pages + delta) - h->free_huge_pages; needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
if (needed <= 0) { if (needed <= 0) {
h->resv_huge_pages += delta; h->resv_huge_pages += delta;
...@@ -2043,6 +2049,7 @@ static void return_unused_surplus_pages(struct hstate *h, ...@@ -2043,6 +2049,7 @@ static void return_unused_surplus_pages(struct hstate *h,
struct page *page; struct page *page;
LIST_HEAD(page_list); LIST_HEAD(page_list);
lockdep_assert_held(&hugetlb_lock);
/* Uncommit the reservation */ /* Uncommit the reservation */
h->resv_huge_pages -= unused_resv_pages; h->resv_huge_pages -= unused_resv_pages;
...@@ -2530,6 +2537,7 @@ static void try_to_free_low(struct hstate *h, unsigned long count, ...@@ -2530,6 +2537,7 @@ static void try_to_free_low(struct hstate *h, unsigned long count,
int i; int i;
LIST_HEAD(page_list); LIST_HEAD(page_list);
lockdep_assert_held(&hugetlb_lock);
if (hstate_is_gigantic(h)) if (hstate_is_gigantic(h))
return; return;
...@@ -2571,6 +2579,7 @@ static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed, ...@@ -2571,6 +2579,7 @@ static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed,
{ {
int nr_nodes, node; int nr_nodes, node;
lockdep_assert_held(&hugetlb_lock);
VM_BUG_ON(delta != -1 && delta != 1); VM_BUG_ON(delta != -1 && delta != 1);
if (delta < 0) { if (delta < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment