Re: [PATCH v3 06/10] mm/vma: clean up __vma_enter/exit_locked()

Lorenzo Stoakes
2026-01-23T16:16:30Z

On Thu, Jan 22, 2026 at 12:55:29PM -0800, Andrew Morton wrote:
> On Thu, 22 Jan 2026 12:15:20 -0800 Suren Baghdasaryan <surenb@google.com> wrote:
>
> > > + /* vma should remain attached. */
> > > + if (locked)
> > > + WARN_ON_ONCE(__vma_exit_exclusive_locked(vma));
> >
> > I'm wary of calling functions from WARN_ON_ONCE() statements. If
> > someone decides to replace WARN_ON_ONCE() with VM_WARN_ON_ONCE(), the
> > call will disappear when CONFIG_DEBUG_VM=n. Maybe I'm being paranoid
> > but it's because I have been bitten by that before...
>
> Yes please. The elision is desirable if the function has no side-effects, but
> __vma_exit_exclusive_locked() changes stuff.

Ack will update in this case :)

>
> Someone(tm) should check for this. A pathetically partial grep turns
> up plenty of things:
>
> mm/slab_common.c: if (head && !WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&head_gp_snap)))
> mm/slab_common.c: if (!WARN_ON_ONCE(!poll_state_synchronize_rcu_full(&bnode->gp_snap))) {
> mm/page-writeback.c: WARN_ON_ONCE(atomic_long_add_return(delta,
> mm/page_isolation.c: WARN_ON_ONCE(!pageblock_unisolate_and_move_free_pages(zone, page));
> mm/page_alloc.c: VM_WARN_ONCE(get_pageblock_isolate(page),
> mm/numa_memblks.c: WARN_ON(memblock_clear_hotplug(0, max_addr));
> mm/numa_memblks.c: WARN_ON(memblock_set_node(0, max_addr, &memblock.memory, NUMA_NO_NODE));
> mm/numa_memblks.c: WARN_ON(memblock_set_node(0, max_addr, &memblock.reserved,
> mm/zsmalloc.c: WARN_ON(!zpdesc_trylock(zpdesc));
>

*Adds to todo*

Cheers, Lorenzo