Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755681AbaG3RjI (ORCPT ); Wed, 30 Jul 2014 13:39:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29894 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755452AbaG3RjF (ORCPT ); Wed, 30 Jul 2014 13:39:05 -0400 Date: Wed, 30 Jul 2014 13:36:38 -0400 From: "Frank Ch. Eigler" To: Alexei Starovoitov Cc: "David S. Miller" , Ingo Molnar , Linus Torvalds , Andy Lutomirski , Steven Rostedt , Daniel Borkmann , Chema Gonzalez , Eric Dumazet , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Thomas Gleixner , "H. Peter Anvin" , Andrew Morton , Kees Cook , Linux API , Network Development , LKML Subject: Re: [PATCH RFC v3 net-next 3/3] samples: bpf: eBPF dropmon example in C Message-ID: <20140730173638.GB8745@redhat.com> References: <1406000723-4872-1-git-send-email-ast@plumgrid.com> <1406000723-4872-4-git-send-email-ast@plumgrid.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Alexei - > My understanding of systemtap is that the whole .stp script is converted > to C, compiled as .ko and loaded, so all map walking and prints are > happening in the kernel. Similarly for ktap which has special functions > in kernel to print histograms. That is correct. > I thought dtrace printf are also happening from the kernel. What is > the trick they use to know which pieces of dtrace script should be > run in user space? It appears as though the bytecode language running in the kernel sends some action commands back out to userspace, not just plain data. > In ebpf examples there are two C files: one for kernel with ebpf isa > and one for userspace as native. I thought about combining them, > but couldn't figure out a clean way of doing it. (#if ?) > > What kind of locking/serialization is provided by the ebpf runtime > > over shared variables such as my_map? > > it's traditional rcu scheme. OK, that protects the table structure, but: > [...] In such case concurrent write access to map value can be done > with bpf_xadd instruction, though using normal read/write is also > allowed. In some cases the speed of racy var++ is preferred over > 'lock xadd'. ... so concurrency control over shared values is left up to the programmer. > There are no lock/unlock function helpers available to ebpf > programs, since program may terminate early with div by zero > for example, so in-kernel lock helper implementation would > be complicated and slow. It's possible to do, but for the use > cases so far there is no need. OK, I hope that works out. I've been told that dtrace does something similiar (!) by eschewing protection on global variables such as strings. In their case it's less bad than it sounds because they are used to offloading computation to userspace or to store only thread-local state, and accept the corollary limitations on control. (Systemtap does fully & automatically protect shared variables, even in the face of run-time script errors.) - FChE -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/