Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2934924pxb; Tue, 24 Aug 2021 10:56:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi3+wIfz4RYHUloVCHC35O9lbiG3DafMyZRsGG/TK20DHbbHtai0IE/phiy144M5SVzvbS X-Received: by 2002:a02:a695:: with SMTP id j21mr32583816jam.99.1629827800762; Tue, 24 Aug 2021 10:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629827800; cv=none; d=google.com; s=arc-20160816; b=SSkMAlAIqMLTZgD6eBpkU1RjY29JTl+iUt/WLZz7s75kRrFnq+rDPbVJlhGQvaBAUE LU5p1u7Z6P6eTuImgaWGQkBR1srRnoJQb3llIHynw+MM+ktm4XwbJAdAFjfPeWLuXk8a HM0I5O0X9PmADwh5F5XZDgxaIKgyYaiE2vrm6A25YZzRtSSlAnzi0IVk909BryWxce0+ z6OTzdvU2DzyFjQXpgvrr5J3qxg3dL2vSlMRzEiDHbwibkKop5jZ8bx4aQq9GdEmPnsC KsQBInabA1TXBAVhrHjLQml+gRAGT8HKfud8XW+bF4RINFQEHKvIxnJ2kN5d1QciQJht n7rQ== 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; bh=chVnKEDwYYQUQViETp6uuKG3BZcPCB1twrqyI4/+WD8=; b=NxNAhck9eNaCVnXXbWyxFR+ES6yIhobfLNwy5N2WTqqu37n2aaQyCo4ltUcj5UV/a0 o3bT8eci/qk+qPpxc4IJeS80Uk2G+nTqv8Ly3x3FkP20nVFGLNkuBf/6xzvNJGBskY/h o3juUQyrgGw1/e/GaEFvk+mRCCQkgsYZeejbRaE9OoBu2AWcHQ9sozlrHxL2nOtFWtFi VDSte0jxo7UftRf7FUD6LuiJSS2OinEqQ7jW2RVaSs5Ffia16ML3YRWwzepX1WmGtURg CHo5F+Sp3kYZyzfddh7809KwzPdcwRdP81SiEiWaeQPLsKzH9HkZmJy+I31guSfF1k3f NaeA== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si18795344iow.85.2021.08.24.10.56.29; Tue, 24 Aug 2021 10:56:40 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234662AbhHXR4U (ORCPT + 99 others); Tue, 24 Aug 2021 13:56:20 -0400 Received: from mail-lf1-f50.google.com ([209.85.167.50]:38904 "EHLO mail-lf1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240599AbhHXR4Q (ORCPT ); Tue, 24 Aug 2021 13:56:16 -0400 Received: by mail-lf1-f50.google.com with SMTP id x27so47248028lfu.5 for ; Tue, 24 Aug 2021 10:55:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=chVnKEDwYYQUQViETp6uuKG3BZcPCB1twrqyI4/+WD8=; b=rfRr7InwUCR8yo6SE4hc/icBTXpqN004PBk9YAWkgdPrjpKuL9PrLe6x5il0Ttx6om ZxXo2mxCEtwrt0qvPcnTn4QMIpfuMOFIEE5V1R3k0p/noidzF+iz4wEeIJ9XBLW05IxM UPyWaOD71AEV5Ny7N1ATC0Dku2Oh1MjlR76K/jGat5Gcw7WI1/utm1ocjrHaFFUWOgxr smKjSxvhJX4hN2gj1jBrb2hT3SigHZyUBKIzV0bptHtiOATn/k2ZBk7GRsAzcjNaVgTK KF5k/7YGEJs2MAw8IzjsIdKG7JOLQOvcaEaNUVmaFNPgnzbpcJaM4jjZz3ss+qSOcs6K HwUQ== X-Gm-Message-State: AOAM532gBxzcE67i50XCaYQPlfCSdGR1WACOjc/OKMEAkFQF12nXS2JI +GbE6dpzlK195St8TLQyZMm4Oo2kKDPrkm39Xqk= X-Received: by 2002:a19:6d02:: with SMTP id i2mr10098374lfc.112.1629827731064; Tue, 24 Aug 2021 10:55:31 -0700 (PDT) MIME-Version: 1.0 References: <20210811062135.1332927-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 24 Aug 2021 10:55:19 -0700 Message-ID: Subject: Re: [RFC] perf/core: Add an ioctl to get a number of lost samples To: Peter Zijlstra Cc: Jiri Olsa , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , LKML , Stephane Eranian , Andi Kleen , Ian Rogers , Gabriel Marin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On Tue, Aug 24, 2021 at 7:05 AM Peter Zijlstra wrote: > > On Wed, Aug 11, 2021 at 01:54:09PM -0700, Namhyung Kim wrote: > > Hi Jiri, > > > > On Wed, Aug 11, 2021 at 8:04 AM Jiri Olsa wrote: > > > > > > On Tue, Aug 10, 2021 at 11:21:35PM -0700, Namhyung Kim wrote: > > > > Sometimes we want to know an accurate number of samples even if it's > > > > lost. Currenlty PERF_RECORD_LOST is generated for a ring-buffer which > > > > might be shared with other events. So it's hard to know per-event > > > > lost count. > > > > > > > > Add event->lost_samples field and PERF_EVENT_IOC_LOST_SAMPLES to > > > > retrieve it from userspace. > > > > > > > > Signed-off-by: Namhyung Kim > > > > --- > > > > include/linux/perf_event.h | 2 ++ > > > > include/uapi/linux/perf_event.h | 1 + > > > > kernel/events/core.c | 9 +++++++++ > > > > kernel/events/ring_buffer.c | 5 ++++- > > > > 4 files changed, 16 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > > > > index f5a6a2f069ed..44d72079c77a 100644 > > > > --- a/include/linux/perf_event.h > > > > +++ b/include/linux/perf_event.h > > > > @@ -756,6 +756,8 @@ struct perf_event { > > > > struct pid_namespace *ns; > > > > u64 id; > > > > > > > > + atomic_t lost_samples; > > > > + > > > > u64 (*clock)(void); > > > > perf_overflow_handler_t overflow_handler; > > > > void *overflow_handler_context; > > > > diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h > > > > index bf8143505c49..24397799127d 100644 > > > > --- a/include/uapi/linux/perf_event.h > > > > +++ b/include/uapi/linux/perf_event.h > > > > @@ -505,6 +505,7 @@ struct perf_event_query_bpf { > > > > #define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32) > > > > #define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *) > > > > #define PERF_EVENT_IOC_MODIFY_ATTRIBUTES _IOW('$', 11, struct perf_event_attr *) > > > > +#define PERF_EVENT_IOC_LOST_SAMPLES _IOR('$', 12, __u64 *) > > > > > > would it be better to use the read syscall for that? > > > https://lore.kernel.org/lkml/20210622153918.688500-5-jolsa@kernel.org/ > > > > > > that patchset ended up on me not having a way to reproduce the > > > issue you guys wanted the fix for ;-) the lost count is there > > > as well > > > > Oh, right... I forgot about that, sorry. > > But I think the lost count is not collected accurately. > > > > Peter, what do you think about the interface (read vs ioctl)? > > I think I'm the one that suggested PERF_FORMAT_LOST at the time :-) Ah, ok. I'm fine with the read format then. Thanks, Namhyung