From: Eliezer Tamir <eliezer.tamir@linux.intel.com>
To: David Miller <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Willem de Bruijn <willemb@google.com>,
Eric Dumazet <erdnetdev@gmail.com>,
Andi Kleen <andi@firstfloor.org>, HPA <hpa@zytor.com>,
Cody P Schafer <devel-lists@codyps.com>,
Eliezer Tamir <eliezer@tamir.org.il>
Subject: [PATCH net-next 1/2] net: fix LLS debug_smp_processor_id() warning
Date: Fri, 28 Jun 2013 15:59:26 +0300 [thread overview]
Message-ID: <20130628125926.14419.89905.stgit@ladj378.jer.intel.com> (raw)
In-Reply-To: <20130628125918.14419.36214.stgit@ladj378.jer.intel.com>
Our use of sched_clock is OK because we don't mind the side effects
of calling it and occasionally waking up on a different CPU.
When CONFIG_DEBUG_PREEMPT is on, disable preempt before calling
sched_clock() so we don't trigger a debug_smp_processor_id() warning.
Reported-by: Cody P Schafer <devel-lists@codyps.com>
Signed-off-by: Eliezer Tamir <eliezer.tamir@linux.intel.com>
---
include/net/ll_poll.h | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/include/net/ll_poll.h b/include/net/ll_poll.h
index 5bf2b3a..6d45e6f 100644
--- a/include/net/ll_poll.h
+++ b/include/net/ll_poll.h
@@ -37,20 +37,40 @@ extern unsigned int sysctl_net_ll_poll __read_mostly;
#define LL_FLUSH_FAILED -1
#define LL_FLUSH_BUSY -2
-/* we can use sched_clock() because we don't care much about precision
+/* a wrapper to make debug_smp_processor_id() happy
+ * we can use sched_clock() because we don't care much about precision
* we only care that the average is bounded
- * we don't mind a ~2.5% imprecision so <<10 instead of *1000
+ */
+#ifdef CONFIG_DEBUG_PREEMPT
+static inline u64 ll_sched_clock(void)
+{
+ u64 rc;
+
+ preempt_disable_notrace();
+ rc = sched_clock();
+ preempt_enable_no_resched_notrace();
+
+ return rc;
+}
+#else /* CONFIG_DEBUG_PREEMPT */
+static inline u64 ll_sched_clock(void)
+{
+ return sched_clock();
+}
+#endif /* CONFIG_DEBUG_PREEMPT */
+
+/* we don't mind a ~2.5% imprecision so <<10 instead of *1000
* sk->sk_ll_usec is a u_int so this can't overflow
*/
static inline u64 ll_sk_end_time(struct sock *sk)
{
- return ((u64)ACCESS_ONCE(sk->sk_ll_usec) << 10) + sched_clock();
+ return ((u64)ACCESS_ONCE(sk->sk_ll_usec) << 10) + ll_sched_clock();
}
/* in poll/select we use the global sysctl_net_ll_poll value */
static inline u64 ll_end_time(void)
{
- return ((u64)ACCESS_ONCE(sysctl_net_ll_poll) << 10) + sched_clock();
+ return ((u64)ACCESS_ONCE(sysctl_net_ll_poll) << 10) + ll_sched_clock();
}
static inline bool sk_valid_ll(struct sock *sk)
@@ -61,7 +81,7 @@ static inline bool sk_valid_ll(struct sock *sk)
static inline bool can_poll_ll(u64 end_time)
{
- return !time_after64(sched_clock(), end_time);
+ return !time_after64(ll_sched_clock(), end_time);
}
/* when used in sock_poll() nonblock is known at compile time to be true
next prev parent reply other threads:[~2013-06-28 12:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-28 12:59 [PATCH net-next 0/2] net: lls cleanup patches Eliezer Tamir
2013-06-28 12:59 ` Eliezer Tamir [this message]
2013-06-28 16:51 ` Using sched_clock() for polling time limit Ben Hutchings
2013-06-29 18:50 ` Eliezer Tamir
2013-07-01 19:48 ` Ben Hutchings
2013-06-28 12:59 ` [PATCH net-next 2/2] net: avoid calling sched_clock when LLS is off Eliezer Tamir
2013-06-28 14:38 ` Andi Kleen
2013-06-28 14:54 ` Eliezer Tamir
2013-07-01 21:08 ` [PATCH net-next 0/2] net: lls cleanup patches David Miller
2013-07-02 8:38 ` Eliezer Tamir
2013-07-02 8:45 ` Eliezer Tamir
2013-07-02 9:49 ` [PATCH v2 net-next] net: convert lls to use time_in_range() Eliezer Tamir
2013-07-02 19:56 ` David Miller
2013-07-02 20:10 ` Ben Hutchings
2013-07-02 20:28 ` Eliezer Tamir
2013-07-02 20:42 ` Ben Hutchings
2013-07-03 7:00 ` Eliezer Tamir
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=20130628125926.14419.89905.stgit@ladj378.jer.intel.com \
--to=eliezer.tamir@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=davem@davemloft.net \
--cc=devel-lists@codyps.com \
--cc=eliezer@tamir.org.il \
--cc=erdnetdev@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/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
Powered by JetHome