Skip to content

Commit 31c5629

Browse files
petrisakpm00
authored andcommitted
mm: add RCU annotation to pte_offset_map(_lock)
RCU lock is taken by ___pte_offset_map() unless it returns NULL. Add this information to its inline callers to avoid sparse warning about context imbalance in pte_unmap(). Link: https://lkml.kernel.org/r/20241210000604.700710-1-oss@malat.biz Signed-off-by: Petr Malat <oss@malat.biz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 42c4e4b commit 31c5629

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

include/linux/mm.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,15 @@ static inline void pagetable_pte_dtor(struct ptdesc *ptdesc)
30103010
lruvec_stat_sub_folio(folio, NR_PAGETABLE);
30113011
}
30123012

3013-
pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp);
3013+
pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp);
3014+
static inline pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr,
3015+
pmd_t *pmdvalp)
3016+
{
3017+
pte_t *pte;
3018+
3019+
__cond_lock(RCU, pte = ___pte_offset_map(pmd, addr, pmdvalp));
3020+
return pte;
3021+
}
30143022
static inline pte_t *pte_offset_map(pmd_t *pmd, unsigned long addr)
30153023
{
30163024
return __pte_offset_map(pmd, addr, NULL);
@@ -3023,7 +3031,8 @@ static inline pte_t *pte_offset_map_lock(struct mm_struct *mm, pmd_t *pmd,
30233031
{
30243032
pte_t *pte;
30253033

3026-
__cond_lock(*ptlp, pte = __pte_offset_map_lock(mm, pmd, addr, ptlp));
3034+
__cond_lock(RCU, __cond_lock(*ptlp,
3035+
pte = __pte_offset_map_lock(mm, pmd, addr, ptlp)));
30273036
return pte;
30283037
}
30293038

mm/pgtable-generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static unsigned long pmdp_get_lockless_start(void) { return 0; }
279279
static void pmdp_get_lockless_end(unsigned long irqflags) { }
280280
#endif
281281

282-
pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)
282+
pte_t *___pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)
283283
{
284284
unsigned long irqflags;
285285
pmd_t pmdval;

0 commit comments

Comments
 (0)