[PATCH v2 2/4] arm64: mm: Batch dsb and isb when populating pgtables

Mark Rutland mark.rutland at arm.com
Wed Apr 10 04:06:04 PDT 2024


On Wed, Apr 10, 2024 at 11:25:10AM +0100, Ryan Roberts wrote:
> On 10/04/2024 11:06, Mark Rutland wrote:
> > On Thu, Apr 04, 2024 at 03:33:06PM +0100, Ryan Roberts wrote:
[> >> @@ -234,6 +238,13 @@ static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr,
> >>  	} while (addr = next, addr != end);
> >>  
> >>  	pte_clear_fixmap();
> >> +
> >> +	/*
> >> +	 * Ensure all previous pgtable writes are visible to the table walker.
> >> +	 * See init_pte().
> >> +	 */
> >> +	dsb(ishst);
> >> +	isb();
> > 
> > Hmm... currently the call to pte_clear_fixmap() alone should be sufficient,
> > since that needs to update the PTE for the fixmap slot, then do maintenance for
> > that.
> 
> Yes, true...
> 
> > 
> > So we could avoid the addition of the dsb+isb here, and have a comment:
> > 
> > 	/*
> > 	 * Note: barriers and maintenance necessary to clear the fixmap slot
> > 	 * ensure that all previous pgtable writes are visible to the table
> > 	 * walker.
> > 	 */
> > 	pte_clear_fixmap();
> > 
> > ... which'd be fine as long as we keep this fixmap clearing rather than trying
> > to do that lazily as in patch 4.
> 
> But it isn't patch 4 that breaks it, it's patch 3. Once we have abstracted
> pte_clear_fixmap() into the ops->unmap() call, for the "late" ops, unmap is a
> noop.

Ah, yep; I hadn't spotted that yet.

> I guess the best solution there would be to require that unmap() always
> issues these barriers.
> 
> I'll do as you suggest for this patch. If we want to keep patch 3, then I'll add
> the barriers for all unmap() impls.

Thanks. It's going to take me a bit longer to chew through patches 3 and 4, but
I will try to get through those soon.

For now a slightly simpler option would be to have patch 3 introduce the
DSB+ISB as above rather than in each of the unmap() impls.

Mark.



More information about the linux-arm-kernel mailing list