Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1101710pxm; Wed, 23 Feb 2022 18:10:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgfK6VCjIH+oeVASFo0lvAQkAYQVrnKe7Fx96xPfKJQ9aAN0FP5ockpcp5GrIOHncZ0N4m X-Received: by 2002:a63:5c09:0:b0:370:6303:1464 with SMTP id q9-20020a635c09000000b0037063031464mr548964pgb.351.1645668653846; Wed, 23 Feb 2022 18:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645668653; cv=none; d=google.com; s=arc-20160816; b=Eu/twWc19UnpAZ/DyOYKW/MP08YBO+lN+BE4LZ70HRtAlEOd/tm8MzZusvA5qhg3OS vL+PWb5l9bcz60bJdWgUx2HMcQVkPe3fLbEOPc6LMnDN1hn6peffX5TsSaRyWJAAC6WE v2w4bcy9Ja+vYdZ3vlCntqTmaX/qFVh2+rPwr/GGOdzqU9VVmCHv3TlWYcQoZQ4SIEbN rBMQoCyUminmpoSnQxnJZ0rLHj8Y2l2yiX3mg/3bK+vfn0sZDKO1NEXpQGv1v0mq8KE6 puyEqtQLSCU6ImNJxiZ7Fqlr7ea/MbACBfnz8gU/ufemq5oDOq9rsOize1+6C+THXEmP pCag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=c0+yvP+F0EsSuoYlT67FNUqaSTeigpT+q0Adpduwy5E=; b=ycNd6UdlWNJxz4k15q7//YgWjivjg3TewUd/JGWaMlUSpyYXWlH7TqArMT4ZLAsWpa vjnPsnK4v7KMOOHO9S217MJn8f+Nd4oaj2s3JHd2a89Auq68y/DkpqSXwjy+nkadIqg8 IfUsKfNbeOtQWPiSXabTr3wdUEGHE77WW6GLU3IQ3Q3+/k2JqNXhI18lp00HBc2O8jwE V4Uol3dmm1NkIVgbWAwiz//bPcaVEIKKv5cQryVI7cgaAJobZk8wBv5s6rEG180L0UtT 0Wb1+Y8TaucpAHdI0VBxIJIfmCYLfrmFxfxjAAbAXZFeIiQZHf8RHF0YcG02FAIJVY0L TFoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PKlhuVKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h9si1276952pfv.41.2022.02.23.18.10.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 18:10:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PKlhuVKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 550067E5A3; Wed, 23 Feb 2022 17:43:29 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbiBXBny (ORCPT + 99 others); Wed, 23 Feb 2022 20:43:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiBXBnw (ORCPT ); Wed, 23 Feb 2022 20:43:52 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F39F7C784 for ; Wed, 23 Feb 2022 17:43:22 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id c23so1058915ioi.4 for ; Wed, 23 Feb 2022 17:43:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c0+yvP+F0EsSuoYlT67FNUqaSTeigpT+q0Adpduwy5E=; b=PKlhuVKsNrEUVyGzqvCwpR8pOqGCDrmzI7od+f6QUwpI4cmRgdMiZkhC5ZyCbdVKht YDd6YnwP1YyLrazZS6FiQPbDdXWPhDuMTIgbXeHtIZTdWhdy6R2FcZh8vyYb7PN4QLGa Bf4Hs/73etduJ2HA/jcIzkMAmCVnSPpnrt41CtswnJO4g5BnMddF2fk2FnfNjBrYQxEg Pt1wVmjrz/iyWUmePS2L/K8+pz3Y5VUOf5kHlBTC2AGYOktfHzjue9EzRDvDo0BpYkGF Oa7GDG/lKeJffigWDZnuuvB9hut5Vlqah1bHh3Ut5kTCxtK3+iQi3CixsxR1VBGwIsbK yXog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c0+yvP+F0EsSuoYlT67FNUqaSTeigpT+q0Adpduwy5E=; b=r0DkuWkZxoZJC2ELpru3GDyMN4AKGiqTiDpMZHV/iBw5uOnK6xjzPNifU4Sm+trw5M 0OOzkl7SPeFkpJdq+omP0I8TM+raF8abMmfyONFPpknbBrE4zHZAgNifD/saXGbtO6zO WLCrbwF/nksG6F0gzEm6BQoXVrxCv862Rs9YhrTK1AX2pnJKfGEyz6hXdOY2IHmvhZ8v u3KhI5ZkY4Od7TeodB/9uhHA9CQJGcI0cA9gK9NRQDhh+DVXrH1F8TtQNBo8nDdO1+YL 2nxqAmZ3UfBAl5ojhqKtGeOpGEvZw8E0jZLH/QLY1Mgttk6fsokDoGmVGoept2lPUaJ+ PJLA== X-Gm-Message-State: AOAM5323zIU58D9qvqu5JBF1iHSrgNV2/PafftJOapmXzW+R0o64Qdx8 ooBB8IhGBPKOjNkxutL4dAlKhlf/q9s0t/8KoooR9x+RDnepEw== X-Received: by 2002:a05:622a:178b:b0:2dd:cbdf:ae23 with SMTP id s11-20020a05622a178b00b002ddcbdfae23mr403443qtk.566.1645665123836; Wed, 23 Feb 2022 17:12:03 -0800 (PST) MIME-Version: 1.0 References: <20220224000531.1265030-1-haoluo@google.com> In-Reply-To: From: Hao Luo Date: Wed, 23 Feb 2022 17:11:52 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: Cache the last valid build_id. To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Namhyung Kim , Blake Jones , bpf , open list , Greg Thelen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 23, 2022 at 5:10 PM Andrii Nakryiko wrote: > > On Wed, Feb 23, 2022 at 4:33 PM Hao Luo wrote: > > > > On Wed, Feb 23, 2022 at 4:11 PM Andrii Nakryiko > > wrote: > > > > > > On Wed, Feb 23, 2022 at 4:05 PM Hao Luo wrote: > > > > > > > > For binaries that are statically linked, consecutive stack frames are > > > > likely to be in the same VMA and therefore have the same build id. > > > > As an optimization for this case, we can cache the previous frame's > > > > VMA, if the new frame has the same VMA as the previous one, reuse the > > > > previous one's build id. We are holding the MM locks as reader across > > > > the entire loop, so we don't need to worry about VMA going away. > > > > > > > > Tested through "stacktrace_build_id" and "stacktrace_build_id_nmi" in > > > > test_progs. > > > > > > > > Suggested-by: Greg Thelen > > > > Signed-off-by: Hao Luo > > > > --- > > > > > > LGTM. Can you share performance numbers before and after? > > > > > > Acked-by: Andrii Nakryiko > > > > > > > Thanks Andrii. > > > > On a real-world workload, we observed that 66% of cpu cycles in > > __bpf_get_stackid() were spent on build_id_parse() and find_vma(). > > This was before. > > > > We haven't evaluated the performance with this patch yet. This > > optimization seems straightforward, so we plan to upstream it first > > and then retest. > > Ok, once it lands upstream, I'd really appreciate if you can retest > and update us with numbers. Thanks! Sure, will do that.