[PATCH RFC v3 net-next 0/3] eBPF examples in C

2014-07-21 Thread Alexei Starovoitov
Hi, I've been asked to repost LLVM eBPF backend and examples in C, so here they are. LLVM backend is 99% the same as it was in Feb. Not resending it to the list, since I only fixed minor things there. See it in my tree. ex1 - is the same example I showed in Feb, but now it works through BPF sysca

[PATCH RFC v3 net-next 1/3] samples: bpf: elf file loader

2014-07-21 Thread Alexei Starovoitov
simple .o parser and loader using BPF syscall. .o is a standard ELF generated by LLVM backend /* parses elf file compiled by llvm .c->.o * creates maps and stores FD into map_fd array * loads eBPF programs * returns zero on success */ int load_bpf_file(char *path); Signed-off-by: Alexei Staro

[PATCH RFC v3 net-next 3/3] samples: bpf: eBPF dropmon example in C

2014-07-21 Thread Alexei Starovoitov
semantically this example is the same as dropmon.c which has eBPF in assembler. In this example both eBPF and user space are in C: ex2_kern.c - C code that will compile into eBPF and will be attached to kfree_skb event ex2_user.c - corresponding user space part that iterates the map populated

[PATCH RFC v3 net-next 2/3] samples: bpf: eBPF example in C

2014-07-21 Thread Alexei Starovoitov
ex1_kern.c - C program which will be compiled into eBPF to filter netif_receive_skb events on skb->dev->name == "lo" ex1_user.c - corresponding user space component that forever reads /sys/.../trace_pipe Usage: $ sudo ex1 ex1_kern.o should see: writing bpf-4 -> /sys/kernel/debug/tracing/events/n

Re: [RFC PATCH 5/5] futex, doc: add a document on how to use the spinning futexes

2014-07-21 Thread Waiman Long
On 07/21/2014 11:45 AM, Randy Dunlap wrote: On 07/21/2014 08:24 AM, Waiman Long wrote: This patch adds a new document file on how to use the spinning futexes. Signed-off-by: Waiman Long --- Documentation/spinning-futex.txt | 109 ++ 1 files changed, 109 i

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Davidlohr Bueso
On Mon, 2014-07-21 at 21:34 -0400, Steven Rostedt wrote: > On Tue, 22 Jul 2014 03:01:00 +0200 (CEST) > Thomas Gleixner wrote: > > > On Mon, 21 Jul 2014, Darren Hart wrote: > > > On 7/21/14, 14:47, "Thomas Gleixner" wrote: > > > > > > >On Mon, 21 Jul 2014, Andy Lutomirski wrote: > > > >> On Mon,

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Mike Galbraith
On Mon, 2014-07-21 at 21:34 -0400, Steven Rostedt wrote: > I was telling Robert that if futexes get optimistic spinning, he should > reconsider their use of userspace spinlocks in favor of this, because > I'm pretty sure that they will see a great improvement. My (dated) experience with pgsql say

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Steven Rostedt
On Tue, 22 Jul 2014 03:01:00 +0200 (CEST) Thomas Gleixner wrote: > On Mon, 21 Jul 2014, Darren Hart wrote: > > On 7/21/14, 14:47, "Thomas Gleixner" wrote: > > > > >On Mon, 21 Jul 2014, Andy Lutomirski wrote: > > >> On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra > > >>wrote: > > >> > All this

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Darren Hart wrote: > On 7/21/14, 14:47, "Thomas Gleixner" wrote: > > >On Mon, 21 Jul 2014, Andy Lutomirski wrote: > >> On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra > >>wrote: > >> > All this is predicated on the fact that syscalls are 'expensive'. > >> > Weren't syscalls

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Davidlohr Bueso
On Mon, 2014-07-21 at 14:31 -0700, Andy Lutomirski wrote: > On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra wrote: > > All this is predicated on the fact that syscalls are 'expensive'. > > Weren't syscalls only 100s of cycles? All this bitmap mucking is far > > more expensive due to cacheline miss

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Darren Hart
On 7/21/14, 14:47, "Thomas Gleixner" wrote: >On Mon, 21 Jul 2014, Andy Lutomirski wrote: >> On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra >>wrote: >> > All this is predicated on the fact that syscalls are 'expensive'. >> > Weren't syscalls only 100s of cycles? All this bitmap mucking is far >>

Re: [PATCH -v4] random: introduce getrandom(2) system call

2014-07-21 Thread Theodore Ts'o
On Mon, Jul 21, 2014 at 10:21:26PM +0200, Till Smejkal wrote: > Hi, > > On Fri, 18 Jul 2014, Theodore Ts'o wrote: > [...] > > If the GRND_RANDOM bit is not set, then the /dev/urandom pool > > will be used. Unlike using read(2) to fetch data from > > /dev/urandom, if the urandom pool h

