LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Xuefeng Li <lixuefeng@loongson.cn>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] MIPS: Fix using smp_processor_id() in preemptible in show_cpuinfo()
Date: Thu, 25 Nov 2021 16:54:58 +0100	[thread overview]
Message-ID: <20211125155458.GA11524@alpha.franken.de> (raw)
In-Reply-To: <1637840372-27773-1-git-send-email-yangtiezhu@loongson.cn>

On Thu, Nov 25, 2021 at 07:39:32PM +0800, Tiezhu Yang wrote:
> There exists the following issue under DEBUG_PREEMPT:
> 
>  BUG: using smp_processor_id() in preemptible [00000000] code: systemd/1
>  caller is show_cpuinfo+0x460/0xea0
>  ...
>  Call Trace:
>  [<ffffffff8020f0dc>] show_stack+0x94/0x128
>  [<ffffffff80e6cab4>] dump_stack_lvl+0x94/0xd8
>  [<ffffffff80e74c5c>] check_preemption_disabled+0x104/0x110
>  [<ffffffff802209c8>] show_cpuinfo+0x460/0xea0
>  [<ffffffff80539d54>] seq_read_iter+0xfc/0x4f8
>  [<ffffffff804fcc10>] new_sync_read+0x110/0x1b8
>  [<ffffffff804ff57c>] vfs_read+0x1b4/0x1d0
>  [<ffffffff804ffb18>] ksys_read+0xd0/0x110
>  [<ffffffff8021c090>] syscall_common+0x34/0x58
> 
> We can see the following call trace:
>  show_cpuinfo()
>    cpu_has_fpu
>      current_cpu_data
>        smp_processor_id()
> 
>  $ addr2line -f -e vmlinux 0xffffffff802209c8
>  show_cpuinfo
>  arch/mips/kernel/proc.c:188
> 
>  $ head -188 arch/mips/kernel/proc.c | tail -1
> 	 if (cpu_has_fpu)
> 
>  arch/mips/include/asm/cpu-features.h
>  #  define cpu_has_fpu		(current_cpu_data.options & MIPS_CPU_FPU)
> 
>  arch/mips/include/asm/cpu-info.h
>  #define current_cpu_data cpu_data[smp_processor_id()]
> 
> Based on the above analysis, fix the issue by using raw_cpu_has_fpu
> which calls raw_smp_processor_id() in show_cpuinfo().
> 
> Fixes: 626bfa037299 ("MIPS: kernel: proc: add CPU option reporting")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/mips/kernel/proc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
> index 376a6e2..9f47a88 100644
> --- a/arch/mips/kernel/proc.c
> +++ b/arch/mips/kernel/proc.c
> @@ -185,7 +185,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>  		seq_puts(m, " tx39_cache");
>  	if (cpu_has_octeon_cache)
>  		seq_puts(m, " octeon_cache");
> -	if (cpu_has_fpu)
> +	if (raw_cpu_has_fpu)
>  		seq_puts(m, " fpu");
>  	if (cpu_has_32fpr)
>  		seq_puts(m, " 32fpr");
> -- 
> 2.1.0

applied to mips-fixes.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

      reply	other threads:[~2021-11-25 16:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 11:39 Tiezhu Yang
2021-11-25 15:54 ` Thomas Bogendoerfer [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=20211125155458.GA11524@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=yangtiezhu@loongson.cn \
    --subject='Re: [PATCH v2] MIPS: Fix using smp_processor_id() in preemptible in show_cpuinfo()' \
    /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

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).