Re: [RFC PATCH] fs: proc: task_mmu: fix sparse warnings

From: Matthew Wilcox
Date: Thu Oct 07 2021 - 15:31:40 EST


On Thu, Oct 07, 2021 at 09:16:36PM +0200, Anders Roxell wrote:
> When building the kernel with sparse enabled 'C=1' the following
> warnings can be seen:
>
> fs/proc/task_mmu.c:587:17: warning: context imbalance in 'smaps_pte_range' - unexpected unlock
> fs/proc/task_mmu.c:1145:28: warning: context imbalance in 'clear_refs_pte_range' - unexpected unlock
> fs/proc/task_mmu.c:1473:28: warning: context imbalance in 'pagemap_pmd_range' - unexpected unlock
> fs/proc/task_mmu.c:1811:28: warning: context imbalance in 'gather_pte_stats' - unexpected unlock
>
> Rework to add __acquire() and __release() to tell sparse that it is all good.

Surely the root problem here is that pmd_trans_huge_lock() isn't
marked with __cond_lock() like, eg, get_locked_pte() is?