linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Balbir Singh <balbirs@nvidia.com>
Cc: kernel test robot <lkp@intel.com>,
	oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [akpm-mm:mm-unstable 39/428] include/linux/pgtable.h:235:36: error: expected expression before 'do'
Date: Sat, 13 Sep 2025 17:06:28 -0700	[thread overview]
Message-ID: <20250913170628.e76ed73413b58aef022aba3c@linux-foundation.org> (raw)
In-Reply-To: <b96ea27d-6e8a-40d9-8fa6-677cd8134363@nvidia.com>

On Sun, 14 Sep 2025 08:57:29 +1000 Balbir Singh <balbirs@nvidia.com> wrote:

> On 9/13/25 16:03, Andrew Morton wrote:
> > On Sat, 13 Sep 2025 12:53:27 +0800 kernel test robot <lkp@intel.com> wrote:
> > 
> >> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> >> head:   8ded915c4409a5190b1c9c57c172d62ab5534274
> >> commit: f6748cc302fdca7c486c6098f315bd4174f5c614 [39/428] kasan: Fix warnings caused by use of arch_enter_lazy_mmu_mode()
> >> config: s390-randconfig-002-20250913 (https://download.01.org/0day-ci/archive/20250913/202509131255.x9EfvIGt-lkp@intel.com/config)
> >> compiler: s390-linux-gcc (GCC) 8.5.0
> >> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250913/202509131255.x9EfvIGt-lkp@intel.com/reproduce)
> >>
> >> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> >> the same patch/commit), kindly add following tags
> >> | Reported-by: kernel test robot <lkp@intel.com>
> >> | Closes: https://lore.kernel.org/oe-kbuild-all/202509131255.x9EfvIGt-lkp@intel.com/
> >>
> >> All errors (new ones prefixed by >>):
> >>
> >>    In file included from include/linux/kasan.h:37,
> >>                     from mm/kasan/shadow.c:14:
> >>    mm/kasan/shadow.c: In function 'kasan_populate_vmalloc_pte':
> >>>> include/linux/pgtable.h:235:36: error: expected expression before 'do'
> >>     #define arch_enter_lazy_mmu_mode() do {} while (0)
> >>                                        ^~
> >>    mm/kasan/shadow.c:322:8: note: in expansion of macro 'arch_enter_lazy_mmu_mode'
> >>      (void)arch_enter_lazy_mmu_mode();
> >>            ^~~~~~~~~~~~~~~~~~~~~~~~
> >>    mm/kasan/shadow.c: In function 'kasan_depopulate_vmalloc_pte':
> >>>> include/linux/pgtable.h:235:36: error: expected expression before 'do'
> >>     #define arch_enter_lazy_mmu_mode() do {} while (0)
> >>                                     ^~
> > 
> > Huh, thanks.  Another reason why static inlines are better than macros.
> > 
> >>    mm/kasan/shadow.c:497:8: note: in expansion of macro 'arch_enter_lazy_mmu_mode'
> >>      (void)arch_enter_lazy_mmu_mode();
> >>            ^~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > You can't do that with them!
> > 
> 
> [...]
> 
> AFAICT, The issue I saw and fixed only occurs on top of 
> 
> commit 116191f326bce79aefa0ed540caade5a55fbd33f
> Author: Kevin Brodsky <kevin.brodsky@arm.com>
> Date:   Mon Sep 8 08:39:26 2025 +0100
> 
>     mm: introduce local state for lazy_mmu sections
> 
> Which changes the definition of arch_*_lazy_mmu_mode
> 
> -#define arch_enter_lazy_mmu_mode()     do {} while (0)
> -#define arch_leave_lazy_mmu_mode()     do {} while (0)
> +typedef int lazy_mmu_state_t;
> +
> +#define arch_enter_lazy_mmu_mode()     (LAZY_MMU_DEFAULT)
> +#define arch_leave_lazy_mmu_mode(state)        ((void)(state))
> 

No, this error happens on maainline + this-patch


#define arch_enter_lazy_mmu_mode()	do {} while (0)

plus

	(void)arch_enter_lazy_mmu_mode();

expands to

	(void)do {} while (0)

which is nonsensical.



In fact let's do this:

From: Andrew Morton <akpm@linux-foundation.org>
Subject: include/linux/pgtable.h: convert arch_enter_lazy_mmu_mode() and friends to static inlines
Date: Sat Sep 13 05:03:39 PM PDT 2025

For all the usual reasons, plus a new one.  Calling

	(void)arch_enter_lazy_mmu_mode();

deservedly blows up.

Cc: Balbir Singh <balbirs@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/pgtable.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/include/linux/pgtable.h~include-linux-pgtableh-convert-arch_enter_lazy_mmu_mode-and-friends-to-static-inlines
+++ a/include/linux/pgtable.h
@@ -232,9 +232,9 @@ static inline int pmd_dirty(pmd_t pmd)
  * and the mode cannot be used in interrupt context.
  */
 #ifndef __HAVE_ARCH_ENTER_LAZY_MMU_MODE
-#define arch_enter_lazy_mmu_mode()	do {} while (0)
-#define arch_leave_lazy_mmu_mode()	do {} while (0)
-#define arch_flush_lazy_mmu_mode()	do {} while (0)
+static inline void arch_enter_lazy_mmu_mode(void) {}
+static inline void arch_leave_lazy_mmu_mode(void) {}
+static inline void arch_flush_lazy_mmu_mode(void) {}
 #endif
 
 #ifndef pte_batch_hint
_



      reply	other threads:[~2025-09-14  0:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-13  4:53 kernel test robot
2025-09-13  6:03 ` Andrew Morton
2025-09-13 22:57   ` Balbir Singh
2025-09-14  0:06     ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250913170628.e76ed73413b58aef022aba3c@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=balbirs@nvidia.com \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox