Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp735625pxb; Thu, 2 Sep 2021 13:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyECDsMZRB5bxZUP5Kt3GnvFc2lve6Xdry+eIcdDkiDPqfxAUn0GwSxxfnLEsKY22q0a15T X-Received: by 2002:a17:907:7f93:: with SMTP id qk19mr97784ejc.433.1630616321108; Thu, 02 Sep 2021 13:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630616321; cv=none; d=google.com; s=arc-20160816; b=ATVDWWsd5NTWL0A4145HYo6rrUWgxy07ScAq2JWl378s55ixJ3FDX3/LjOff7BUpqG 0DbVOFBN0qpAre91U55swTpJ+m1M5wBd0CF3wi5KoQpZrGoQG5Ss9KeJAnC4CPVF1i3y O6WFz1R3dfk5XzsuQg0aThFnrZmMixTT3FrrShlkVdD/tYmi/NZniuQ9i17F3ksYcDmJ w9GBDjfW5ki35brkCCpVfRMIHsLQMHcww4I6jIPoDT66e5nbbcgDDXCLboxhqyIfVc5Q QqYS+yV3VPv21z/B/mPEsaMTkc4P+k/YkGsuHV+p2hqCiW5C/e1ECsOHKtDvyPlhbgIj BptQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=E1S+5jcQWtYE5x5qrFpgfYh9OaMNAx9YRcmdcbIaK6o=; b=dd7hZf8hiButNeGZpCch1fyiSztNbexeYuFt6k9sBXJJ26iUG9zgAInoPtyK80C0J0 WV8eFTfod7JKlWaYIrc5HgO74xvaGre3yQnyvE28GiI58qaswF0FFHCRh9wG8vPslNQI 0LnRG+SqRz//mCA/Ex9igjZJp4C1pqazZFXPRo3iBTQG1+8C/BJYUPx3l2OlFS8inH11 5fC1RbdcIJTU0RM5EU7T4tEjnKnXDE0sZY2m7rSJvp/RepsQIOvMlJWNMYoIXcI5L7ul SSuw8adow33QrroP2Ybb/TYya2GKp7PzvHMa4xuOr9R0XmNwbB/EGeWhFq+Se0wAxYBC we5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ChEuHje9; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js19si2657654ejc.737.2021.09.02.13.58.17; Thu, 02 Sep 2021 13:58:41 -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=@gmail.com header.s=20210112 header.b=ChEuHje9; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346878AbhIBU54 (ORCPT + 99 others); Thu, 2 Sep 2021 16:57:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242413AbhIBU54 (ORCPT ); Thu, 2 Sep 2021 16:57:56 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D292C061575; Thu, 2 Sep 2021 13:56:57 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id x5so3210972ill.3; Thu, 02 Sep 2021 13:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-transfer-encoding; bh=E1S+5jcQWtYE5x5qrFpgfYh9OaMNAx9YRcmdcbIaK6o=; b=ChEuHje9Z9mTGPnt9v3KD+WXVDNxocrqhat7qwkCyKtXkS5EXxCbtVyjH7Sv2chiVx M7rbQ1HftU4Ydq+ZrvmH6scvsgFryZn2S30Yy7bZWJoEQmDDQhvfI2F80ZhnEqFKrqPy XSeFVKHEE6QFQQGwl5p6EIstrbIcof9ecDt8BDjRBdEwRT2e1mgarqMjCcAY5EgmcToh edXrdheQ2WAZON0iKD5CGUDTw1DvkWg7y7SGFPbl6VBRBcsx8thDnAL9bKoEN8YI977s 1gidKOMrNOMO63X0NGAL6Jgf2EC3PLhrnHcgsRxpHMtzMxcdMdsNSCs7scfufrsAmBOb ngSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version:content-transfer-encoding; bh=E1S+5jcQWtYE5x5qrFpgfYh9OaMNAx9YRcmdcbIaK6o=; b=FPhFJqFZXBafH1TH8E9WQGIEWqOKmWfuTlrJHUkX3wIeiG7ESiwcsMDvEIVINaWOxs aiyDsgOBzQMza0tWB+Lb/hy4IVsAMVbQoJEaA9UhhLd0XZ+U50+TTOOCN+GJ5FarrBqV fq9zMFeB0wOQiND0ls3+FrHVP0H2ZTr7CQvfgt2jYb09gcnzpg20zbBRc/TdKhbzxzrN 7xooDIu4ucg9Oeh++5kPgBO+Yo5dVSHCpjtgwvkNKZk2ABNDQPRxvh6xzcI9nhM/Qs42 7bm3PrGBOWiY1CaCFM4YlNzP0h6WAXT/um6ne1ouR/+GcqbFjT5AxO2193d+ph4gybSO snRA== X-Gm-Message-State: AOAM533sQBEYVjmxQOy0SAMbgJNUKl6wF+Q7uuBKpQsP6mAWIsUCYPYd rJ08J+fbi2YLQ13TbMSa97A= X-Received: by 2002:a92:c70e:: with SMTP id a14mr60918ilp.299.1630616216688; Thu, 02 Sep 2021 13:56:56 -0700 (PDT) Received: from localhost ([172.243.157.240]) by smtp.gmail.com with ESMTPSA id j6sm1601683iom.5.2021.09.02.13.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 13:56:56 -0700 (PDT) Date: Thu, 02 Sep 2021 13:56:47 -0700 From: John Fastabend To: Song Liu , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, kjain@linux.ibm.com, kernel-team@fb.com, Song Liu Message-ID: <61313a8fda896_2c56f208bb@john-XPS-13-9370.notmuch> In-Reply-To: <20210902165706.2812867-3-songliubraving@fb.com> References: <20210902165706.2812867-1-songliubraving@fb.com> <20210902165706.2812867-3-songliubraving@fb.com> Subject: RE: [PATCH v5 bpf-next 2/3] bpf: introduce helper bpf_get_branch_snapshot Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Song Liu wrote: > Introduce bpf_get_branch_snapshot(), which allows tracing pogram to get > branch trace from hardware (e.g. Intel LBR). To use the feature, the > user need to create perf_event with proper branch_record filtering > on each cpu, and then calls bpf_get_branch_snapshot in the bpf function. > On Intel CPUs, VLBR event (raw event 0x1b00) can be use for this. > > Signed-off-by: Song Liu > --- [...] > > +BPF_CALL_3(bpf_get_branch_snapshot, void *, buf, u32, size, u64, flags) > +{ > +#ifndef CONFIG_X86 > + return -ENOENT; > +#else > + static const u32 br_entry_size = sizeof(struct perf_branch_entry); > + u32 entry_cnt = size / br_entry_size; > + > + if (unlikely(flags)) > + return -EINVAL; > + > + if (!buf || (size % br_entry_size != 0)) > + return -EINVAL; LGTM, but why fail if buffer is slightly larger than expected? I guess its a slightly buggy program that would do this, but not actually harmful right? Acked-by: John Fastabend