LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86/mm: fix an unused variable "tsk" warning
@ 2019-05-31 20:38 Qian Cai
  2019-05-31 20:53 ` Dave Hansen
  0 siblings, 1 reply; 2+ messages in thread
From: Qian Cai @ 2019-05-31 20:38 UTC (permalink / raw)
  To: mingo, tglx, bp
  Cc: dave.hansen, luto, peterz, hpa, x86, linux-kernel, Qian Cai

"tsk" is only used when MEMORY_FAILURE=y.

arch/x86/mm/fault.c: In function 'do_sigbus':
arch/x86/mm/fault.c:1017:22: warning: unused variable 'tsk'
[-Wunused-variable]

Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/x86/mm/fault.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 46df4c6aae46..a10e518dcdf8 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -1015,7 +1015,9 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
 do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
 	  vm_fault_t fault)
 {
+#ifdef CONFIG_MEMORY_FAILURE
 	struct task_struct *tsk = current;
+#endif
 
 	/* Kernel mode? Handle exceptions or die: */
 	if (!(error_code & X86_PF_USER)) {
-- 
1.8.3.1


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

* Re: [PATCH] x86/mm: fix an unused variable "tsk" warning
  2019-05-31 20:38 [PATCH] x86/mm: fix an unused variable "tsk" warning Qian Cai
@ 2019-05-31 20:53 ` Dave Hansen
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Hansen @ 2019-05-31 20:53 UTC (permalink / raw)
  To: Qian Cai, mingo, tglx, bp
  Cc: dave.hansen, luto, peterz, hpa, x86, linux-kernel

On 5/31/19 1:38 PM, Qian Cai wrote:
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1015,7 +1015,9 @@ static inline bool bad_area_access_from_pkeys(unsigned long error_code,
>  do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
>  	  vm_fault_t fault)
>  {
> +#ifdef CONFIG_MEMORY_FAILURE
>  	struct task_struct *tsk = current;
> +#endif
>  
>  	/* Kernel mode? Handle exceptions or die: */
>  	if (!(error_code & X86_PF_USER)) {

Ick.  I'd much rather see this:

#ifdef CONFIG_MEMORY_FAILURE
        if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
                unsigned lsb = 0;

become:

        if (IS_ENABLED(CONFIG_MEMORY_FAILURE) &&
 	    (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE))) {
                unsigned lsb = 0;

than add another #ifdef.

BTW, which tree are you doing this against?  Current -linus uses tsk in
the last line of do_sigbus():

        force_sig_fault(SIGBUS, BUS_ADRERR, ..., tsk);

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

end of thread, other threads:[~2019-05-31 20:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 20:38 [PATCH] x86/mm: fix an unused variable "tsk" warning Qian Cai
2019-05-31 20:53 ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).