* [PATCH v1 1/1] mm/page_alloc: Mark has_unaccepted_memory() with __maybe_unused
@ 2024-09-05 17:15 Andy Shevchenko
2024-09-05 21:22 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-05 17:15 UTC (permalink / raw)
To: Andrew Morton, linux-mm, linux-kernel, llvm
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
Andy Shevchenko
When has_unaccepted_memory() is unused, it prevents kernel builds
with clang, `make W=1` and CONFIG_WERROR=y:
mm/page_alloc.c:7036:20: error: unused function 'has_unaccepted_memory' [-Werror,-Wunused-function]
7036 | static inline bool has_unaccepted_memory(void)
| ^~~~~~~~~~~~~~~~~~~~~
Fix this by marking it with __maybe_unused (all cases for the sake of
symmetry).
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
inline functions for W=1 build").
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
mm/page_alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c565de8f48e9..3b47f1b17ae5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6990,7 +6990,7 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order)
return ret;
}
-static inline bool has_unaccepted_memory(void)
+static inline __maybe_unused bool has_unaccepted_memory(void)
{
return static_branch_unlikely(&zones_with_unaccepted_pages);
}
@@ -7033,7 +7033,7 @@ static bool cond_accept_memory(struct zone *zone, unsigned int order)
return false;
}
-static inline bool has_unaccepted_memory(void)
+static inline __maybe_unused bool has_unaccepted_memory(void)
{
return false;
}
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] mm/page_alloc: Mark has_unaccepted_memory() with __maybe_unused
2024-09-05 17:15 [PATCH v1 1/1] mm/page_alloc: Mark has_unaccepted_memory() with __maybe_unused Andy Shevchenko
@ 2024-09-05 21:22 ` Andrew Morton
2024-09-05 22:05 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2024-09-05 21:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-mm, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Thu, 5 Sep 2024 20:15:53 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> When has_unaccepted_memory() is unused, it prevents kernel builds
> with clang, `make W=1` and CONFIG_WERROR=y:
>
> mm/page_alloc.c:7036:20: error: unused function 'has_unaccepted_memory' [-Werror,-Wunused-function]
> 7036 | static inline bool has_unaccepted_memory(void)
> | ^~~~~~~~~~~~~~~~~~~~~
>
> Fix this by marking it with __maybe_unused (all cases for the sake of
> symmetry).
>
> See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> inline functions for W=1 build").
>
has_unaccepted_memory() has no callers if CONFIG_UNACCEPTED_MEMORY=n.
Can't we do this better thing?
--- a/mm/page_alloc.c~a
+++ a/mm/page_alloc.c
@@ -288,7 +288,6 @@ EXPORT_SYMBOL(nr_online_nodes);
static bool page_contains_unaccepted(struct page *page, unsigned int order);
static void accept_page(struct page *page, unsigned int order);
static bool cond_accept_memory(struct zone *zone, unsigned int order);
-static inline bool has_unaccepted_memory(void);
static bool __free_unaccepted(struct page *page);
int page_group_by_mobility_disabled __read_mostly;
@@ -6963,6 +6962,11 @@ static bool try_to_accept_memory_one(str
return true;
}
+static inline bool has_unaccepted_memory(void)
+{
+ return static_branch_unlikely(&zones_with_unaccepted_pages);
+}
+
static bool cond_accept_memory(struct zone *zone, unsigned int order)
{
long to_accept;
@@ -6990,11 +6994,6 @@ static bool cond_accept_memory(struct zo
return ret;
}
-static inline bool has_unaccepted_memory(void)
-{
- return static_branch_unlikely(&zones_with_unaccepted_pages);
-}
-
static bool __free_unaccepted(struct page *page)
{
struct zone *zone = page_zone(page);
@@ -7032,11 +7031,6 @@ static bool cond_accept_memory(struct zo
{
return false;
}
-
-static inline bool has_unaccepted_memory(void)
-{
- return false;
-}
static bool __free_unaccepted(struct page *page)
{
_
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] mm/page_alloc: Mark has_unaccepted_memory() with __maybe_unused
2024-09-05 21:22 ` Andrew Morton
@ 2024-09-05 22:05 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-05 22:05 UTC (permalink / raw)
To: Andrew Morton
Cc: Andy Shevchenko, linux-mm, linux-kernel, llvm, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
Thu, Sep 05, 2024 at 02:22:20PM -0700, Andrew Morton kirjoitti:
> On Thu, 5 Sep 2024 20:15:53 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > When has_unaccepted_memory() is unused, it prevents kernel builds
> > with clang, `make W=1` and CONFIG_WERROR=y:
> >
> > mm/page_alloc.c:7036:20: error: unused function 'has_unaccepted_memory' [-Werror,-Wunused-function]
> > 7036 | static inline bool has_unaccepted_memory(void)
> > | ^~~~~~~~~~~~~~~~~~~~~
> >
> > Fix this by marking it with __maybe_unused (all cases for the sake of
> > symmetry).
> >
> > See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> > inline functions for W=1 build").
>
> has_unaccepted_memory() has no callers if CONFIG_UNACCEPTED_MEMORY=n.
> Can't we do this better thing?
Sure! Please, use your patch, I'm fine with that
Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-05 22:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-05 17:15 [PATCH v1 1/1] mm/page_alloc: Mark has_unaccepted_memory() with __maybe_unused Andy Shevchenko
2024-09-05 21:22 ` Andrew Morton
2024-09-05 22:05 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox