Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1100494pxm; Wed, 23 Feb 2022 18:08:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQGQyFg2Zu5L/rxN4ZajA2vIpVBy8muYKpYp9VGYdV6s2kMMYccNAk1VBnucouG30Y3+Il X-Received: by 2002:aa7:9199:0:b0:4e1:9243:b625 with SMTP id x25-20020aa79199000000b004e19243b625mr562347pfa.21.1645668539507; Wed, 23 Feb 2022 18:08:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645668539; cv=none; d=google.com; s=arc-20160816; b=D4NseVk0Dp3JritIV0QfQyCnH3pFiN3IUohvbClRiKKhz6ZXoFBWjmzRy7nGElBuR6 dZF8lK94NYYLs1xkBblymkgrqyL91F91/EWVKJl6YnMdMTwdkXW6D6WoyHfFwzxRhWMI 2MST9QgI0mi7hNj8PMu6PUKh2hvUH5yBI+RsWWvb0Xg3Zo0YuWndSwqCJwDwGUsgjOfi CCOhob9AhSvpY/I1/bFnV3JdTOugL98vUgPWng3FwJXhx+XHL5hlm72w+FPzzjlLxynx wg1AT9KQsorVPn+2bUM+OcgYamL1aF857HUWg2BOHqdFzHcFm7rl36AUVWVoeIHSkxVj 8xkQ== 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=qQ9tgl+30McuPheRkP6XMt3TbjKT/oePeBXnUFyrMv8=; b=digRtjH29uol0RiN352egMn0QnmbesbZ1O/nEm0DM73I1O1K6AhBBMfc1yF54oB5Nn +dDjuGNZX6D+OLHDiz9uKf487Q9k8fJzOngZBBZjYJlZmIw1RLjwT2wCfHHFrMTuWGbp jqiEEvQSYJZS+88FQ2f5r8NyB7f0X2azp8pzrrEjD730jbZar31kducR6ifEPDOH78UC ElqodxLX0iw2Z/4Ii7M78SZ3jjxoqZAftZlG1nNW7Pax1YsQoQ90neXvnOIdYtcoCd+x 29xCz/7duPRXHelgZGXXbab6ySbm9lbeNh/3fn38n8V52UYIlTfrB4TDbMeOeXYBrc4V DLhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X1sWVunS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c194si1114142pfc.292.2022.02.23.18.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 18:08:59 -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=@gmail.com header.s=20210112 header.b=X1sWVunS; 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=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 2F267ECB31; Wed, 23 Feb 2022 17:38:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbiBXBjO (ORCPT + 99 others); Wed, 23 Feb 2022 20:39:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbiBXBjM (ORCPT ); Wed, 23 Feb 2022 20:39:12 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D6069287; Wed, 23 Feb 2022 17:38:43 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id 8so1330958qvf.2; Wed, 23 Feb 2022 17:38:43 -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=qQ9tgl+30McuPheRkP6XMt3TbjKT/oePeBXnUFyrMv8=; b=X1sWVunSGk/wOb21MF08UOQHsGL44JsXndBN1yNlDkxuKaYMnfPmwd37XxH81H8zMT V6ZfcwE7enjB66q6Axil2+yHYqNYbDaBI3mFd9i22vPMvICZv9d2al1c3Jmvv82UgC5b mDiKqjq6M8vUtvTSV9v4LRq3yIHjZGwas8lM3izN0LMb00kvJuYrWyPxO2mnzNcTwGNb 2HEt348EEc5HYRQjU9hnqhjmjwreFdG9yCH/CWv+n3JfFRDHAiEhhPuvaTNQ9dUo+F0p +N7pO+oaStp8rx5b6FHUFdWPC4CRQfagSBV9jnwJDCBVCKgKqOtWiBxCKNp94bT870Gm ydOg== 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=qQ9tgl+30McuPheRkP6XMt3TbjKT/oePeBXnUFyrMv8=; b=k9wXOEoFqcZL3/FQypx96M8GmiFk19mT7/RncLLfgQxXc6EvReGIIAcQBf4eoDhmBH 8orjqvKzxxoXpYJ1EtA6pBqkBlkl61Zr7XDK9JUny7zl5SOUFsrE7oioywZt+qvbCRpg zYV1FQuvHu9Qr+gAl3wgyGKlYQYpMoPL3P0YCnhsUYEk+HQEcj2iUULCJky++q/DMBXj 5jKFn4TqUAJlKG/bvGNr95TlCFhUVGN0q6bMUbCQIX1bKAcNg0xh9EVxMQXh2n8s0AYG USUGZ9LmQPqNHsj9FPAWqohEuLosr05OJKrhqBPw5WZWwsNIVwhwuZkk75Ze/p16SJRG 3DGg== X-Gm-Message-State: AOAM530RWepSdWfQeygRmEo766dULKN62+JQTJ2vdx1jNiZuLDhxwRCS cRbwynFIFNGvusZPxQ5gXCRdL01YhAmF5JbjEcQQ8Od3rvA= X-Received: by 2002:a05:6638:382:b0:30e:3e2e:3227 with SMTP id y2-20020a056638038200b0030e3e2e3227mr209459jap.234.1645665018788; Wed, 23 Feb 2022 17:10:18 -0800 (PST) MIME-Version: 1.0 References: <20220224000531.1265030-1-haoluo@google.com> In-Reply-To: From: Andrii Nakryiko Date: Wed, 23 Feb 2022 17:10:07 -0800 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: Cache the last valid build_id. To: Hao Luo 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=-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 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!