Re: [PATCH 5/5] cgroup: introduce cgroup namespaces

2014-07-21 Thread Andy Lutomirski
On Mon, Jul 21, 2014 at 3:11 PM, Aditya Kali wrote: > On Fri, Jul 18, 2014 at 11:57 AM, Andy Lutomirski wrote: >> On Fri, Jul 18, 2014 at 11:51 AM, Aditya Kali wrote: >>> On Fri, Jul 18, 2014 at 9:51 AM, Andy Lutomirski >>> wrote: On Jul 17, 2014 1:56 PM, "Aditya Kali" wrote: > >

Re: [PATCH 5/5] cgroup: introduce cgroup namespaces

2014-07-21 Thread Aditya Kali
On Fri, Jul 18, 2014 at 11:57 AM, Andy Lutomirski wrote: > On Fri, Jul 18, 2014 at 11:51 AM, Aditya Kali wrote: >> On Fri, Jul 18, 2014 at 9:51 AM, Andy Lutomirski wrote: >>> On Jul 17, 2014 1:56 PM, "Aditya Kali" wrote: On Thu, Jul 17, 2014 at 12:57 PM, Andy Lutomirski wrote:

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Andy Lutomirski wrote: > On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra wrote: > > All this is predicated on the fact that syscalls are 'expensive'. > > Weren't syscalls only 100s of cycles? All this bitmap mucking is far > > more expensive due to cacheline misses, which due

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Peter Zijlstra wrote: > On Mon, Jul 21, 2014 at 10:16:37PM +0200, Thomas Gleixner wrote: > > On Mon, 21 Jul 2014, Darren Hart wrote: > > > We observed some significant improvements under some very specific use > > > cases, but a more thorough dive into performance impact in

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Ingo Molnar wrote: > * Waiman Long wrote: > > > Testing done on a 4-socket Westmere-EX boxes with 40 cores (HT off) > > showed the following performance data (average kops/s) with various > > load factor (number of pause instructions) used in the critical > > section using

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Andy Lutomirski
On Mon, Jul 21, 2014 at 2:27 PM, Peter Zijlstra wrote: > On Mon, Jul 21, 2014 at 10:16:37PM +0200, Thomas Gleixner wrote: >> On Mon, 21 Jul 2014, Darren Hart wrote: >> > We observed some significant improvements under some very specific use >> > cases, but a more thorough dive into performance imp

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Peter Zijlstra
On Mon, Jul 21, 2014 at 10:16:37PM +0200, Thomas Gleixner wrote: > On Mon, 21 Jul 2014, Darren Hart wrote: > > We observed some significant improvements under some very specific use > > cases, but a more thorough dive into performance impact in the other cases > > as well as security implications w

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Ingo Molnar
* Waiman Long wrote: > Testing done on a 4-socket Westmere-EX boxes with 40 cores (HT off) > showed the following performance data (average kops/s) with various > load factor (number of pause instructions) used in the critical > section using an userspace mutex microbenchmark. > > Threads

Re: [PATCH -v4] random: introduce getrandom(2) system call

2014-07-21 Thread Till Smejkal
Hi, On Fri, 18 Jul 2014, Theodore Ts'o wrote: [...] > If the GRND_RANDOM bit is not set, then the /dev/urandom pool > will be used. Unlike using read(2) to fetch data from > /dev/urandom, if the urandom pool has not been sufficiently > initialized, getrandom(2) will block

Re: [RFC PATCH 2/5] futex: add optimistic spinning to FUTEX_SPIN_LOCK

2014-07-21 Thread Jason Low
On Mon, 2014-07-21 at 11:24 -0400, Waiman Long wrote: > This patch adds code to do optimistic spinning for the FUTEX_SPIN_LOCK > primitive on the futex value when the lock owner is running. It is > the same optimistic spinning technique that is done in the mutex and > rw semaphore code to improve t

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Darren Hart wrote: > We observed some significant improvements under some very specific use > cases, but a more thorough dive into performance impact in the other cases > as well as security implications with the vdso is still wanting. The security implication is that the feat

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Andi Kleen wrote: > Andi Kleen writes: > > > Waiman Long writes: > > > >> This patch series introduces two new futex command codes to support > >> a new optimistic spinning futex for implementing an exclusive lock > >> primitive that should perform better than the same prim

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Darren Hart
On 7/21/14, 10:20, "Darren Hart" wrote: >On 7/21/14, 9:45, "Andi Kleen" wrote: > >>Andi Kleen writes: >> >>> Waiman Long writes: >>> This patch series introduces two new futex command codes to support a new optimistic spinning futex for implementing an exclusive lock primitive t

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Darren Hart
On 7/21/14, 9:45, "Andi Kleen" wrote: >Andi Kleen writes: > >> Waiman Long writes: >> >>> This patch series introduces two new futex command codes to support >>> a new optimistic spinning futex for implementing an exclusive lock >>> primitive that should perform better than the same primitive u

