* [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() @ 2025-06-07 7:09 Tal Zussman 2025-06-07 7:59 ` David Hildenbrand 0 siblings, 1 reply; 4+ messages in thread From: Tal Zussman @ 2025-06-07 7:09 UTC (permalink / raw) To: Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko Cc: linux-mm, linux-kernel, Tal Zussman This allows the compiler to validate the condition even with CONFIG_DEBUG_VIRTUAL disabled, and aligns VIRTUAL_BUG_ON() with the other macros in mmdebug.h. Signed-off-by: Tal Zussman <tz2294@columbia.edu> --- include/linux/mmdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index a0a3894900ed..012aef40e7a9 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -129,7 +129,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); #ifdef CONFIG_DEBUG_VIRTUAL #define VIRTUAL_BUG_ON(cond) BUG_ON(cond) #else -#define VIRTUAL_BUG_ON(cond) do { } while (0) +#define VIRTUAL_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) #endif #ifdef CONFIG_DEBUG_VM_PGFLAGS --- base-commit: efe99fabeb11b030c89a7dc5a5e7a7558d0dc7ec change-id: 20250607-virtual_bug_on_invalid-81d24b276109 Best regards, -- Tal Zussman <tz2294@columbia.edu> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() 2025-06-07 7:09 [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() Tal Zussman @ 2025-06-07 7:59 ` David Hildenbrand 2025-06-07 16:21 ` Tal Zussman 0 siblings, 1 reply; 4+ messages in thread From: David Hildenbrand @ 2025-06-07 7:59 UTC (permalink / raw) To: Tal Zussman, Andrew Morton, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko Cc: linux-mm, linux-kernel On 07.06.25 09:09, Tal Zussman wrote: > This allows the compiler to validate the condition even with > CONFIG_DEBUG_VIRTUAL disabled, and aligns VIRTUAL_BUG_ON() with the > other macros in mmdebug.h. > In the light of recent discussions, I think we should get rid of VIRTUAL_BUG_ON completely. There are only a hand full of callers, and I am preety sure for most of them VM_WARN_ON is a suitable replacement. > Signed-off-by: Tal Zussman <tz2294@columbia.edu> > --- > include/linux/mmdebug.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h > index a0a3894900ed..012aef40e7a9 100644 > --- a/include/linux/mmdebug.h > +++ b/include/linux/mmdebug.h > @@ -129,7 +129,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi); > #ifdef CONFIG_DEBUG_VIRTUAL > #define VIRTUAL_BUG_ON(cond) BUG_ON(cond) > #else > -#define VIRTUAL_BUG_ON(cond) do { } while (0) > +#define VIRTUAL_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) > #endif > > #ifdef CONFIG_DEBUG_VM_PGFLAGS > > --- > base-commit: efe99fabeb11b030c89a7dc5a5e7a7558d0dc7ec > change-id: 20250607-virtual_bug_on_invalid-81d24b276109 > > Best regards, -- Cheers, David / dhildenb ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() 2025-06-07 7:59 ` David Hildenbrand @ 2025-06-07 16:21 ` Tal Zussman 2025-06-07 18:13 ` David Hildenbrand 0 siblings, 1 reply; 4+ messages in thread From: Tal Zussman @ 2025-06-07 16:21 UTC (permalink / raw) To: David Hildenbrand Cc: Andrew Morton, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kernel On Sat, Jun 7, 2025 at 3:59 AM David Hildenbrand <david@redhat.com> wrote: > On 07.06.25 09:09, Tal Zussman wrote: > > This allows the compiler to validate the condition even with > > CONFIG_DEBUG_VIRTUAL disabled, and aligns VIRTUAL_BUG_ON() with the > > other macros in mmdebug.h. > > > > In the light of recent discussions, I think we should get rid of > VIRTUAL_BUG_ON completely. > > There are only a hand full of callers, and I am preety sure for most of > them VM_WARN_ON is a suitable replacement. Makes sense. However, all of the callers (except for vmalloc) are already gated by CONFIG_DEBUG_VIRTUAL, which doesn't depend on CONFIG_DEBUG_VM, so using VM_WARN_ON_ONCE() would break DEBUG_VIRTUAL on its own. Perhaps it makes sense to convert the non-vmalloc callers to WARN_ON_ONCE() instead so DEBUG_VIRTUAL still works. The vmalloc caller would then become if (IS_ENABLED(CONFIG_DEBUG_VIRTUAL)) WARN_ON_ONCE(...); as opposed to VM_WARN_ON_ONCE(), in order to maintain the existing DEBUG_VIRTUAL behavior. Alternatively, DEBUG_VIRTUAL could be folded into DEBUG_VM, but that seems like a slightly more invasive change... Thanks, Tal ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() 2025-06-07 16:21 ` Tal Zussman @ 2025-06-07 18:13 ` David Hildenbrand 0 siblings, 0 replies; 4+ messages in thread From: David Hildenbrand @ 2025-06-07 18:13 UTC (permalink / raw) To: Tal Zussman Cc: Andrew Morton, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm, linux-kernel On 07.06.25 18:21, Tal Zussman wrote: > On Sat, Jun 7, 2025 at 3:59 AM David Hildenbrand <david@redhat.com> wrote: >> On 07.06.25 09:09, Tal Zussman wrote: >>> This allows the compiler to validate the condition even with >>> CONFIG_DEBUG_VIRTUAL disabled, and aligns VIRTUAL_BUG_ON() with the >>> other macros in mmdebug.h. >>> >> >> In the light of recent discussions, I think we should get rid of >> VIRTUAL_BUG_ON completely. >> >> There are only a hand full of callers, and I am preety sure for most of >> them VM_WARN_ON is a suitable replacement. > > Makes sense. However, all of the callers (except for vmalloc) are already > gated by CONFIG_DEBUG_VIRTUAL, which doesn't depend on CONFIG_DEBUG_VM, so > using VM_WARN_ON_ONCE() would break DEBUG_VIRTUAL on its own. It should either be folded or made dependent on DEBUG_VM > > Perhaps it makes sense to convert the non-vmalloc callers to WARN_ON_ONCE() > instead so DEBUG_VIRTUAL still works. > The vmalloc caller would then become> > if (IS_ENABLED(CONFIG_DEBUG_VIRTUAL)) > WARN_ON_ONCE(...); > > as opposed to VM_WARN_ON_ONCE(), in order to maintain the existing > DEBUG_VIRTUAL behavior. From a quick glimpse, I am not even sure Fedora/RHEL enable it in the debug config (and if so, probably it's not enabled by mistake) I think we can make it depend on DEBUG_VM. > > Alternatively, DEBUG_VIRTUAL could be folded into DEBUG_VM, but that seems > like a slightly more invasive change... I'd start with making it depend on DEBUG_VM. If there is good reason to not fold it, then all VIRTUAL_BUG_ON should be renamed to VIRTUAL_WARN_ON and get defined as VM_WARN_ON. If there is good reason to fold it, then all VIRTUAL_BUG_ON should be replaced by VM_WARN_ON. The only question is what the performance overhead is. I mean, performance with DEBUG_VM is already bad (debug kernels), so not sure if we really care that much. -- Cheers, David / dhildenb ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-07 18:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-06-07 7:09 [PATCH] mm/debug: Use BUILD_BUG_ON_INVALID() for VIRTUAL_BUG_ON() Tal Zussman 2025-06-07 7:59 ` David Hildenbrand 2025-06-07 16:21 ` Tal Zussman 2025-06-07 18:13 ` David Hildenbrand
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox