File: autoconf-relay_buf-per_cpu_ptr.c

package info (click to toggle)
systemtap 5.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 47,964 kB
  • sloc: cpp: 80,838; ansic: 54,757; xml: 49,725; exp: 43,665; sh: 11,527; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (28 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// The following kernel commit:
//
// commit 017c59c042d01fc84cae7a8ea475861e702c77ab
// Author: Akash Goel <akash.goel@intel.com>
// Date:   Fri Sep 2 21:47:38 2016 +0200
//
//     relay: Use per CPU constructs for the relay channel buffer pointers
//
//     relay essentially needs to maintain a per CPU array of channel buffer
//     pointers but it manually creates that array.  Instead its better to use
//     the per CPU constructs, provided by the kernel, to allocate & access the
//     array of pointer to channel buffers.
//
// changed the way the 'rchan->buf' field works. It just to be a
// regular array, and is now a per_cpu_ptr-style array.

#include <linux/relay.h>
#include <linux/percpu.h>
#include <linux/bug.h>

struct rchan_buf *relay_buf_test(struct rchan *chan, unsigned int cpu);

struct rchan_buf *relay_buf_test(struct rchan *chan, unsigned int cpu)
{
    BUILD_BUG_ON(sizeof(chan->buf) != sizeof(struct rchan_buf **));
    return *per_cpu_ptr(chan->buf, cpu);
}