linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: cacheinfo: Fix using smp_processor_id() in preemptible
@ 2020-11-16  8:12 Kefeng Wang
  2020-12-18  8:14 ` Atish Patra
  0 siblings, 1 reply; 3+ messages in thread
From: Kefeng Wang @ 2020-11-16  8:12 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv
  Cc: Kefeng Wang, Zong Li

Use raw_smp_processor_id instead of smp_processor_id() to fix warning,

BUG: using smp_processor_id() in preemptible [00000000] code: init/1
caller is debug_smp_processor_id+0x1c/0x26
CPU: 0 PID: 1 Comm: init Not tainted 5.10.0-rc4 #211
Call Trace:
  walk_stackframe+0x0/0xaa
  show_stack+0x32/0x3e
  dump_stack+0x76/0x90
  check_preemption_disabled+0xaa/0xac
  debug_smp_processor_id+0x1c/0x26
  get_cache_size+0x18/0x68
  load_elf_binary+0x868/0xece
  bprm_execve+0x224/0x498
  kernel_execve+0xdc/0x142
  run_init_process+0x90/0x9e
  try_to_run_init_process+0x12/0x3c
  kernel_init+0xb4/0xf8
  ret_from_exception+0x0/0xc

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/riscv/kernel/cacheinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
index de59dd457b41..9b5a8a347434 100644
--- a/arch/riscv/kernel/cacheinfo.c
+++ b/arch/riscv/kernel/cacheinfo.c
@@ -26,7 +26,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
 
 static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type)
 {
-	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id());
+	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id());
 	struct cacheinfo *this_leaf;
 	int index;
 
-- 
2.26.2


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: cacheinfo: Fix using smp_processor_id() in preemptible
  2020-11-16  8:12 [PATCH] riscv: cacheinfo: Fix using smp_processor_id() in preemptible Kefeng Wang
@ 2020-12-18  8:14 ` Atish Patra
  2020-12-18  8:24   ` Kefeng Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Atish Patra @ 2020-12-18  8:14 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: linux-riscv, Albert Ou, Palmer Dabbelt, Zong Li, Paul Walmsley

On Mon, Nov 16, 2020 at 12:08 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> Use raw_smp_processor_id instead of smp_processor_id() to fix warning,
>
> BUG: using smp_processor_id() in preemptible [00000000] code: init/1
> caller is debug_smp_processor_id+0x1c/0x26
> CPU: 0 PID: 1 Comm: init Not tainted 5.10.0-rc4 #211
> Call Trace:
>   walk_stackframe+0x0/0xaa
>   show_stack+0x32/0x3e
>   dump_stack+0x76/0x90
>   check_preemption_disabled+0xaa/0xac
>   debug_smp_processor_id+0x1c/0x26
>   get_cache_size+0x18/0x68
>   load_elf_binary+0x868/0xece
>   bprm_execve+0x224/0x498
>   kernel_execve+0xdc/0x142
>   run_init_process+0x90/0x9e
>   try_to_run_init_process+0x12/0x3c
>   kernel_init+0xb4/0xf8
>   ret_from_exception+0x0/0xc
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  arch/riscv/kernel/cacheinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
> index de59dd457b41..9b5a8a347434 100644
> --- a/arch/riscv/kernel/cacheinfo.c
> +++ b/arch/riscv/kernel/cacheinfo.c
> @@ -26,7 +26,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
>
>  static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type)
>  {
> -       struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id());
> +       struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id());
>         struct cacheinfo *this_leaf;
>         int index;
>
> --
> 2.26.2
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

Reviewed-by: Atish Patra <atish.patra@wdc.com>

As this issue is only reproducible with CONFIG_PREEMPT, the commit
text can be updated to specify that. I have tested this patch with
Qemu as well. FWIW,

Tested-by: Atish Patra <atish.patra@wdc.com>


-- 
Regards,
Atish

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: cacheinfo: Fix using smp_processor_id() in preemptible
  2020-12-18  8:14 ` Atish Patra
@ 2020-12-18  8:24   ` Kefeng Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Kefeng Wang @ 2020-12-18  8:24 UTC (permalink / raw)
  To: Atish Patra
  Cc: linux-riscv, Albert Ou, Palmer Dabbelt, Zong Li, Paul Walmsley


On 2020/12/18 16:14, Atish Patra wrote:
> On Mon, Nov 16, 2020 at 12:08 AM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>> Use raw_smp_processor_id instead of smp_processor_id() to fix warning,
>>
>> BUG: using smp_processor_id() in preemptible [00000000] code: init/1
>> caller is debug_smp_processor_id+0x1c/0x26
>> CPU: 0 PID: 1 Comm: init Not tainted 5.10.0-rc4 #211
>> Call Trace:
>>    walk_stackframe+0x0/0xaa
>>    show_stack+0x32/0x3e
>>    dump_stack+0x76/0x90
>>    check_preemption_disabled+0xaa/0xac
>>    debug_smp_processor_id+0x1c/0x26
>>    get_cache_size+0x18/0x68
>>    load_elf_binary+0x868/0xece
>>    bprm_execve+0x224/0x498
>>    kernel_execve+0xdc/0x142
>>    run_init_process+0x90/0x9e
>>    try_to_run_init_process+0x12/0x3c
>>    kernel_init+0xb4/0xf8
>>    ret_from_exception+0x0/0xc
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   arch/riscv/kernel/cacheinfo.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/cacheinfo.c b/arch/riscv/kernel/cacheinfo.c
>> index de59dd457b41..9b5a8a347434 100644
>> --- a/arch/riscv/kernel/cacheinfo.c
>> +++ b/arch/riscv/kernel/cacheinfo.c
>> @@ -26,7 +26,7 @@ cache_get_priv_group(struct cacheinfo *this_leaf)
>>
>>   static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type)
>>   {
>> -       struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id());
>> +       struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id());
>>          struct cacheinfo *this_leaf;
>>          int index;
>>
>> --
>> 2.26.2
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> Reviewed-by: Atish Patra <atish.patra@wdc.com>
>
> As this issue is only reproducible with CONFIG_PREEMPT, the commit
> text can be updated to specify that. I have tested this patch with
> Qemu as well. FWIW,
>
> Tested-by: Atish Patra <atish.patra@wdc.com>

Thanks Atish, will send v2.


>
>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2020-12-18  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16  8:12 [PATCH] riscv: cacheinfo: Fix using smp_processor_id() in preemptible Kefeng Wang
2020-12-18  8:14 ` Atish Patra
2020-12-18  8:24   ` Kefeng Wang

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