Re: [PATCH v2 6/6] mm: constify the pte_offset_map_ro_nolock() return value

"Christophe Leroy (CS GROUP)" <[email protected]>
Newsgroups gmane.linux.ports.ppc.embedded
Message-ID <595fe323-59d3-4f4a-92a3-ac5d67b7461b__4406.78204629279$1785909507$gmane$org@kernel.org>

Le 04/08/2026 à 21:22, Pedro Falcato a écrit :
> On Tue, Aug 04, 2026 at 12:22:19PM +0100, Lorenzo Stoakes (ARM) wrote:
> 
>>
>>>   			if (!pte) {
>>>   				mmap_read_unlock(mm);
>>>   				result = SCAN_NO_PTE_TABLE;
>>> diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
>>> index b91b1a98029c..2cfc6e608ef4 100644
>>> --- a/mm/pgtable-generic.c
>>> +++ b/mm/pgtable-generic.c
>>> @@ -308,8 +308,8 @@ pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp)
>>>   	return NULL;
>>>   }
>>>
>>> -pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
>>> -				unsigned long addr, spinlock_t **ptlp)
>>> +const pte_t *pte_offset_map_ro_nolock(struct mm_struct *mm, pmd_t *pmd,
>>
>> Can pmd be const too?
> 
> I was going to say "yes but then pmdp_get() also needs to be constfified" but
> actually no, it can't:
> 
> pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp) {
>          if (unlikely(pmd_bad(pmdval))) {
>                  pmd_clear_bad(pmd);
>                  goto nomap;
>          }
> }
> 
> so PTE mapping actually needs to write to the pmdp if the pmd looks bad.
> Tricky stuff :)

But if pmd is const, can it be bad at all ?

Christophe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.