Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp766880pxp; Fri, 11 Mar 2022 14:34:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWNyZooOP8wsy7RVcirPTUbqmPWN0rXH7zwtQewHzZ9gQZCBjrc4wRTvjvy1HwzGbeHutA X-Received: by 2002:a17:90b:1c03:b0:1bf:552e:f4a9 with SMTP id oc3-20020a17090b1c0300b001bf552ef4a9mr13338737pjb.42.1647038082549; Fri, 11 Mar 2022 14:34:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647038082; cv=none; d=google.com; s=arc-20160816; b=g4ZnjURkgu0JSpfdg3/Hcus5TWbAAswIQQ9RT46Ot1TYhssjlAq20R9hEkxIy9/vdt B0m7BRJ75ZEuwIWJ1nrJCQECfZcNuxR1gV5XHYEnE86xbkvXHFk6Irds0QRovVHlQqrl a2Q3Fe6diiIceyXKJJdKyrasWkGCdLWaJSOHPMtYW1bbf4dR61oNjH1lrSmedvNpjgqe RNczKSyUgBk6yb8R9ymqZ7Gb2u4sOj8es2qz5BHZBui1kjJ0qP7/klk2vL2XI4zMRrsy pQcxSHFtkZx3it47xGalXfvt0WzVvsncwaOhbKCZgEx5XD6nXjB3N60b8ZlcNCwbVKbn ASew== 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=bXC5XHcV/Wbu2T0eQaB0nXVhI1w5Uiw1+os7WF404f4=; b=RgWzrwTZcM3j/oBmXJffnWiwoUMzGGJUMpr+HjatqpF380b6oX21SZWz5p2Z31nQjX G085EOM6WDHzWEi2+tX/dexlroEw5XHyhgfki/ji494FZYe+a+3mJAXbvI34eJ9WQMHv 2OvdUA7oW++JBwKN9nCU5FoTg4VUfUIHAajoRrLEeHvm6ftFdu3Z1Tawm0R8IVehGj// 4qfwyLUEQStk9+/scrS5pUpaNdGXAJy9jaZOftEPr5tSuKsUXMFREJvyLFpCo2BQjuWZ o46sHPwdYYx2ywDOPDQSiKVEYXE/M6q6uUNbJDyu1ZXrh5XOWQY/PlG0Z4n9RFDkolth Xf/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=khGZZDjn; 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 x23-20020a17090a165700b001bd14e030aesi6120291pje.134.2022.03.11.14.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:34:42 -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=khGZZDjn; 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 288273442C8; Fri, 11 Mar 2022 13:46:11 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345294AbiCKBR0 (ORCPT + 99 others); Thu, 10 Mar 2022 20:17:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344340AbiCKBRY (ORCPT ); Thu, 10 Mar 2022 20:17:24 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F1119DE9D for ; Thu, 10 Mar 2022 17:16:22 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id n11so553642qtk.4 for ; Thu, 10 Mar 2022 17:16: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=bXC5XHcV/Wbu2T0eQaB0nXVhI1w5Uiw1+os7WF404f4=; b=khGZZDjneArK+aWQ0eJ+CVypbvxl8Hccs4Kv00uBVk+YSpulAXMLw1UvswkczaBPbF PxbAsulQN4WiJPAEHzLAcp8a9kUq61LLqQVu+nofwfCB9Cida/hZz5CovewY/1tAC67x NiAUI2Mm2PB8pG87KIlV0tIDbbeLJbLgEy/pC0r8Y3ioKBhnf3zpXv+0B7fKWX6WXFFs 4DwR27knrmYdywlxS2Cb5N2ySX6wj33aVhKOgg4ymJhlG0lfRhhb+Yf9mRxtIGy6mnRR gpis9PcXSVk6WbbyznDzUrVuuUkhbE6rEDxT0yfnBMNVLeQvQBC6InLIe4rHiqll45JX 0snw== 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=bXC5XHcV/Wbu2T0eQaB0nXVhI1w5Uiw1+os7WF404f4=; b=cMOuVQT4gjILc55+yxVBaBl8bflemlb4urKPY3serhrfL+s0gb/D4lDd7xz2hxXdHF 2IVejVvIqPqgA8lzb0KsBCuREVq4cxaUY0JT/iPwI37+oW0jZhmiaS7E8QpF1MtyfkgN Cct8cK3viDHBrcgOShob3T6VhFnK4T7HdCvBTl45AtIkGUDivbHesTgI1pT+Eap08g3B qGS2ZKd4ePt3laPTZf8mFgQ+kkE3YKNouLtbyK0/QS2B6HX6JjjoBTmIhlmjC8VfvH9a vWms2RZ32nuyxQxRxUunNCYIhyoJmDi9n0lzOQXMh7wBW5UOutXjS3Oj4jzSbmgV7oai AuTA== X-Gm-Message-State: AOAM532EJZYwp7J7SG0f0oufzhprdIrsWHonCBQYjM+cULq1n8qNQz7B jmd+Xdih8jL7RugKmE6Cq3EgdoSz7VLPdexdczYUOAH/qULV9g== X-Received: by 2002:a05:622a:1303:b0:2e0:710e:1372 with SMTP id v3-20020a05622a130300b002e0710e1372mr6392872qtk.566.1646961381032; Thu, 10 Mar 2022 17:16:21 -0800 (PST) MIME-Version: 1.0 References: <20220224000531.1265030-1-haoluo@google.com> In-Reply-To: From: Hao Luo Date: Thu, 10 Mar 2022 17:16:10 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: Cache the last valid build_id. To: Pasha Tatashin Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Namhyung Kim , Blake Jones , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, 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 Fri, Feb 25, 2022 at 12:43 PM Pasha Tatashin wrote: > > On 2/23/22 19:05, 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 > > Reviewed-by: Pasha Tatashin > An update with performance numbers. Thanks to Blake Jones for collecting the stats: In a production workload, with BPF probes sampling stack trace, we see the following changes: - stack_map_get_build_id_offset() is taking 70% of the time of __bpf_get_stackid(); it was 80% before. - find_get_page() and find_vma() together are taking 75% of the time of stack_map_get_build_id_offset(); it was 83% before. Note the call chain is __bpf_get_stackid() -> stack_map_get_build_id_offset() -> find_get_page() -> find_vma() > Thanks, > Pasha