All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next v2] mm/mmap_lock: fix warning when CONFIG_TRACING is not defined
@ 2021-05-31  3:34 Bixuan Cui
  2021-05-31 22:02 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Bixuan Cui @ 2021-05-31  3:34 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, willy, Bixuan Cui

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 3367 bytes --]

Fix the warning: [-Wunused-function]
mm/mmap_lock.c:157:20: warning: ‘get_mm_memcg_path’ defined but not used
 static const char *get_mm_memcg_path(struct mm_struct *mm)
                    ^~~~~~~~~~~~~~~~~

Move get_mm_memcg_path() into #ifdef CONFIG_TRACING.

Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
Acked-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
Changes in v2:
Move get_mm_memcg_path() into #ifdef CONFIG_TRACING to fix the warning.

 mm/mmap_lock.c | 60 ++++++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 29 deletions(-)

diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
index 03ee85c696ef..29e99af73144 100644
--- a/mm/mmap_lock.c
+++ b/mm/mmap_lock.c
@@ -142,6 +142,37 @@ static inline void put_memcg_path_buf(void)
 	rcu_read_unlock();
 }
 
+#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
+	do {                                                                   \
+		const char *memcg_path;                                        \
+		preempt_disable();                                             \
+		memcg_path = get_mm_memcg_path(mm);                            \
+		trace_mmap_lock_##type(mm,                                     \
+				       memcg_path != NULL ? memcg_path : "",   \
+				       ##__VA_ARGS__);                         \
+		if (likely(memcg_path != NULL))                                \
+			put_memcg_path_buf();                                  \
+		preempt_enable();                                              \
+	} while (0)
+
+#else /* !CONFIG_MEMCG */
+
+int trace_mmap_lock_reg(void)
+{
+	return 0;
+}
+
+void trace_mmap_lock_unreg(void)
+{
+}
+
+#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
+	trace_mmap_lock_##type(mm, "", ##__VA_ARGS__)
+
+#endif /* CONFIG_MEMCG */
+
+#ifdef CONFIG_TRACING
+#ifdef CONFIG_MEMCG
 /*
  * Write the given mm_struct's memcg path to a percpu buffer, and return a
  * pointer to it. If the path cannot be determined, or no buffer was available
@@ -175,37 +206,8 @@ static const char *get_mm_memcg_path(struct mm_struct *mm)
 out:
 	return buf;
 }
-
-#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
-	do {                                                                   \
-		const char *memcg_path;                                        \
-		preempt_disable();                                             \
-		memcg_path = get_mm_memcg_path(mm);                            \
-		trace_mmap_lock_##type(mm,                                     \
-				       memcg_path != NULL ? memcg_path : "",   \
-				       ##__VA_ARGS__);                         \
-		if (likely(memcg_path != NULL))                                \
-			put_memcg_path_buf();                                  \
-		preempt_enable();                                              \
-	} while (0)
-
-#else /* !CONFIG_MEMCG */
-
-int trace_mmap_lock_reg(void)
-{
-	return 0;
-}
-
-void trace_mmap_lock_unreg(void)
-{
-}
-
-#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
-	trace_mmap_lock_##type(mm, "", ##__VA_ARGS__)
-
 #endif /* CONFIG_MEMCG */
 
