Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp781655pxp; Fri, 11 Mar 2022 15:00:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxs6ZXP0F1862xIrEQ8mPaGp2+Yc9N9SARJts5TgYcXUZClrLzeZeqo3Bx0MfU7CQgPXvDl X-Received: by 2002:a05:6a00:238f:b0:4f6:b09a:4c63 with SMTP id f15-20020a056a00238f00b004f6b09a4c63mr12531591pfc.35.1647039644294; Fri, 11 Mar 2022 15:00:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647039644; cv=none; d=google.com; s=arc-20160816; b=a01FwpNAvia0sjF8LwforLI84MusP74g9EQpDSrKkxCL3zZrZ9tFYCtTv/6eM9Onex W3AIZlg0sclrqfUr/ySGtt+dyTfOERDNkiENcZv5AYCfaV0Mg5/54IsH9GxcI1+wCIEC RMqtu+tG4CcEaBvBxWbv37mSbU2jUnWe188HdDXvwk+QIefjnMVpqtO2I+ecw9FK81Ab g/ah9yqhupQFWe2X68XIeBw1lwEjd6TS+2/5GDunHf+TOkq8l2B5urCEZnpfzqqY71UN xddNSNH8JW5RqXxlA1Hi1FRLml6JQY6+mskm4ODbYdzb6puJHuTLIrJGoOL2ttAeHRMj pBUA== 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=qZ4G1abLpX1+7FOiIPFq4p8zwTFy2fU8JzBB043JMrU=; b=ilZqHO0D44f0fOrGstwdYDcmW4cHg7EF1ZAmrgMzIyRW8IMHYORMwOt9CkibY2T9IY EEpLJ5uCIdKvAZADexkQbTP1rGYQ+KV/wIf7+meFgCQapAgRvSWRQwxihm5xELf6qK09 Cq98BfJ/au3H530Q2O/AMfPC7gBxOexH2P48gyozB4RC6Y7PrIz7xiexGEJJRnmedpci rL/vbHlgzO9M6Wg+iIP2SEEMfanYkrYWhKoc5RVG4ej6+M+8tMPkR9+pp7wvaqnrXgoA +KVa/XmcvsV/tf3Y0wN/qGqCKWm1h+6by0azRO1IInbxiBGfdE0c+1LYeNIcC0K+px+X uZZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WCKzDTLS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r6-20020a170902be0600b00151f21c46a1si8477065pls.576.2022.03.11.15.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 15:00:44 -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=@gmail.com header.s=20210112 header.b=WCKzDTLS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 227163565D9; Fri, 11 Mar 2022 13:57:26 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243320AbiCKTMa (ORCPT + 99 others); Fri, 11 Mar 2022 14:12:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234133AbiCKTM2 (ORCPT ); Fri, 11 Mar 2022 14:12:28 -0500 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33CBF1B8FF2; Fri, 11 Mar 2022 11:11:25 -0800 (PST) Received: by mail-il1-x12a.google.com with SMTP id b14so6650643ilf.6; Fri, 11 Mar 2022 11:11:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qZ4G1abLpX1+7FOiIPFq4p8zwTFy2fU8JzBB043JMrU=; b=WCKzDTLSv5sImvRmJ5fYFhGVQ7cxKmL6C4Ca7BUKJsOjSoxLYYCmovQmdJd1i7TJma tmdzE+NuUN4rreBhoswlO+sGDsN9eG+kxxScRQK4Jz9zPqIZBl4HlnFIEzUgeAFBvxx7 9WFthOB4dbTGLx3XZoFFCJZvkUnaE1EyRgWnqdyZ3bRjZctuBStydqAlM4qqavMDgtMd ge69m5DYx1fdi+gm3wNC3eWpOkS9farucoZDgVqoBe0uq54FXH1WxQxTNYbizlvWb6J6 v7XibIjbPyNrFz1E3eHmv8UiwzzF2DQZ1KKlP11zjMSPoOPKauCjhSVySPUN4YsotS3v 6zyw== 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=qZ4G1abLpX1+7FOiIPFq4p8zwTFy2fU8JzBB043JMrU=; b=6b2PbSbVhrjRBfnhm14DvNkpWM2gHQgtjjrjeCpffkdggHk1Wrhq91Yd1hMf/wcyra cHqNP2eypfyYTLZdI2CMY9JBbHU6lLBo+XCG551kRNj38azQz6JZdi6vIL4PkoGfT7ZD z6yrf8txPydaB55ipst+GU8AoN8/uPyjph7ClosY7Vz9D3JMY/dJS0QP8poL8zhDQLS+ ptBfoabf5FkUaGrhM9C8H9FPl15tGir6lyw2QSX/pRPnrR7IwNoflUDhG8Raj1HCdY5w 2irLIuUlpEUHbuIgEZhU5gXO3DYEc0uSX8zFNTLobw5XZ109OxYZXFVPlx9Bt0z2SqDr Q1ag== X-Gm-Message-State: AOAM5331hXFhyKxqUFPnYO80zWcsE9oXzMJO3Ks7w81wAvTz18bj9NyZ AwTPm0Ti2TOzOe9FpIFBsFiLtxf71UZjZJEih3s= X-Received: by 2002:a92:6406:0:b0:2bb:f1de:e13e with SMTP id y6-20020a926406000000b002bbf1dee13emr8885290ilb.305.1647025884602; Fri, 11 Mar 2022 11:11:24 -0800 (PST) MIME-Version: 1.0 References: <20220224000531.1265030-1-haoluo@google.com> In-Reply-To: From: Andrii Nakryiko Date: Fri, 11 Mar 2022 11:11:13 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: Cache the last valid build_id. To: Hao Luo Cc: Pasha Tatashin , 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=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Thu, Mar 10, 2022 at 5:16 PM Hao Luo wrote: > > 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. Great, thanks for following up with updated numbers! > > - 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