From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9643CC33C8C for ; Tue, 7 Jan 2020 13:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68C59207E0 for ; Tue, 7 Jan 2020 13:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgAGNap (ORCPT ); Tue, 7 Jan 2020 08:30:45 -0500 Received: from mga18.intel.com ([134.134.136.126]:5777 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbgAGNap (ORCPT ); Tue, 7 Jan 2020 08:30:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 05:30:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,406,1571727600"; d="scan'208";a="222577449" Received: from mjaganna-mobl1.amr.corp.intel.com (HELO btopel-mobl.ger.intel.com) ([10.249.36.63]) by orsmga006.jf.intel.com with ESMTP; 07 Jan 2020 05:30:36 -0800 Subject: Re: [PATCH 5/5] bpf: Allow to resolve bpf trampoline in unwind To: Jiri Olsa , Alexei Starovoitov Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org, bpf@vger.kernel.org, Andrii Nakryiko , Yonghong Song , Martin KaFai Lau , Jakub Kicinski , David Miller References: <20191229143740.29143-1-jolsa@kernel.org> <20191229143740.29143-6-jolsa@kernel.org> <20200106234639.fo2ctgkb5vumayyl@ast-mbp> <20200107130546.GI290055@krava> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Message-ID: <76a10338-391a-ffca-9af8-f407265d146a@intel.com> Date: Tue, 7 Jan 2020 14:30:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200107130546.GI290055@krava> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 2020-01-07 14:05, Jiri Olsa wrote: > On Mon, Jan 06, 2020 at 03:46:40PM -0800, Alexei Starovoitov wrote: >> On Sun, Dec 29, 2019 at 03:37:40PM +0100, Jiri Olsa wrote: >>> When unwinding the stack we need to identify each >>> address to successfully continue. Adding latch tree >>> to keep trampolines for quick lookup during the >>> unwind. >>> >>> Signed-off-by: Jiri Olsa >> ... >>> +bool is_bpf_trampoline(void *addr) >>> +{ >>> + return latch_tree_find(addr, &tree, &tree_ops) != NULL; >>> +} >>> + >>> struct bpf_trampoline *bpf_trampoline_lookup(u64 key) >>> { >>> struct bpf_trampoline *tr; >>> @@ -65,6 +98,7 @@ struct bpf_trampoline *bpf_trampoline_lookup(u64 key) >>> for (i = 0; i < BPF_TRAMP_MAX; i++) >>> INIT_HLIST_HEAD(&tr->progs_hlist[i]); >>> tr->image = image; >>> + latch_tree_insert(&tr->tnode, &tree, &tree_ops); >> >> Thanks for the fix. I was thinking to apply it, but then realized that bpf >> dispatcher logic has the same issue. >> Could you generalize the fix for both? >> May be bpf_jit_alloc_exec_page() can do latch_tree_insert() ? >> and new version of bpf_jit_free_exec() is needed that will do latch_tree_erase(). >> Wdyt? > > I need to check the dispatcher code, but seems ok.. will check > Thanks Jiri! The trampoline and dispatcher share the image allocation, so putting it there would make sense. It's annoying that the dispatcher doesn't show up correctly in perf, and it's been on my list to fix that. Hopefully you beat me to it! :-D Björn