* [PATCH 1/1]: powerpc: block interrupts when updating TIDR
@ 2017-12-01 21:31 Sukadev Bhattiprolu
2018-01-29 4:13 ` [1/1] : " Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Sukadev Bhattiprolu @ 2017-12-01 21:31 UTC (permalink / raw)
To: Michael Ellerman; +Cc: clombard, felix, vaibhav, linuxppc-dev, linux-kernel
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Tue, 28 Nov 2017 13:39:43 -0600
Subject: [PATCH 1/1]: powerpc: block interrupts when updating TIDR
clear_thread_tidr() is called in interrupt context as a part of delayed
put of the task structure (i.e as a part of timer interrupt). To prevent
a deadlock, block interrupts when holding vas_thread_id_lock to set/
clear TIDR for a task.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
arch/powerpc/kernel/process.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index bfdd783..aa8dbb9 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1509,14 +1509,15 @@ static int assign_thread_tidr(void)
{
int index;
int err;
+ unsigned long flags;
again:
if (!ida_pre_get(&vas_thread_ida, GFP_KERNEL))
return -ENOMEM;
- spin_lock(&vas_thread_id_lock);
+ spin_lock_irqsave(&vas_thread_id_lock, flags);
err = ida_get_new_above(&vas_thread_ida, 1, &index);
- spin_unlock(&vas_thread_id_lock);
+ spin_unlock_irqrestore(&vas_thread_id_lock, flags);
if (err == -EAGAIN)
goto again;
@@ -1524,9 +1525,9 @@ static int assign_thread_tidr(void)
return err;
if (index > MAX_THREAD_CONTEXT) {
- spin_lock(&vas_thread_id_lock);
+ spin_lock_irqsave(&vas_thread_id_lock, flags);
ida_remove(&vas_thread_ida, index);
- spin_unlock(&vas_thread_id_lock);
+ spin_unlock_irqrestore(&vas_thread_id_lock, flags);
return -ENOMEM;
}
@@ -1535,9 +1536,11 @@ static int assign_thread_tidr(void)
static void free_thread_tidr(int id)
{
- spin_lock(&vas_thread_id_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&vas_thread_id_lock, flags);
ida_remove(&vas_thread_ida, id);
- spin_unlock(&vas_thread_id_lock);
+ spin_unlock_irqrestore(&vas_thread_id_lock, flags);
}
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [1/1] : powerpc: block interrupts when updating TIDR
2017-12-01 21:31 [PATCH 1/1]: powerpc: block interrupts when updating TIDR Sukadev Bhattiprolu
@ 2018-01-29 4:13 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-01-29 4:13 UTC (permalink / raw)
To: Sukadev Bhattiprolu; +Cc: felix, linuxppc-dev, clombard, linux-kernel, vaibhav
On Fri, 2017-12-01 at 21:31:40 UTC, Sukadev Bhattiprolu wrote:
> From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> Date: Tue, 28 Nov 2017 13:39:43 -0600
> Subject: [PATCH 1/1]: powerpc: block interrupts when updating TIDR
>
> clear_thread_tidr() is called in interrupt context as a part of delayed
> put of the task structure (i.e as a part of timer interrupt). To prevent
> a deadlock, block interrupts when holding vas_thread_id_lock to set/
> clear TIDR for a task.
>
> Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/384dfd627f1ee67d028e6f14c6e9bf
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-29 4:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-01 21:31 [PATCH 1/1]: powerpc: block interrupts when updating TIDR Sukadev Bhattiprolu
2018-01-29 4:13 ` [1/1] : " Michael Ellerman
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).