Skip to contentSkip to conversation

relay-use-per-cpu-constructs-for-the-relay-channel-buffer-pointers.patch removed from -mm tree

merged [email protected] 1 participant 1 message Sep 9, 2016

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: relay: Use per CPU constructs for the relay channel buffer pointers
has been removed from the -mm tree. Its filename was
relay-use-per-cpu-constructs-for-the-relay-channel-buffer-pointers.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Akash Goel <[email protected]>
Subject: relay: Use per CPU constructs for the relay channel buffer pointers

relay essentially needs to maintain the per CPU array of channel buffer pointers but it manually creates that array. Instead its better to avail the per CPU constructs, provided by the kernel, to allocate & access the array of pointer to channel buffers.

---

 include/linux/relay.h |   17 +++++----
 kernel/relay.c        |   74 ++++++++++++++++++++++------------------
 2 files changed, 52 insertions(+), 39 deletions(-)
include/linux/relay.h renamed from include/linux/relay.h~relay-use-per-cpu-constructs-for-the-relay-channel-buffer-pointers +10 -7
diff -puN include/linux/relay.h~relay-use-per-cpu-constructs-for-the-relay-channel-buffer-pointers include/linux/relay.h
@@ -20,6 +20,7 @@
 #include <linux/poll.h>
 #include <linux/kref.h>
 #include <linux/irq_work.h>
+#include <linux/percpu.h>
 
 /*
  * Tracks changes to rchan/rchan_buf structs
@@ -64,7 +65,7 @@ struct rchan
 	struct kref kref;		/* channel refcount */
 	void *private_data;		/* for user-defined data */
 	size_t last_toobig;		/* tried to log event > subbuf size */
-	struct rchan_buf *buf[NR_CPUS]; /* per-cpu channel buffers */
+	struct rchan_buf ** __percpu buf; /* per-cpu channel buffers */
 	int is_global;			/* One global buffer ? */
 	struct list_head list;		/* for channel list */
 	struct dentry *parent;		/* parent dentry passed to open */
@@ -205,7 +206,7 @@ static inline void relay_write(struct rc
 	struct rchan_buf *buf;
 
 	local_irq_save(flags);
-	buf = chan->buf[smp_processor_id()];
+	buf = *this_cpu_ptr(chan->buf);
 	if (unlikely(buf->offset + length > chan->subbuf_size))
 		length = relay_switch_subbuf(buf, length);
 	memcpy(buf->data + buf->offset, data, length);
@@ -231,12 +232,12 @@ static inline void __relay_write(struct
 {
 	struct rchan_buf *buf;
 
-	buf = chan->buf[get_cpu()];
+	buf = *get_cpu_ptr(chan->buf);
 	if (unlikely(buf->offset + length > buf->chan->subbuf_size))
 		length = relay_switch_subbuf(buf, length);
 	memcpy(buf->data + buf->offset, data, length);
 	buf->offset += length;
-	put_cpu();
+	put_cpu_ptr(chan->buf);
 }
 
 /**
@@ -252,17 +253,19 @@ static inline void __relay_write(struct
  */
 static inline void *relay_reserve(struct rchan *chan, size_t length)
 {
-	void *reserved;
-	struct rchan_buf *buf = chan->buf[smp_processor_id()];
+	void *reserved = NULL;
+	struct rchan_buf *buf = *get_cpu_ptr(chan->buf);
 
 	if (unlikely(buf->offset + length > buf->chan->subbuf_size)) {
 		length = relay_switch_subbuf(buf, length);
 		if (!length)
-			return NULL;
+			goto end;
 	}
 	reserved = buf->data + buf->offset;
 	buf->offset += length;
 
+end:
+	put_cpu_ptr(chan->buf);
 	return reserved;
 }
 
kernel/relay.c renamed from kernel/relay.c~relay-use-per-cpu-constructs-for-the-relay-channel-buffer-pointers +42 -32

222 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are