From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Jain, Ronak" <ronak.jain@amd.com>
Cc: "Buddhabhatti, Jay" <jay.buddhabhatti@amd.com>,
"haribabu.gattem@xilinx.com" <haribabu.gattem@xilinx.com>,
"Simek, Michal" <michal.simek@amd.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [bug report] soc: xilinx: Fix for call trace due to the usage of smp_processor_id()
Date: Tue, 27 Feb 2024 14:36:14 +0300 [thread overview]
Message-ID: <1c8fb4b3-c5a7-453c-b032-ac2a495faff0@moroto.mountain> (raw)
In-Reply-To: <LV8PR12MB9206E32C066D7497D671878186592@LV8PR12MB9206.namprd12.prod.outlook.com>
On Tue, Feb 27, 2024 at 10:10:45AM +0000, Jain, Ronak wrote:
> Hi Dan,
>
> > -----Original Message-----
> > From: Buddhabhatti, Jay <jay.buddhabhatti@amd.com>
> > Sent: Tuesday, February 27, 2024 3:25 PM
> > To: Dan Carpenter <dan.carpenter@linaro.org>;
> > haribabu.gattem@xilinx.com; Jain, Ronak <ronak.jain@amd.com>
> > Cc: Simek, Michal <michal.simek@amd.com>; linux-arm-
> > kernel@lists.infradead.org
> > Subject: RE: [bug report] soc: xilinx: Fix for call trace due to the usage of
> > smp_processor_id()
> >
> > +@Jain, Ronak
> >
> > > -----Original Message-----
> > > From: Dan Carpenter <dan.carpenter@linaro.org>
> > > Sent: Thursday, February 1, 2024 5:50 PM
> > > To: haribabu.gattem@xilinx.com
> > > Cc: Buddhabhatti, Jay <jay.buddhabhatti@amd.com>; Simek, Michal
> > > <michal.simek@amd.com>; linux-arm-kernel@lists.infradead.org
> > > Subject: [bug report] soc: xilinx: Fix for call trace due to the usage of
> > > smp_processor_id()
> > >
> > > Hello HariBabu Gattem,
> > >
> > > The patch daed80ed0758: "soc: xilinx: Fix for call trace due to the usage of
> > > smp_processor_id()" from Oct 26, 2023 (linux-next), leads to the following
> > > Smatch static checker warning:
> > >
> > > kernel/irq/manage.c:2614 __request_percpu_irq()
> > > warn: sleeping in atomic context
> > >
> > > drivers/soc/xilinx/xlnx_event_manager.c
> > > 610 cpu = get_cpu();
> > > ^^^^^^^^^^^^^^^
> > > The patch adds get_cpu() which disables preemption.
> > >
> > > 611 per_cpu(cpu_number1, cpu) = cpu;
> > > 612 ret = request_percpu_irq(virq_sgi, xlnx_event_handler,
> > > "xlnx_event_mgmt",
> > > ^^^^^^^^^^^^^^^^^^
> > > request_percpu_irq() does a sleeping allocation so it's a sleeping in atomic
> > bug.
> > >
> > > 613 &cpu_number1);
> > > 614 put_cpu();
> > >
>
> I am working on this issue, and I tried to reproduce the issue but I
> couldn't. First, I tried enabling the below config flags for kernel
> preemption and then ran the smatch command but didn't get the warning
> you were mentioning.
>
> The configs I enabled,
> CONFIG_DEBUG_ATOMIC_SLEEP=y
This config would detect the issue at runtime.
> CONFIG_PREEMPT_RT=y
> CONFIG_PREEMPT=y
> CONFIG_PREEMPT_COUNT=y
> CONFIG_PREEMPTION=y
> CONFIG_PREEMPT_RCU=y
> CONFIG_DEBUG_PREEMPT=y
>
> The smatch command I ran,
> ~/smatch/smatch_scripts/kchecker --spammy drivers/soc/xilinx/xlnx_event_manager.c
> ~/smatch/smatch_scripts/kchecker --spammy kernel/irq/manage.c
> make ARCH=arm64 CHECK="~/smatch/smatch -p=kernel" C=2 drivers/soc/xilinx/xlnx_event_manager.o
>
> Could you please help me with the config you used for this issue and
> would be good if you could share the complete steps(the smatch
> commands) to reproduce the issue.
I'm sorry, to generate this warning you need to rebuild the cross
function database a few times. Which is simple enough, but each time
you rebuild the database takes something like 6 hours.
smatch_scripts/build_kernel_data.sh
Each time you rebuild it, it adds one more branch to the call trees. In
this case building it twice would work I guess. Then it would be:
~/smatch/smatch_scripts/kchecker --spammy kernel/irq/manage.c
That prints the warning quoted above and then I do:
~/smatch/smatch_data/db/smdb.py preempt __request_percpu_irq
xlnx_event_init_sgi() <- disables preempt
-> request_percpu_irq()
-> __request_percpu_irq()
And review the call tree to figure out who to report the warnings too.
But it's probably more interesting to enable CONFIG_DEBUG_ATOMIC_SLEEP
and do runtime testing.
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-02-27 11:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 12:20 [bug report] soc: xilinx: Fix for call trace due to the usage of smp_processor_id() Dan Carpenter
2024-02-27 9:55 ` Buddhabhatti, Jay
2024-02-27 10:10 ` Jain, Ronak
2024-02-27 11:36 ` Dan Carpenter [this message]
2024-02-29 8:39 ` Jain, Ronak
2024-03-01 7:53 ` Dan Carpenter
2024-03-01 11:44 ` Jain, Ronak
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=1c8fb4b3-c5a7-453c-b032-ac2a495faff0@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=haribabu.gattem@xilinx.com \
--cc=jay.buddhabhatti@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=michal.simek@amd.com \
--cc=ronak.jain@amd.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox