public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Santosh Shukla <sshukla@mvista.com>
To: fche@redhat.com,	dsmith@redhat.com,	jistone@redhat.com
Cc: systemtap@sourceware.org,	Santosh Shukla <sshukla@mvista.com>
Subject: [SYSTEMTAP/PATCH v3 1/9] stp: rt: locking helper api
Date: Mon, 22 Sep 2014 07:27:00 -0000	[thread overview]
Message-ID: <1411370822-8707-2-git-send-email-sshukla@mvista.com> (raw)
In-Reply-To: <1411370822-8707-1-git-send-email-sshukla@mvista.com>

Locking helper api used for replacing -rt and non-rt specific locks with common
helper lock starts with prefix stp_.  -rt version of locking api compatible to
kernel version 3.0 and greater. Older -rt version can be supported by adding
more kernel version checks, ifdefs in header file.. I haven't tested on
those(older) kernel version so not including code for now. Tested for
3.10.40-rt38 and 3.14.12-rt9.

Signed-off-by: Santosh Shukla <sshukla@mvista.com>
---
 runtime/stp_helper_lock.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 runtime/stp_helper_lock.h

diff --git a/runtime/stp_helper_lock.h b/runtime/stp_helper_lock.h
new file mode 100644
index 0000000..d1a69b4
--- /dev/null
+++ b/runtime/stp_helper_lock.h
@@ -0,0 +1,67 @@
+/* -*- linux-c -*- 
+ * Locking helper function api to support preempt-rt variant raw locks
+ * and keep legacy locking compatibility intact.
+ *
+ * Author: Santosh Shukla <sshukla@mvista.com>
+ *
+ * Copyright (C) 2014 Red Hat Inc.
+ * 
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ * */
+
+#ifndef _STP_HELPER_LOCK_H_
+#define _STP_HELPER_LOCK_H_
+
+#include <linux/spinlock.h>
+
+#ifdef CONFIG_PREEMPT_RT_FULL
+
+#define STP_DEFINE_SPINLOCK(lock)	DEFINE_RAW_SPINLOCK(lock)
+
+static inline void stp_spin_lock(raw_spinlock_t *lock)		{ raw_spin_lock(lock); }
+static inline void stp_spin_unlock(raw_spinlock_t *lock)	{ raw_spin_unlock(lock); }
+
+#define stp_spin_lock_irqsave(lock, flags)		raw_spin_lock_irqsave(lock, flags)
+#define stp_spin_unlock_irqrestore(lock, flags)		raw_spin_unlock_irqrestore(lock, flags)
+
+
+#define STP_DEFINE_RWLOCK(lock)		DEFINE_RAW_SPINLOCK(lock)
+
+static inline void stp_read_lock(raw_spinlock_t *lock)		{ raw_spin_lock(lock); }
+static inline void stp_read_unlock(raw_spinlock_t *lock)	{ raw_spin_unlock(lock); }
+static inline void stp_write_lock(raw_spinlock_t *lock)		{ raw_spin_lock(lock); }
+static inline void stp_write_unlock(raw_spinlock_t *lock) 	{ raw_spin_unlock(lock); }
+
+#define stp_read_lock_irqsave(lock, flags)		raw_spin_lock_irqsave(lock, flags)
+#define stp_read_unlock_irqrestore(lock, flags)		raw_spin_unlock_irqrestore(lock, flags)
+#define stp_write_lock_irqsave(lock, flags)		raw_spin_lock_irqsave(lock, flags)
+#define stp_write_unlock_irqrestore(lock, flags) 	raw_spin_unlock_irqrestore(lock, flags)
+  
+#else
+#define STP_DEFINE_SPINLOCK(lock)	DEFINE_SPINLOCK(lock)
+
+static inline void stp_spin_lock(spinlock_t *lock)		{ spin_lock(lock); }
+static inline void stp_spin_unlock(spinlock_t *lock)		{ spin_unlock(lock); }
+
+#define stp_spin_lock_irqsave(lock, flags)		spin_lock_irqsave(lock, flags)
+#define stp_spin_unlock_irqrestore(lock, flags)		spin_unlock_irqrestore(lock, flags)
+
+#define STP_DEFINE_RWLOCK(lock)				DEFINE_RWLOCK(lock)
+
+static inline void stp_read_lock(rwlock_t *lock)	{ read_lock(lock); }
+static inline void stp_read_unlock(rwlock_t *lock)	{ read_unlock(lock); }
+static inline void stp_write_lock(rwlock_t *lock)	{ write_lock(lock); }
+static inline void stp_write_unlock(rwlock_t *lock)	{ write_unlock(lock); }
+
+#define stp_read_lock_irqsave(lock, flags)		read_lock_irqsave(lock, flags)
+#define stp_read_unlock_irqrestore(lock, flags)		read_unlock_irqrestore(lock, flags)
+#define stp_write_lock_irqsave(lock, flags)		write_lock_irqsave(lock, flags)
+#define stp_write_unlock_irqrestore(lock, flags) 	write_unlock_irqrestore(lock, flags)
+
+#endif
+
+#endif /* _STP_HELPER_LOCK_H_ */
+
-- 
1.8.3.1

  parent reply	other threads:[~2014-09-22  7:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22  7:27 [SYSTEMTAP/PATCH v3 0/9] RT aware systemtap patch set Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 2/9] stp: rt: replace __stp_tf_map_lock rd/wr lock with stp style raw lock Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 5/9] stp: rt: replace utrace_struct lock to " Santosh Shukla
2014-09-22  7:27 ` Santosh Shukla [this message]
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 9/9] stp: rt: fix preemptible bug_on for STAT_GET_CPU Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 3/9] stp: rt: replace __stp_tf_vma_lock rd/wr lock with stp style of raw lock Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 4/9] stp: rt: replace utrace->lock with stp style " Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 6/9] stp: rt: replace __stp_tf_task_work_list_lock to stp raw Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 7/9] stp: rt: replace addr_map_lock rd/wr lock with stp type raw lock Santosh Shukla
2014-09-22  7:27 ` [SYSTEMTAP/PATCH v3 8/9] stp: rt: replace stp_print lock with stp style lock Santosh Shukla
2014-09-25 18:14 ` [SYSTEMTAP/PATCH v3 0/9] RT aware systemtap patch set Frank Ch. Eigler

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=1411370822-8707-2-git-send-email-sshukla@mvista.com \
    --to=sshukla@mvista.com \
    --cc=dsmith@redhat.com \
    --cc=fche@redhat.com \
    --cc=jistone@redhat.com \
    --cc=systemtap@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).