-#ifdef CONFIG_TRACING
 /*
  * Trace calls must be in a separate file, as otherwise there's a circular
  * dependency between linux/mmap_lock.h and trace/events/mmap_lock.h.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next v2] mm/mmap_lock: fix warning when CONFIG_TRACING is not defined
  2021-05-31  3:34 [PATCH -next v2] mm/mmap_lock: fix warning when CONFIG_TRACING is not defined Bixuan Cui
@ 2021-05-31 22:02 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2021-05-31 22:02 UTC (permalink / raw)
  To: Bixuan Cui; +Cc: linux-mm, linux-kernel, willy, Mel Gorman

On Mon, 31 May 2021 11:34:26 +0800 Bixuan Cui <cuibixuan@huawei.com> wrote:

> Fix the warning: [-Wunused-function]
> mm/mmap_lock.c:157:20: warning: ‘get_mm_memcg_path’ defined but not used
>  static const char *get_mm_memcg_path(struct mm_struct *mm)
>                     ^~~~~~~~~~~~~~~~~
> 
> Move get_mm_memcg_path() into #ifdef CONFIG_TRACING.

Thanks, I queued this as a fix against Mel's "mm/mmap_lock: remove dead
code for !CONFIG_TRACING configurations".


>  mm/mmap_lock.c | 60 ++++++++++++++++++++++++++------------------------
>  1 file changed, 31 insertions(+), 29 deletions(-)
> 
> diff --git a/mm/mmap_lock.c b/mm/mmap_lock.c
> index 03ee85c696ef..29e99af73144 100644
> --- a/mm/mmap_lock.c
> +++ b/mm/mmap_lock.c
> @@ -142,6 +142,37 @@ static inline void put_memcg_path_buf(void)
>  	rcu_read_unlock();
>  }
>  
> +#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
> +	do {                                                                   \
> +		const char *memcg_path;                                        \
> +		preempt_disable();                                             \
> +		memcg_path = get_mm_memcg_path(mm);                            \
> +		trace_mmap_lock_##type(mm,                                     \
> +				       memcg_path != NULL ? memcg_path : "",   \
> +				       ##__VA_ARGS__);                         \
> +		if (likely(memcg_path != NULL))                                \
> +			put_memcg_path_buf();                                  \
> +		preempt_enable();                                              \
> +	} while (0)
> +
> +#else /* !CONFIG_MEMCG */
> +
> +int trace_mmap_lock_reg(void)
> +{
> +	return 0;
> +}
> +
> +void trace_mmap_lock_unreg(void)
> +{
> +}
> +
> +#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
> +	trace_mmap_lock_##type(mm, "", ##__VA_ARGS__)
> +
> +#endif /* CONFIG_MEMCG */
> +
> +#ifdef CONFIG_TRACING
> +#ifdef CONFIG_MEMCG
>  /*
>   * Write the given mm_struct's memcg path to a percpu buffer, and return a
>   * pointer to it. If the path cannot be determined, or no buffer was available
> @@ -175,37 +206,8 @@ static const char *get_mm_memcg_path(struct mm_struct *mm)
>  out:
>  	return buf;
>  }
> -
> -#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
> -	do {                                                                   \
> -		const char *memcg_path;                                        \
> -		preempt_disable();                                             \
> -		memcg_path = get_mm_memcg_path(mm);                            \
> -		trace_mmap_lock_##type(mm,                                     \
> -				       memcg_path != NULL ? memcg_path : "",   \
> -				       ##__VA_ARGS__);                         \
> -		if (likely(memcg_path != NULL))                                \
> -			put_memcg_path_buf();                                  \
> -		preempt_enable();                                              \
> -	} while (0)
> -
> -#else /* !CONFIG_MEMCG */
> -
> -int trace_mmap_lock_reg(void)
> -{
> -	return 0;
> -}
> -
> -void trace_mmap_lock_unreg(void)
> -{
> -}
> -
> -#define TRACE_MMAP_LOCK_EVENT(type, mm, ...)                                   \
> -	trace_mmap_lock_##type(mm, "", ##__VA_ARGS__)
> -
>  #endif /* CONFIG_MEMCG */
>  
> -#ifdef CONFIG_TRACING
>  /*
>   * Trace calls must be in a separate file, as otherwise there's a circular
>   * dependency between linux/mmap_lock.h and trace/events/mmap_lock.h.
> -- 
> 2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-31 22:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31  3:34 [PATCH -next v2] mm/mmap_lock: fix warning when CONFIG_TRACING is not defined Bixuan Cui
2021-05-31 22:02 ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.