Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1732010pxb; Fri, 10 Sep 2021 12:30:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqaJZ9BmAOImF+EQtnvoViLfqr2u0JW7f08Ijiv7dtb6XsFA8qSqoxFyPWy2Xx5y7LimLm X-Received: by 2002:a6b:bad5:: with SMTP id k204mr8733329iof.65.1631302227150; Fri, 10 Sep 2021 12:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631302227; cv=none; d=google.com; s=arc-20160816; b=HVT/GAsWQ+Y1jesnJ2Ym+LYwq+FKTuNYJXa+nuTsAqN4+kagWhFRsM9ySimTKY/GLI 8sfvzp8Dy2OUCuPNGj5YaK3CcgMkcWvKMcWYcJh49+30Fc00iwVy8c6JCB4ANzmhMnzi mFwcmzexwXrnf99G776N+HCJx4fi3LpucSlfvZZ6ySXuF5BUIVUtFAep7ZIGIesks7em kLmc9BkFnxG1qw3lthuKoFCBBCXBv90QiCrLmfc4Cr7t3diuUEHy/nQgaNTZ0Fh+3JLr N84PJUjCoLrKp4zcnsUmnIMtSm4GH3bTqPTl/AEv33Pj5EAyGw/Nj+4oEi1svV1zg+zm tItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6jlEs7B165almJRLRE31tW+xA96GS78RIfJR4xnCYbg=; b=TBiTuX7VHZDQDv3cuB5+wSJYhuGYndtD928Y2F5Lar3/fyr8/k3bmZqafB468cxGyq 0nGL9HO69OITzK82dNmyZkMVeZCaj2hoFIUeArZVwn+vNvBRYCjG+CCnKB5YUtSUoBBN 7cjl2nxv/Tj8h2U3Lo1/U4Ge+qh+qjsi02vxXilWWie/S4n6W4mmo5yi6zjK2/KFGtxF 4Q9Tt7xq2TikkeTya9bTiTHXJ6yO/jSZJ4MQavunh2+i/W+PoLtRZCJ86wk/RJ+RGj7X NIdfXokhk6w/S/4P5eb0Rhl+GDR8XfCwSb2JqYzM8aziLLlhg6FoZpu/i0PBVKmKqze/ uLRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=PL265S7y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si6573509ilv.42.2021.09.10.12.30.14; Fri, 10 Sep 2021 12:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=PL265S7y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234001AbhIJTah (ORCPT + 99 others); Fri, 10 Sep 2021 15:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhIJTaK (ORCPT ); Fri, 10 Sep 2021 15:30:10 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 233A3C061756; Fri, 10 Sep 2021 12:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6jlEs7B165almJRLRE31tW+xA96GS78RIfJR4xnCYbg=; b=PL265S7y2ZrKBxAQknmUxxk6IB Aguj777Hn3MNTpKzo4XgmpG3fkwj5QEPCohKYCOKBOp92wiIPxFnr1dSYYv+wIgCXd/qRYPuiPcX/ HcFkxsCp4UTc/iYvtsb7Jg814M7S5lXI5sS6rHb6Hoaqu5XGCFYrBREwCEI5AzKSC4DFgyXXA2j8E J8yUeX4WkSUKCkCfpaxR1bu2gUpVf/tQwLnWbdWacIYf05oUSwCUHkw9xn6CxrRfpEAkWElIHdnK4 ILdqf7NBdUP+g7nRdZyNG0lHwLN38GrVDQLu66NfJJupMdQ6NCFKSLJQU16oogf5UyE1ly7MFYUCp 66tc4f7w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOmCb-002CZS-PL; Fri, 10 Sep 2021 19:28:46 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 3557898627A; Fri, 10 Sep 2021 21:28:45 +0200 (CEST) Date: Fri, 10 Sep 2021 21:28:45 +0200 From: Peter Zijlstra To: Song Liu Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, acme@kernel.org, mingo@redhat.com, kjain@linux.ibm.com, kernel-team@fb.com, John Fastabend , Andrii Nakryiko Subject: Re: [PATCH v7 bpf-next 1/3] perf: enable branch record for software events Message-ID: <20210910192845.GT4323@worktop.programming.kicks-ass.net> References: <20210910183352.3151445-1-songliubraving@fb.com> <20210910183352.3151445-2-songliubraving@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210910183352.3151445-2-songliubraving@fb.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 10, 2021 at 11:33:50AM -0700, Song Liu wrote: > The typical way to access branch record (e.g. Intel LBR) is via hardware > perf_event. For CPUs with FREEZE_LBRS_ON_PMI support, PMI could capture > reliable LBR. On the other hand, LBR could also be useful in non-PMI > scenario. For example, in kretprobe or bpf fexit program, LBR could > provide a lot of information on what happened with the function. Add API > to use branch record for software use. > > Note that, when the software event triggers, it is necessary to stop the > branch record hardware asap. Therefore, static_call is used to remove some > branch instructions in this process. > > Suggested-by: Peter Zijlstra > Acked-by: John Fastabend > Acked-by: Andrii Nakryiko > Signed-off-by: Song Liu Acked-by: Peter Zijlstra (Intel)