Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1094611pxm; Wed, 23 Feb 2022 18:00:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx82Uw+jmfeFWWb5AVifRGWxzEDjtItouWATFxby61LQt3uCuRfboyQtWqvY2FE08A+sfZt X-Received: by 2002:a17:902:7c01:b0:14f:44f2:4fa with SMTP id x1-20020a1709027c0100b0014f44f204famr522758pll.36.1645668047098; Wed, 23 Feb 2022 18:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645668047; cv=none; d=google.com; s=arc-20160816; b=b+i/VvpRItmxYzSCJzPvCCKeDJUQBtLun2o8NV6wUWS7ryKjQIwZLNXLFNx8YS+4RV 1UTdGX8cUXm9g5wF3dlSKhu3lIwOfsxvk/CkmG9KeokJ6P4qeZJUKisGRBLXTNkGvwi9 /qoYJdqmkvWs+VeV9BokNTFT7p7wOFjtLAqAqodqijBKhjEtXFF+xTjcjC+vN+dj/WAD FwkA+1bDroQMIkkvItfEeVHKdj6af/HOQ/BHROvkLjgCq5TzhlphAEoHJ02XXwN7Yhva WQ+80DXXuZRSX33sTmjwXNsL0orXGCi6UuEt4H/EjEgtSZpUb6p0L+UFmGxeOC88l/+x CfhA== 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=AXLSRzCjsZCFoAyswTHwstLfgcPocf6IJntD36q7k5Q=; b=eZNOGMILvEk6UWlNpM3u8FJyMMu5+TfnfW3xMHk3CZ2Javu6sylhgb8M1h1rTiQ5Y2 5PnAijfEH8lLdU8/N4KrxedVSCpzrw2+7M25OgwIbqMdITtCt8WYV6akcVqUIRkgWlPb EWbFddmAZHgN4Yk/+ZEs+6oMwlFLlno2szCSZLPbkrB4iAamQV5GyqDAb59wCYaj4T3V b0X60MtPCwSrlKxl24ksf4cT2IsngXJhFrluGlt3SEw33Mh64oAwA1ZnV1HPPTPRk5AL K/5I6YJjYz6rHTQ0KesZlm1+gmb4+FlXSgiWdBzzRg0byeNFcMb754cmN9OYpeDnZK3S JUPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eXo4RTiB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id u8si1126673pfg.1.2022.02.23.18.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 18:00:47 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eXo4RTiB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 D498620C1BD; Wed, 23 Feb 2022 17:29:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbiBXAeU (ORCPT + 99 others); Wed, 23 Feb 2022 19:34:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbiBXAeS (ORCPT ); Wed, 23 Feb 2022 19:34:18 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394E79318F for ; Wed, 23 Feb 2022 16:33:49 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id n185so549746qke.5 for ; Wed, 23 Feb 2022 16:33:49 -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=AXLSRzCjsZCFoAyswTHwstLfgcPocf6IJntD36q7k5Q=; b=eXo4RTiBDfKvcK3zjsVQUbB5xRiFtVQPIcgfPkctoWbFm5mnw9b/rvv7i7W/blEnBC yIc5bKXcG1pxnlC0SRfWI5IDbeG0z3AZX3nQHmQHc113lD6Ol5OZ2tS74G+kNbIpat1S l2koJ9Bkk6iHOLOt0wQmQQ2nbaKX3GYVJzBJISlswiX/aKcziR17YdIj0OELDv5KI37/ dvnuxypDL6azczfOlAZUUWle1zoc4hheSw3nVaAqiT9YpEGYVaSrD6iUaorNjL/zZVSV Ci3XLLXkSLWxebo0p8uOW6BT3b9e7L/3SBI7yIwiQbVWMq95CTdtytdFiiwQrPyOiCF+ 4Hcg== 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=AXLSRzCjsZCFoAyswTHwstLfgcPocf6IJntD36q7k5Q=; b=12DpJbFk9GIkOTMQuxtUboQSddVZ9FkRfmH6ZwL+wa3hHs7KVHrT/rVOQGwcQ3DyZz 25WZa8FloB7M10ZFpEETN9gwWzG44EHgDW2Ps8Qe9qwHlPzGo5OLjCwzk+8Qyrqc36DL a7vMfUqUeghpI5I87ijOseqIk5DkkcAO9tY8JTorz7fVg7ZEwBLRrHQFpCej578vQFP/ bgmFAGoMmEjeLcLMQJe/46EL+VW9+CQt65WMvjZAgdlCXxBCtxbm0ksOIpFke3bX7yBQ kDSWi6Ek1DpJoFObwT6kX39R7rbbeydarHTSqebWVPtQdcZJ4xzJMPxbaC7g6YhCdnVC DMgA== X-Gm-Message-State: AOAM531oVyGLNCdHEBY4nH/ByeyTA0H+kPJ75sVJV6DLDYWxDY1Pdkqq +iKQrTxxX39G/igj6y7uPqnJZ2FkTiYLz3Lp3Go/Ng== X-Received: by 2002:a37:b287:0:b0:607:afb3:2c1d with SMTP id b129-20020a37b287000000b00607afb32c1dmr212265qkf.221.1645662828189; Wed, 23 Feb 2022 16:33:48 -0800 (PST) MIME-Version: 1.0 References: <20220224000531.1265030-1-haoluo@google.com> In-Reply-To: From: Hao Luo Date: Wed, 23 Feb 2022 16:33:37 -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 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.