Debian Codegraph @

runtime/linux/autoconf-relay_buf-per_cpu_ptr.c

raw
1 //
2 // The following kernel commit:
3 //
4 // commit 017c59c042d01fc84cae7a8ea475861e702c77ab
5 // Author: Akash Goel <[email protected]>
6 // Date: Fri Sep 2 21:47:38 2016 +0200
7 //
8 // relay: Use per CPU constructs for the relay channel buffer pointers
9 //
10 // relay essentially needs to maintain a per CPU array of channel buffer
11 // pointers but it manually creates that array. Instead its better to use
12 // the per CPU constructs, provided by the kernel, to allocate & access the
13 // array of pointer to channel buffers.
14 //
15 // changed the way the 'rchan->buf' field works. It just to be a
16 // regular array, and is now a per_cpu_ptr-style array.
17
18 #include <linux/relay.h>
19 #include <linux/percpu.h>
20 #include <linux/bug.h>
21
22 struct rchan_buf *relay_buf_test(struct rchan *chan, unsigned int cpu);
23
24 struct rchan_buf *relay_buf_test(struct rchan *chan, unsigned int cpu)
25 {
26 BUILD_BUG_ON(sizeof(chan->buf) != sizeof(struct rchan_buf **));
27 return *per_cpu_ptr(chan->buf, cpu);
28 }