From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
Davidlohr Bueso <dbueso@suse.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
Will Deacon <will@kernel.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched: Unbreak wakeups
Date: Fri, 18 Jun 2021 11:24:05 -0000 [thread overview]
Message-ID: <162401544513.19906.5579522519263051079.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210611082838.160855222@infradead.org>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 37aadc687ab441bbcb693ddae613acf9afcea1ab
Gitweb: https://git.kernel.org/tip/37aadc687ab441bbcb693ddae613acf9afcea1ab
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Fri, 11 Jun 2021 10:28:11 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 18 Jun 2021 11:43:06 +02:00
sched: Unbreak wakeups
Remove broken task->state references and let wake_up_process() DTRT.
The anti-pattern in these patches breaks the ordering of ->state vs
COND as described in the comment near set_current_state() and can lead
to missed wakeups:
(OoO load, observes RUNNING)<-.
for (;;) { |
t->state = UNINTERRUPTIBLE; |
smp_mb(); ,-----> | (observes !COND)
| /
if (COND) ---------' | COND = 1;
break; `- if (t->state != RUNNING)
wake_up_process(t); // not done
schedule(); // forever waiting
}
t->state = TASK_RUNNING;
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210611082838.160855222@infradead.org
---
drivers/net/ethernet/qualcomm/qca_spi.c | 6 ++----
drivers/usb/gadget/udc/max3420_udc.c | 15 +++++----------
drivers/usb/host/max3421-hcd.c | 3 +--
kernel/softirq.c | 2 +-
4 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index ab9b025..0a6b811 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -653,8 +653,7 @@ qcaspi_intr_handler(int irq, void *data)
struct qcaspi *qca = data;
qca->intr_req++;
- if (qca->spi_thread &&
- qca->spi_thread->state != TASK_RUNNING)
+ if (qca->spi_thread)
wake_up_process(qca->spi_thread);
return IRQ_HANDLED;
@@ -777,8 +776,7 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
netif_trans_update(dev);
- if (qca->spi_thread &&
- qca->spi_thread->state != TASK_RUNNING)
+ if (qca->spi_thread)
wake_up_process(qca->spi_thread);
return NETDEV_TX_OK;
diff --git a/drivers/usb/gadget/udc/max3420_udc.c b/drivers/usb/gadget/udc/max3420_udc.c
index 3517954..34f4db5 100644
--- a/drivers/usb/gadget/udc/max3420_udc.c
+++ b/drivers/usb/gadget/udc/max3420_udc.c
@@ -509,8 +509,7 @@ static irqreturn_t max3420_vbus_handler(int irq, void *dev_id)
? USB_STATE_POWERED : USB_STATE_NOTATTACHED);
spin_unlock_irqrestore(&udc->lock, flags);
- if (udc->thread_task &&
- udc->thread_task->state != TASK_RUNNING)
+ if (udc->thread_task)
wake_up_process(udc->thread_task);
return IRQ_HANDLED;
@@ -529,8 +528,7 @@ static irqreturn_t max3420_irq_handler(int irq, void *dev_id)
}
spin_unlock_irqrestore(&udc->lock, flags);
- if (udc->thread_task &&
- udc->thread_task->state != TASK_RUNNING)
+ if (udc->thread_task)
wake_up_process(udc->thread_task);
return IRQ_HANDLED;
@@ -1093,8 +1091,7 @@ static int max3420_wakeup(struct usb_gadget *gadget)
spin_unlock_irqrestore(&udc->lock, flags);
- if (udc->thread_task &&
- udc->thread_task->state != TASK_RUNNING)
+ if (udc->thread_task)
wake_up_process(udc->thread_task);
return ret;
}
@@ -1117,8 +1114,7 @@ static int max3420_udc_start(struct usb_gadget *gadget,
udc->todo |= UDC_START;
spin_unlock_irqrestore(&udc->lock, flags);
- if (udc->thread_task &&
- udc->thread_task->state != TASK_RUNNING)
+ if (udc->thread_task)
wake_up_process(udc->thread_task);
return 0;
@@ -1137,8 +1133,7 @@ static int max3420_udc_stop(struct usb_gadget *gadget)
udc->todo |= UDC_START;
spin_unlock_irqrestore(&udc->lock, flags);
- if (udc->thread_task &&
- udc->thread_task->state != TASK_RUNNING)
+ if (udc->thread_task)
wake_up_process(udc->thread_task);
return 0;
diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index afd9174..e7a8e06 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -1169,8 +1169,7 @@ max3421_irq_handler(int irq, void *dev_id)
struct spi_device *spi = to_spi_device(hcd->self.controller);
struct max3421_hcd *max3421_hcd = hcd_to_max3421(hcd);
- if (max3421_hcd->spi_thread &&
- max3421_hcd->spi_thread->state != TASK_RUNNING)
+ if (max3421_hcd->spi_thread)
wake_up_process(max3421_hcd->spi_thread);
if (!test_and_set_bit(ENABLE_IRQ, &max3421_hcd->todo))
disable_irq_nosync(spi->irq);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4992853..5ddc3b1 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -76,7 +76,7 @@ static void wakeup_softirqd(void)
/* Interrupts are disabled: no need to stop preemption */
struct task_struct *tsk = __this_cpu_read(ksoftirqd);
- if (tsk && tsk->state != TASK_RUNNING)
+ if (tsk)
wake_up_process(tsk);
}
next prev parent reply other threads:[~2021-06-18 11:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-11 8:28 [PATCH v2 0/7] Cleanup task_struct::state Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 1/7] sched: Unbreak wakeups Peter Zijlstra
2021-06-18 11:24 ` tip-bot2 for Peter Zijlstra [this message]
2021-06-11 8:28 ` [PATCH v2 2/7] sched: Introduce task_is_running() Peter Zijlstra
2021-06-11 8:49 ` Geert Uytterhoeven
2021-06-11 9:13 ` Peter Zijlstra
2021-06-11 10:26 ` Will Deacon
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 3/7] sched,perf,kvm: Fix preemption condition Peter Zijlstra
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 4/7] sched: Add get_current_state() Peter Zijlstra
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 5/7] sched,timer: Use __set_current_state() Peter Zijlstra
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 6/7] sched,arch: Remove unused TASK_STATE offsets Peter Zijlstra
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
2021-06-11 8:28 ` [PATCH v2 7/7] sched: Change task_struct::state Peter Zijlstra
2021-06-16 13:24 ` Daniel Bristot de Oliveira
2021-06-18 11:24 ` [tip: sched/core] " tip-bot2 for Peter Zijlstra
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=162401544513.19906.5579522519263051079.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=dbueso@suse.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®