linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlb_cgroup: use lockdep_assert_held rather than spin_is_locked
@ 2014-08-12 13:23 Michal Hocko
  2014-08-12 15:43 ` Aneesh Kumar K.V
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Hocko @ 2014-08-12 13:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Aneesh Kumar K.V

spin_lock may be an empty struct for !SMP configurations and so
arch_spin_is_locked may return unconditional 0 and trigger the VM_BUG_ON
even when the lock is held.

Replace spin_is_locked by lockdep_assert_held. We will not BUG anymore
but it is questionable whether crashing makes a lot of sense in the
uncharge path. Uncharge happens after the last page reference was
released so nobody should touch the page and the function doesn't update
any shared state except for res counter which uses synchronization of
its own.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/hugetlb_cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 9aae6f47433f..9edf189a5ef3 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -217,7 +217,7 @@ void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
 
 	if (hugetlb_cgroup_disabled())
 		return;
-	VM_BUG_ON(!spin_is_locked(&hugetlb_lock));
+	lockdep_assert_held(&hugetlb_lock);
 	h_cg = hugetlb_cgroup_from_page(page);
 	if (unlikely(!h_cg))
 		return;
-- 
2.1.0.rc1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hugetlb_cgroup: use lockdep_assert_held rather than spin_is_locked
  2014-08-12 13:23 [PATCH] hugetlb_cgroup: use lockdep_assert_held rather than spin_is_locked Michal Hocko
@ 2014-08-12 15:43 ` Aneesh Kumar K.V
  0 siblings, 0 replies; 2+ messages in thread
From: Aneesh Kumar K.V @ 2014-08-12 15:43 UTC (permalink / raw)
  To: Michal Hocko, Andrew Morton; +Cc: linux-mm, linux-kernel

Michal Hocko <mhocko@suse.cz> writes:

> spin_lock may be an empty struct for !SMP configurations and so
> arch_spin_is_locked may return unconditional 0 and trigger the VM_BUG_ON
> even when the lock is held.
>
> Replace spin_is_locked by lockdep_assert_held. We will not BUG anymore
> but it is questionable whether crashing makes a lot of sense in the
> uncharge path. Uncharge happens after the last page reference was
> released so nobody should touch the page and the function doesn't update
> any shared state except for res counter which uses synchronization of
> its own.

We do update the hugepage's hugetlb cgroup details. But as you mentioned,
this should not be an issue because we are in hugepage free.

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

>
> Signed-off-by: Michal Hocko <mhocko@suse.cz>
> ---
>  mm/hugetlb_cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
> index 9aae6f47433f..9edf189a5ef3 100644
> --- a/mm/hugetlb_cgroup.c
> +++ b/mm/hugetlb_cgroup.c
> @@ -217,7 +217,7 @@ void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
>
>  	if (hugetlb_cgroup_disabled())
>  		return;
> -	VM_BUG_ON(!spin_is_locked(&hugetlb_lock));
> +	lockdep_assert_held(&hugetlb_lock);
>  	h_cg = hugetlb_cgroup_from_page(page);
>  	if (unlikely(!h_cg))
>  		return;
> -- 
> 2.1.0.rc1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-12 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-12 13:23 [PATCH] hugetlb_cgroup: use lockdep_assert_held rather than spin_is_locked Michal Hocko
2014-08-12 15:43 ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).