On Jul 22, 2022, at 12:08 AM, David Hildenbrand <david@xxxxxxxxxx> wrote: >> +static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma) >> +{ >> + /* >> + * NOTE: we must check this before VM_SOFTDIRTY on soft-dirty >> + * enablements, because when without soft-dirty being compiled in, >> + * VM_SOFTDIRTY is defined as 0x0, then !(vm_flags & VM_SOFTDIRTY) >> + * will be constantly true. >> + */ >> + if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY)) >> + return false; >> + >> + /* >> + * Soft-dirty is kind of special: its tracking is enabled when the >> + * vma flags not set. >> + */ >> + return !(vma->vm_flags & VM_SOFTDIRTY); >> +} > > That will come in handy in other patches I'm cooking. clear_refs_write() also comes to mind as well (for consistency; I see no correctness or performance issue).