Re: [RFC PATCH 2/5] futex: add optimistic spinning to FUTEX_SPIN_LOCK

2014-07-21 Thread Davidlohr Bueso
On Mon, 2014-07-21 at 11:24 -0400, Waiman Long wrote: > This patch adds code to do optimistic spinning for the FUTEX_SPIN_LOCK > primitive on the futex value when the lock owner is running. It is > the same optimistic spinning technique that is done in the mutex and > rw semaphore code to improve t

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Andi Kleen
Andi Kleen writes: > Waiman Long writes: > >> This patch series introduces two new futex command codes to support >> a new optimistic spinning futex for implementing an exclusive lock >> primitive that should perform better than the same primitive using >> the wait-wake futex in cases where the

Re: [RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Andi Kleen
Waiman Long writes: > This patch series introduces two new futex command codes to support > a new optimistic spinning futex for implementing an exclusive lock > primitive that should perform better than the same primitive using > the wait-wake futex in cases where the lock owner is actively worki

Re: [RFC PATCH 1/5] futex: add new exclusive lock & unlock command codes

2014-07-21 Thread Thomas Gleixner
On Mon, 21 Jul 2014, Waiman Long wrote: > +#define FUTEX_TID(u) (pid_t)((u) & FUTEX_TID_MASK) > +#define FUTEX_HAS_WAITERS(u) ((u) & FUTEX_WAITERS) You love ugly macros, right? > +/* > + * futex_spin_trylock - attempt to take the lock > + * Return: 1 if successful or an error happen > +

Re: [RFC PATCH 5/5] futex, doc: add a document on how to use the spinning futexes

2014-07-21 Thread Randy Dunlap
On 07/21/2014 08:24 AM, Waiman Long wrote: > This patch adds a new document file on how to use the spinning futexes. > > Signed-off-by: Waiman Long > --- > Documentation/spinning-futex.txt | 109 > ++ > 1 files changed, 109 insertions(+), 0 deletions(-) > c

[RFC PATCH 1/5] futex: add new exclusive lock & unlock command codes

2014-07-21 Thread Waiman Long
This patch adds two new simple exclusive lock and unlock primitives or command codes (FUTEX_SPIN_LOCK and FUTEX_SPIN_UNLOCK) to provide to the users of the futex(2) syscall. These two primitives provide an abstract for a mutual exclusive lock (mutex). The semantics is about the same as the PI and

[RFC PATCH 4/5] spinning futex: put waiting tasks in a sorted rbtree

2014-07-21 Thread Waiman Long
A simple FIFO list for the waiting tasks is easy to use. However, it differs in behavior from the other futex primitives that the waiting tasks are put in a priority list. In order to make a sorted list ranked on priority as well as the order they enter the kernel, we need to convert the simple li

[RFC PATCH 3/5] spinning futex: move a wakened task to spinning

2014-07-21 Thread Waiman Long
This patch moves a wakened task back to the optimistic spinning loop if the owner is running. Signed-off-by: Waiman Long --- kernel/futex.c | 20 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index ddc24d1..cca6457 100644 -

[RFC PATCH 2/5] futex: add optimistic spinning to FUTEX_SPIN_LOCK

2014-07-21 Thread Waiman Long
This patch adds code to do optimistic spinning for the FUTEX_SPIN_LOCK primitive on the futex value when the lock owner is running. It is the same optimistic spinning technique that is done in the mutex and rw semaphore code to improve their performance especially on large systems with large number

[RFC PATCH 5/5] futex, doc: add a document on how to use the spinning futexes

2014-07-21 Thread Waiman Long
This patch adds a new document file on how to use the spinning futexes. Signed-off-by: Waiman Long --- Documentation/spinning-futex.txt | 109 ++ 1 files changed, 109 insertions(+), 0 deletions(-) create mode 100644 Documentation/spinning-futex.txt diff --g

[RFC PATCH 0/5] futex: introduce an optimistic spinning futex

2014-07-21 Thread Waiman Long
This patch series introduces two new futex command codes to support a new optimistic spinning futex for implementing an exclusive lock primitive that should perform better than the same primitive using the wait-wake futex in cases where the lock owner is actively working instead of waiting for I/O