From: Tom Zanussi <zanussi@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: dwilder@us.ibm.com, HOLZHEU@de.ibm.com
Subject: [RFC PATCH 4/6] relay: add relay_reserve_cpu()
Date: Fri, 29 Jun 2007 22:24:12 -0500 [thread overview]
Message-ID: <1183173852.24291.140.camel@ubuntu> (raw)
This patch adds the ability to explicitly specify the per-cpu buffer
to reserve space in. Needed for early DTI tracing.
Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
Signed-off-by: David Wilder <dwilder@us.ibm.com>
---
relay.h | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 6caedef..37a7306 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -269,6 +269,39 @@ static inline void *relay_reserve(struct rchan *chan, size_t length)
}
/**
+ * relay_reserve_cpu - reserve slot in given cpu's channel buffer
+ * @chan: relay channel
+ * @length: number of bytes to reserve
+ * @cpu: cpu to log to
+ *
+ * Returns pointer to reserved slot, NULL if full.
+ *
+ * Reserves a slot in the given cpu's channel buffer.
+ * Does not protect the buffer at all - caller must provide
+ * appropriate synchronization.
+ *
+ * NOTE: this is almost certainly not the function you want -
+ * use relay_reserve() instead for normal logging. This version
+ * is specialized for things like early tracing.
+ */
+static inline void *relay_reserve_cpu(struct rchan *chan, size_t length,
+ unsigned int cpu)
+{
+ void *reserved;
+ struct rchan_buf *buf = chan->buf[cpu];
+
+ if (unlikely(buf->offset + length > buf->chan->subbuf_size)) {
+ length = relay_switch_subbuf(buf, length);
+ if (!length)
+ return NULL;
+ }
+ reserved = buf->data + buf->offset;
+ buf->offset += length;
+
+ return reserved;
+}
+
+/**
* subbuf_start_reserve - reserve bytes at the start of a sub-buffer
* @buf: relay channel buffer
* @length: number of bytes to reserve
next reply other threads:[~2007-06-30 3:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-30 3:24 Tom Zanussi [this message]
2007-07-04 3:17 ` [RFC PATCH 4/6] relay: add relay_reserve_cpu() Mathieu Desnoyers
2007-07-05 16:00 ` Tom Zanussi
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=1183173852.24291.140.camel@ubuntu \
--to=zanussi@us.ibm.com \
--cc=HOLZHEU@de.ibm.com \
--cc=dwilder@us.ibm.com \
--cc=linux-kernel@vger.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