2020-03-31 16:35:55

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH RT 2/3] irq_work: Fix checking of IRQ_WORK_LAZY flag set on non PREEMPT_RT

4.19.106-rt46-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: "Steven Rostedt (VMware)" <[email protected]>

When CONFIG_PREEMPT_RT_FULL is not set, some of the checks for using
lazy_list are not properly made as the IRQ_WORK_LAZY is not checked. There's
two locations that need this update, so a use_lazy_list() helper function is
added and used in both locations.

Link: https://lore.kernel.org/r/[email protected]
Reported-by: Pavel Machek <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
---
kernel/irq_work.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 2940622da5b3..b6d9d35941ac 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -70,6 +70,12 @@ static void __irq_work_queue_local(struct irq_work *work, struct llist_head *lis
arch_irq_work_raise();
}

+static inline bool use_lazy_list(struct irq_work *work)
+{
+ return (IS_ENABLED(CONFIG_PREEMPT_RT_FULL) && !(work->flags & IRQ_WORK_HARD_IRQ))
+ || (work->flags & IRQ_WORK_LAZY);
+}
+
/* Enqueue the irq work @work on the current CPU */
bool irq_work_queue(struct irq_work *work)
{
@@ -81,11 +87,10 @@ bool irq_work_queue(struct irq_work *work)

/* Queue the entry and raise the IPI if needed. */
preempt_disable();
- if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL) && !(work->flags & IRQ_WORK_HARD_IRQ))
+ if (use_lazy_list(work))
list = this_cpu_ptr(&lazy_list);
else
list = this_cpu_ptr(&raised_list);
-
__irq_work_queue_local(work, list);
preempt_enable();

@@ -106,7 +111,6 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)

#else /* CONFIG_SMP: */
struct llist_head *list;
- bool lazy_work, realtime = IS_ENABLED(CONFIG_PREEMPT_RT_FULL);

/* All work should have been flushed before going offline */
WARN_ON_ONCE(cpu_is_offline(cpu));
@@ -116,10 +120,7 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
return false;

preempt_disable();
-
- lazy_work = work->flags & IRQ_WORK_LAZY;
-
- if (lazy_work || (realtime && !(work->flags & IRQ_WORK_HARD_IRQ)))
+ if (use_lazy_list(work))
list = &per_cpu(lazy_list, cpu);
else
list = &per_cpu(raised_list, cpu);
--
2.25.1



2020-04-02 18:14:42

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH RT 2/3] irq_work: Fix checking of IRQ_WORK_LAZY flag set on non PREEMPT_RT

Hi!

> 4.19.106-rt46-rc1 stable review patch.
> If anyone has any objections, please let me know.
>
> ------------------
>
> From: "Steven Rostedt (VMware)" <[email protected]>
>
> When CONFIG_PREEMPT_RT_FULL is not set, some of the checks for using
> lazy_list are not properly made as the IRQ_WORK_LAZY is not checked. There's
> two locations that need this update, so a use_lazy_list() helper function is
> added and used in both locations.
>
> Link: https://lore.kernel.org/r/[email protected]
> Reported-by: Pavel Machek <[email protected]>
> Signed-off-by: Steven Rostedt (VMware) <[email protected]>

Looks okay to me, thank you.

Acked-by: Pavel Machek <[email protected]>

I'm currently playing with 4.4.X branch, but I'll eventually test it.

Is it possible that 4.4.X branch needs similar patch? My code review
suggests so...

Best regards, Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


Attachments:
(No filename) (1.05 kB)
signature.asc (201.00 B)
Download all attachments

2020-04-02 18:19:18

by Daniel Wagner

[permalink] [raw]
Subject: Re: [PATCH RT 2/3] irq_work: Fix checking of IRQ_WORK_LAZY flag set on non PREEMPT_RT

Hi Pavel,

On Thu, Apr 02, 2020 at 07:22:49PM +0200, Pavel Machek wrote:
> I'm currently playing with 4.4.X branch, but I'll eventually test it.
>
> Is it possible that 4.4.X branch needs similar patch? My code review
> suggests so...

I was waiting for Steven to post the final patch. I'll pick it up for
the next v4.4-rt release.

Thanks,
Daniel

2020-04-03 21:55:48

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH RT 2/3] irq_work: Fix checking of IRQ_WORK_LAZY flag set on non PREEMPT_RT

Hi!

> On Thu, Apr 02, 2020 at 07:22:49PM +0200, Pavel Machek wrote:
> > I'm currently playing with 4.4.X branch, but I'll eventually test it.
> >
> > Is it possible that 4.4.X branch needs similar patch? My code review
> > suggests so...
>
> I was waiting for Steven to post the final patch. I'll pick it up for
> the next v4.4-rt release.

It will not apply cleanly...

Here is version that applies to 4.4, and should compile. Not sure what
other branches it should be applied to.

Best regards,
Pavel

-- cut --

From: "Steven Rostedt (VMware)" <[email protected]>

When CONFIG_PREEMPT_RT_FULL is not set, some of the checks for using
lazy_list are not properly made as the IRQ_WORK_LAZY is not checked. There's
two locations that need this update, so a use_lazy_list() helper function is
added and used in both locations.

Link: https://lore.kernel.org/r/[email protected]
Reported-by: Pavel Machek <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
[ported to 4.4]
Signed-off-by: Pavel Machek <[email protected]>

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 2899ba0d23d1..abc65de5d793 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -57,6 +57,12 @@ void __weak arch_irq_work_raise(void)
*/
}

+static inline bool use_lazy_list(struct irq_work *work)
+{
+ return (IS_ENABLED(CONFIG_PREEMPT_RT_FULL) && !(work->flags & IRQ_WORK_HARD_IRQ))
+ || (work->flags & IRQ_WORK_LAZY);
+}
+
#ifdef CONFIG_SMP
/*
* Enqueue the irq_work @work on @cpu unless it's already pending
@@ -78,7 +84,7 @@ bool irq_work_queue_on(struct irq_work *work, int cpu)
if (!irq_work_claim(work))
return false;

- if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL) && !(work->flags & IRQ_WORK_HARD_IRQ))
+ if (use_lazy_list(work))
list = &per_cpu(lazy_list, cpu);
else
list = &per_cpu(raised_list, cpu);
@@ -95,7 +101,7 @@ EXPORT_SYMBOL_GPL(irq_work_queue_on);
bool irq_work_queue(struct irq_work *work)
{
struct llist_head *list;
- bool lazy_work, realtime = IS_ENABLED(CONFIG_PREEMPT_RT_FULL);
+ int lazy_work;

/* Only queue if not already pending */
if (!irq_work_claim(work))
@@ -106,7 +112,7 @@ bool irq_work_queue(struct irq_work *work)

lazy_work = work->flags & IRQ_WORK_LAZY;

- if (lazy_work || (realtime && !(work->flags & IRQ_WORK_HARD_IRQ)))
+ if (use_lazy_list(work))
list = this_cpu_ptr(&lazy_list);
else
list = this_cpu_ptr(&raised_list);

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


Attachments:
(No filename) (2.61 kB)
signature.asc (201.00 B)
Download all attachments