mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
@ 2024-10-31  7:27 Qi Xi
  2024-11-01  1:52 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Qi Xi @ 2024-10-31  7:27 UTC (permalink / raw)
  To: bobo.shaobowang, xiqi2, bhe, vgoyal, dyoung, holzheu, akpm,
	kexec, linux-fsdevel
  Cc: linux-kernel

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
is defined but not used:

>> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

Fix this by declaring it __maybe_unused.

Fixes: 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202410301936.GcE8yUos-lkp@intel.com/
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
 fs/proc/vmcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 1fb213f379a5..9651f105c25b 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -455,7 +455,7 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
+static const struct vm_operations_struct __maybe_unused vmcore_mmap_ops = {
 	.fault = mmap_vmcore_fault,
 };
 
-- 
2.33.0


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

* Re: [PATCH] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
  2024-10-31  7:27 [PATCH] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops' Qi Xi
@ 2024-11-01  1:52 ` Andrew Morton
  2024-11-01  3:23   ` [PATCH v2] " Qi Xi
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2024-11-01  1:52 UTC (permalink / raw)
  To: Qi Xi
  Cc: bobo.shaobowang, bhe, vgoyal, dyoung, holzheu, kexec,
	linux-fsdevel, linux-kernel

On Thu, 31 Oct 2024 15:27:46 +0800 Qi Xi <xiqi2@huawei.com> wrote:

> When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
> is defined but not used:
> 
> >> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
>      458 | static const struct vm_operations_struct vmcore_mmap_ops = {
> 
> Fix this by declaring it __maybe_unused.
> 

It's better to move the definition inside #ifdef CONFIG_MMU, perhaps this:

--- a/fs/proc/vmcore.c~a
+++ a/fs/proc/vmcore.c
@@ -457,10 +457,6 @@ static vm_fault_t mmap_vmcore_fault(stru
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
-	.fault = mmap_vmcore_fault,
-};
-
 /**
  * vmcore_alloc_buf - allocate buffer in vmalloc memory
  * @size: size of buffer
@@ -488,6 +484,11 @@ static inline char *vmcore_alloc_buf(siz
  * virtually contiguous user-space in ELF layout.
  */
 #ifdef CONFIG_MMU
+
+static const struct vm_operations_struct vmcore_mmap_ops = {
+	.fault = mmap_vmcore_fault,
+};
+
 /*
  * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
  * reported as not being ram with the zero page.
_


Please check and test that and send it back at us a a v2 patch?

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

* [PATCH v2] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
  2024-11-01  1:52 ` Andrew Morton
@ 2024-11-01  3:23   ` Qi Xi
  2024-11-01  3:38     ` Jinjie Ruan
  0 siblings, 1 reply; 6+ messages in thread
From: Qi Xi @ 2024-11-01  3:23 UTC (permalink / raw)
  To: bobo.shaobowang, xiqi2, bhe, vgoyal, dyoung, holzheu, akpm,
	kexec, linux-fsdevel
  Cc: linux-kernel

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
is defined but not used:

>> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

v2: use ifdef instead of __maybe_unused

Fixes: 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202410301936.GcE8yUos-lkp@intel.com/
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 1fb213f379a5..9ed1f6902c8f 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
-	.fault = mmap_vmcore_fault,
-};
-
 /**
  * vmcore_alloc_buf - allocate buffer in vmalloc memory
  * @size: size of buffer
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * virtually contiguous user-space in ELF layout.
  */
 #ifdef CONFIG_MMU
+
+static const struct vm_operations_struct vmcore_mmap_ops = {
+	.fault = mmap_vmcore_fault,
+};
+
 /*
  * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
  * reported as not being ram with the zero page.
-- 
2.33.0


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

* Re: [PATCH v2] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
  2024-11-01  3:23   ` [PATCH v2] " Qi Xi
@ 2024-11-01  3:38     ` Jinjie Ruan
  2024-11-01  3:43       ` [PATCH v3] " Qi Xi
  2024-11-01  3:48       ` Qi Xi
  0 siblings, 2 replies; 6+ messages in thread
From: Jinjie Ruan @ 2024-11-01  3:38 UTC (permalink / raw)
  To: Qi Xi, bobo.shaobowang, bhe, vgoyal, dyoung, holzheu, akpm,
	kexec, linux-fsdevel
  Cc: linux-kernel



On 2024/11/1 11:23, Qi Xi wrote:
> When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
> is defined but not used:
> 
>>> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
>      458 | static const struct vm_operations_struct vmcore_mmap_ops = {
> 
> v2: use ifdef instead of __maybe_unused

Changelogs should go after the '---' line, otherwise they
end up in the git history.

> 
> Fixes: 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/lkml/202410301936.GcE8yUos-lkp@intel.com/
> Signed-off-by: Qi Xi <xiqi2@huawei.com>
> ---
>  fs/proc/vmcore.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 1fb213f379a5..9ed1f6902c8f 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
>  #endif
>  }
>  
> -static const struct vm_operations_struct vmcore_mmap_ops = {
> -	.fault = mmap_vmcore_fault,
> -};
> -
>  /**
>   * vmcore_alloc_buf - allocate buffer in vmalloc memory
>   * @size: size of buffer
> @@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
>   * virtually contiguous user-space in ELF layout.
>   */
>  #ifdef CONFIG_MMU
> +
> +static const struct vm_operations_struct vmcore_mmap_ops = {
> +	.fault = mmap_vmcore_fault,
> +};
> +
>  /*
>   * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
>   * reported as not being ram with the zero page.

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

* [PATCH v3] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
  2024-11-01  3:38     ` Jinjie Ruan
@ 2024-11-01  3:43       ` Qi Xi
  2024-11-01  3:48       ` Qi Xi
  1 sibling, 0 replies; 6+ messages in thread
From: Qi Xi @ 2024-11-01  3:43 UTC (permalink / raw)
  To: bobo.shaobowang, xiqi2, bhe, vgoyal, dyoung, holzheu, akpm,
	kexec, linux-fsdevel
  Cc: linux-kernel

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
is defined but not used:

>> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

Fix this by only defining it when CONFIG_MMU is enabled.

Fixes: 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202410301936.GcE8yUos-lkp@intel.com/
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
v3: move changelogs after the '---' line
v2: use ifdef instead of __maybe_unused

 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 1fb213f379a5..9ed1f6902c8f 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
-	.fault = mmap_vmcore_fault,
-};
-
 /**
  * vmcore_alloc_buf - allocate buffer in vmalloc memory
  * @size: size of buffer
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * virtually contiguous user-space in ELF layout.
  */
 #ifdef CONFIG_MMU
+
+static const struct vm_operations_struct vmcore_mmap_ops = {
+	.fault = mmap_vmcore_fault,
+};
+
 /*
  * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
  * reported as not being ram with the zero page.
-- 
2.33.0


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

* [PATCH v3] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'
  2024-11-01  3:38     ` Jinjie Ruan
  2024-11-01  3:43       ` [PATCH v3] " Qi Xi
@ 2024-11-01  3:48       ` Qi Xi
  1 sibling, 0 replies; 6+ messages in thread
From: Qi Xi @ 2024-11-01  3:48 UTC (permalink / raw)
  To: ruanjinjie
  Cc: akpm, bhe, bobo.shaobowang, dyoung, holzheu, kexec,
	linux-fsdevel, linux-kernel, vgoyal, xiqi2

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
is defined but not used:

>> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

Fix this by only defining it when CONFIG_MMU is enabled.

Fixes: 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/lkml/202410301936.GcE8yUos-lkp@intel.com/
Signed-off-by: Qi Xi <xiqi2@huawei.com>
---
v3: move changelogs after the '---' line
v2: use ifdef instead of __maybe_unused

 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 1fb213f379a5..9ed1f6902c8f 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
-	.fault = mmap_vmcore_fault,
-};
-
 /**
  * vmcore_alloc_buf - allocate buffer in vmalloc memory
  * @size: size of buffer
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * virtually contiguous user-space in ELF layout.
  */
 #ifdef CONFIG_MMU
+
+static const struct vm_operations_struct vmcore_mmap_ops = {
+	.fault = mmap_vmcore_fault,
+};
+
 /*
  * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
  * reported as not being ram with the zero page.
-- 
2.33.0


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

end of thread, other threads:[~2024-11-01  3:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31  7:27 [PATCH] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops' Qi Xi
2024-11-01  1:52 ` Andrew Morton
2024-11-01  3:23   ` [PATCH v2] " Qi Xi
2024-11-01  3:38     ` Jinjie Ruan
2024-11-01  3:43       ` [PATCH v3] " Qi Xi
2024-11-01  3:48       ` Qi Xi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®