Re: [PATCH 0/3] mm: fix soft-dirty false positives in mprotect() of large folios

From: Garg, Shivank

Date: Wed Nov 25 2026 - 11:12:38 EST


On Wed, 2026-11-25 at 09:42 -0600, Paul Gofman wrote:
> On 11/25/26 07:43, David Hildenbrand (Arm) wrote:
> > On 11/25/26 14:32, Shivank Garg wrote:
> > > mprotect() handles the PTEs of a large folio as one batch, and marks the
> > > whole batch dirty with pte_mkdirty() if any of its PTEs is dirty. On
> > > x86, powerpc, riscv and s390, pte_mkdirty() also sets the soft-dirty
> > > bit, so after clear_refs, mprotect() marks unwritten pages soft-dirty.
> > > With 64K mTHP on x86-64, all 240 unwritten pages of a 1MiB region are
> > > reported soft-dirty; with my fix, none are.
> > Why do we care? Just over-indicate soft-dirty. It's valid, and the whole feature
> > is full of holes and buggy as hell.
> >
> Do I understand correctly that these issues only affect the old soft
> dirty feature and not UFFD WP async (UFFD_FEATURE_WP_ASYNC)?
> Over-indicating written pages with the newer UFFD support is not
> expected and Wine usage of the feature requires that. But I guess it is
> not what is concerned here?

Yes, right. This only affect the soft-dirty bit, and not uffd-wp feature.