From: Song Liu <songliubraving@fb.com>
To: <linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>,
<netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>, Song Liu <songliubraving@fb.com>,
<stable@vger.kernel.org>, Peter Zijlstra <peterz@infradead.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, Tejun Heo <tj@kernel.org>
Subject: [PATCH bpf-next 1/2] sched: introduce this_rq_is_locked()
Date: Wed, 9 Oct 2019 23:19:15 -0700 [thread overview]
Message-ID: <20191010061916.198761-2-songliubraving@fb.com> (raw)
In-Reply-To: <20191010061916.198761-1-songliubraving@fb.com>
this_rq_is_locked() is introduced to check whether current CPU is holding
rq_lock(). This will be used in bpf/stackmap.c to decide whether is safe
to call up_read(), which may call rq_lock() for the same CPU.
Fixes: commit 615755a77b24 ("bpf: extend stackmap to save binary_build_id+offset instead of address")
Cc: stable@vger.kernel.org # v4.17+
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2c2e56bd8913..fb0fcbd1b6f6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1995,4 +1995,5 @@ int sched_trace_rq_cpu(struct rq *rq);
const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
+bool this_rq_is_locked(void);
#endif
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7880f4f64d0e..577cbe7c05fc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -138,6 +138,14 @@ struct rq *task_rq_lock(struct task_struct *p, struct rq_flags *rf)
}
}
+bool this_rq_is_locked(void)
+{
+ struct rq *rq;
+
+ rq = this_rq();
+ return raw_spin_is_locked(&rq->lock);
+}
+
/*
* RQ-clock updating methods:
*/
--
2.17.1
next prev parent reply other threads:[~2019-10-10 6:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 6:19 [PATCH bpf-next 0/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack() Song Liu
2019-10-10 6:19 ` Song Liu [this message]
2019-10-10 6:19 ` [PATCH bpf-next 2/2] " Song Liu
2019-10-10 7:36 ` Peter Zijlstra
2019-10-10 17:19 ` Alexei Starovoitov
2019-10-10 17:46 ` Peter Zijlstra
2019-10-10 18:06 ` Alexei Starovoitov
2019-10-14 9:09 ` Peter Zijlstra
2019-10-14 20:12 ` Song Liu
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=20191010061916.198761-2-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tj@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;
as well as URLs for NNTP newsgroup(s).