From: Waiman Long <longman@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Dave Chinner <david@fromorbit.com>,
Waiman Long <longman@redhat.com>
Subject: [PATCH v2 1/3] sched/core: Export wake_q functions to kernel modules
Date: Sun, 26 Aug 2018 16:53:13 -0400 [thread overview]
Message-ID: <1535316795-21560-2-git-send-email-longman@redhat.com> (raw)
In-Reply-To: <1535316795-21560-1-git-send-email-longman@redhat.com>
The use of wake_q_add() and wake_up_q() functions help to do task wakeup
without holding lock can help to reduce lock hold time. They should be
available to kernel modules as well.
A new task_in_wake_q() inline function is also added to check if the
given task is in a wake_q.
Signed-off-by: Waiman Long <longman@redhat.com>
---
include/linux/sched/wake_q.h | 5 +++++
kernel/sched/core.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/include/linux/sched/wake_q.h b/include/linux/sched/wake_q.h
index 10b19a192b2d..902bf1228d32 100644
--- a/include/linux/sched/wake_q.h
+++ b/include/linux/sched/wake_q.h
@@ -47,6 +47,11 @@ static inline void wake_q_init(struct wake_q_head *head)
head->lastp = &head->first;
}
+static inline bool task_in_wake_q(struct task_struct *task)
+{
+ return READ_ONCE(task->wake_q.next) != NULL;
+}
+
extern void wake_q_add(struct wake_q_head *head,
struct task_struct *task);
extern void wake_up_q(struct wake_q_head *head);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 625bc9897f62..d90a2930b8ce 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -420,6 +420,7 @@ void wake_q_add(struct wake_q_head *head, struct task_struct *task)
*head->lastp = node;
head->lastp = &node->next;
}
+EXPORT_SYMBOL_GPL(wake_q_add);
void wake_up_q(struct wake_q_head *head)
{
@@ -442,6 +443,7 @@ void wake_up_q(struct wake_q_head *head)
put_task_struct(task);
}
}
+EXPORT_SYMBOL_GPL(wake_up_q);
/*
* resched_curr - mark rq's current task 'to be rescheduled now'.
--
2.18.0
next prev parent reply other threads:[~2018-08-27 0:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-26 20:53 [PATCH v2 0/3] xfs: Reduce spinlock contention in log space slowpath code Waiman Long
2018-08-26 20:53 ` Waiman Long [this message]
2018-08-26 20:53 ` [PATCH v2 2/3] xfs: Prevent multiple wakeups of the same log space waiter Waiman Long
2018-08-27 0:21 ` Dave Chinner
2018-08-27 7:39 ` Christoph Hellwig
2018-08-27 21:42 ` Dave Chinner
2018-08-27 15:34 ` Waiman Long
2018-08-28 1:26 ` Dave Chinner
2018-08-26 20:53 ` [PATCH v2 3/3] xfs: Use wake_q for waking up log space waiters Waiman Long
2018-08-26 23:08 ` [PATCH v2 0/3] xfs: Reduce spinlock contention in log space slowpath code Dave Chinner
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=1535316795-21560-2-git-send-email-longman@redhat.com \
--to=longman@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).