From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: Re: [PATCH bpf-next 2/3] bpf: emit RECORD_MMAP events for bpf prog load/unload Date: Thu, 20 Sep 2018 10:25:45 -0300 Message-ID: <20180920132545.GA19861@kernel.org> References: <20180919223935.999270-1-ast@kernel.org> <20180919223935.999270-3-ast@kernel.org> <20180920084424.GN24124@hirez.programming.kicks-ass.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Peter Zijlstra , "David S . Miller" , daniel@iogearbox.net, netdev@vger.kernel.org, kernel-team@fb.com To: Alexei Starovoitov Return-path: Received: from mail.kernel.org ([198.145.29.99]:33684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732441AbeITTJS (ORCPT ); Thu, 20 Sep 2018 15:09:18 -0400 Content-Disposition: inline In-Reply-To: <20180920084424.GN24124@hirez.programming.kicks-ass.net> Sender: netdev-owner@vger.kernel.org List-ID: Em Thu, Sep 20, 2018 at 10:44:24AM +0200, Peter Zijlstra escreveu: > On Wed, Sep 19, 2018 at 03:39:34PM -0700, Alexei Starovoitov wrote: > > void bpf_prog_kallsyms_del(struct bpf_prog *fp) > > { > > + unsigned long symbol_start, symbol_end; > > + /* mmap_record.filename cannot be NULL and has to be u64 aligned */ > > + char buf[sizeof(u64)] = {}; > > + > > if (!bpf_prog_kallsyms_candidate(fp)) > > return; > > > > spin_lock_bh(&bpf_lock); > > bpf_prog_ksym_node_del(fp->aux); > > spin_unlock_bh(&bpf_lock); > > + bpf_get_prog_addr_region(fp, &symbol_start, &symbol_end); > > + perf_event_mmap_bpf_prog(symbol_start, symbol_end - symbol_start, > > + buf, sizeof(buf)); > > } > > So perf doesn't normally issue unmap events.. We've talked about doing > that, but so far it's never really need needed I think. > I feels a bit weird to start issuing unmap events for this. For reference, this surfaced here: https://lkml.org/lkml/2017/1/27/452 Start of the thread, that involves postgresql, JIT, LLVM, perf is here: https://lkml.org/lkml/2016/12/10/1 PeterZ provided a patch introducing PERF_RECORD_MUNMAP, went nowhere due to having to cope with munmapping parts of existing mmaps, etc. I'm still more in favour of introduce PERF_RECORD_MUNMAP, even if for now it would be used just in this clean case for undoing a PERF_RECORD_MMAP for a BPF program. The ABI is already complicated, starting to use something called PERF_RECORD_MMAP for unmmaping by just using a NULL name... too clever, I think. - Arnaldo