linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] sched: add preempt_[disable|enable]_strict()
Date: Sat, 29 Jun 2013 17:15:09 +0200	[thread overview]
Message-ID: <1372518909-12609-1-git-send-email-ard.biesheuvel@linaro.org> (raw)

Add preempt_disable_strict and preempt_enable_strict functions that
can be used to demarcate atomic sections for which we would like
to enforce -even on non-PREEMPT builds with CONFIG_DEBUG_ATOMIC_SLEEP
disabled- that sleeping is not allowed.

The rationale is that in some cases, the risk of data corruption is
high while the likelihood of immediate detection is low, e.g., when
using the NEON unit in kernel mode on arm64.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 include/linux/preempt.h |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index f5d4723..178bf2e 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -56,29 +56,33 @@ do { \
 #endif /* CONFIG_PREEMPT */
 
 
-#ifdef CONFIG_PREEMPT_COUNT
-
-#define preempt_disable() \
+#define preempt_disable_strict() \
 do { \
 	inc_preempt_count(); \
 	barrier(); \
 } while (0)
 
-#define sched_preempt_enable_no_resched() \
+#define __atomic_end() \
 do { \
 	barrier(); \
 	dec_preempt_count(); \
 } while (0)
 
-#define preempt_enable_no_resched()	sched_preempt_enable_no_resched()
-
-#define preempt_enable() \
+#define preempt_enable_strict() \
 do { \
-	preempt_enable_no_resched(); \
+	__atomic_end(); \
 	barrier(); \
 	preempt_check_resched(); \
 } while (0)
 
+#ifdef CONFIG_PREEMPT_COUNT
+
+#define preempt_disable()	preempt_disable_strict()
+#define preempt_enable()	preempt_enable_strict()
+
+#define sched_preempt_enable_no_resched()	__atomic_end()
+#define preempt_enable_no_resched()		__atomic_end()
+
 /* For debugging and tracer internals only! */
 #define add_preempt_count_notrace(val)			\
 	do { preempt_count() += (val); } while (0)
-- 
1.7.9.5

                 reply	other threads:[~2013-06-29 15:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1372518909-12609-1-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.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).