Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3462241ybl; Mon, 19 Aug 2019 19:37:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCKw7hzaYc8JWR4qNboYq1uUyLLirFamKsiNbLWcFxYCI8Y3AE1tMgynJ6KyJMbUOSpsPD X-Received: by 2002:aa7:8dcc:: with SMTP id j12mr27722117pfr.137.1566268644146; Mon, 19 Aug 2019 19:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566268644; cv=none; d=google.com; s=arc-20160816; b=LegaSAkDRzcMp0KF4e6aKj7DMUb930k1Y5BGDbv9Mijm+TcEa5PxX97XxY8Ddo0BX4 7L/0Qb+oRqDd/3eMWoX4AmvQG4SpTCiXzP3xw69ZRjOb4VPpDl3KCp3GjN1v6INqQtBd lUa5luGlXJ0+ETjvrP31DSSHRE2l5WIoyI2gMc4DlLJt86KxyDK7660lMbgn/MOs5+Va DtZBPJrINWccXJgZg7S6kezs2p6QyVLApC+ZwnHbfNb3hj4NFLuw0fPk0NtlVg7YPbfH 0UG4lijg9aoaSc7XgVFjGlFrRO21ZbhtXPMwXb6ZsBFwUTwTg7D5Nv1aTdpc88HL9DAr Dazg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:subject:cc:to:date :in-reply-to:content-transfer-encoding:dkim-signature:dkim-signature; bh=UTtjerizdprs5SO9sELd3ccBs2SUqyaWLtKiMRtIKCg=; b=ukiAF6GWjpgWfu4NyIVvKnoH9MSsYvAwmoWmGABiApYHa362q/kKrzbqMy7FQmZu2P ff0hPBxusCqazKv6pZHjRgBNK8jsU4My/BvAdCZU3DGFmZlGZbE5vY0TlXwute/N5byg rD9tezrbW3QahWE1Xp65rcrvo4GJx/GWRxn4JfyFYP1wMNVf8A5SHM23xFOe25XMV8pG 02mgp+aIjOqSdm8jhiSuIYdobOS951FD+e2Zutz7UXlVLGSw5ukalAVZakgrlJfo5Xef LZvgrk/5V8jdqQMQWNtzqTbPrz1L8P9MxJJjg6ogIV63SCbd58EGAxMlkKP6/p7tcbvQ yjkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm1 header.b=er29fuLU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=fynTHJt8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o70si11218278pgo.280.2019.08.19.19.37.08; Mon, 19 Aug 2019 19:37:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm1 header.b=er29fuLU; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=fynTHJt8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728960AbfHTCez (ORCPT + 99 others); Mon, 19 Aug 2019 22:34:55 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:44033 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbfHTCey (ORCPT ); Mon, 19 Aug 2019 22:34:54 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id AC9BF30E0; Mon, 19 Aug 2019 22:34:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 19 Aug 2019 22:34:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= content-transfer-encoding:content-type:in-reply-to:date:to:cc :subject:from:message-id; s=fm1; bh=UTtjerizdprs5SO9sELd3ccBs2SU qyaWLtKiMRtIKCg=; b=er29fuLUdvd1y7Vd5jcXA52UKTe5juq047EmhDXXdQsg 4i0VKXAdXsh4sIPjz2kFlKA4+h8LuMP6+CzWR/K26hK720DDdpLTroG6g4aPpGFV N+/6xBj20VDHHhBh7vb9Go9afTgh2NJvqvinN8sDE6kl4D81xUnTx9jmhza8yRgr OW7r6ak2qnvtX0Bhcc1ACfE9JR+CwBONq/+QrtMoIWuW9JKQiNt616kJSF4CejTe 0iUc9RicFQNleToRpDE+8qrOtHqxbwRv1zj9NSkbhHWu8bwd2XYoAsgA6R7+L8Yy hnDXo5i4W7/ilI2zoNSQT3t9bc8REsTPnUO28pd4Jg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=UTtjer izdprs5SO9sELd3ccBs2SUqyaWLtKiMRtIKCg=; b=fynTHJt8XyRPpXxlmDWLvm O1cqz/sy/p5hsH/qu9jkdrpINAJS7QIO0rdSo1Ce6qNTgTdRtuPVFq0yCaZV+PA6 UUM04RADWxVzZBf8kmTHtFBGbsX41cgrtf3pQY5dm5qOvFxc59FiXCZfljYPYbmQ qIkxDkPnoqb/uLTVAbiYPvmb2hw4pSqCxnFCiV34RuinYdjoAHa+/5Lu5g4Hlu6F 87K6C57/BfRoC/8bi7RRtOBe2bxE9skGXUuTOxHqoj3Bi3gcPIKUBOoKLEZ39r+0 Qnt3VuHMtq7PLMzzFvZADt7Kc5EtslLSqJXPNpVJkmj98i27lRV2RErbhzHjJLRA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudegtddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpefgtggjfffvuffhkfesthhqredttddtjeen ucfhrhhomhepfdffrghnihgvlhcuighufdcuoegugihusegugihuuhhurdighiiiqeenuc fkphepudelledrvddtuddrieegrddufeehnecurfgrrhgrmhepmhgrihhlfhhrohhmpegu gihusegugihuuhhurdighiiinecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (unknown [199.201.64.135]) by mail.messagingengine.com (Postfix) with ESMTPA id 6184B380074; Mon, 19 Aug 2019 22:34:51 -0400 (EDT) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 In-Reply-To: Date: Mon, 19 Aug 2019 19:34:50 -0700 To: "Alexei Starovoitov" Cc: "bpf" , "Song Liu" , "Yonghong Song" , "Andrii Nakryiko" , "Peter Zijlstra" , "Ingo Molnar" , "Arnaldo Carvalho de Melo" , "Alexei Starovoitov" , "Alexander Shishkin" , "Jiri Olsa" , "Namhyung Kim" , "LKML" , "Kernel Team" Subject: Re: [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl From: "Daniel Xu" Message-Id: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon Aug 19, 2019 at 6:26 PM Alexei Starovoitov wrote: > On Fri, Aug 16, 2019 at 3:33 PM Daniel Xu wrote: > > > > It's useful to know [uk]probe's nmissed and nhit stats. For example wit= h > > tracing tools, it's important to know when events may have been lost. > > debugfs currently exposes a control file to get this information, but > > it is not compatible with probes registered with the perf API. > > > > While bpf programs may be able to manually count nhit, there is no way > > to gather nmissed. In other words, it is currently not possible to > > retrieve information about FD-based probes. > > > > This patch adds a new ioctl that lets users query nmissed (as well as > > nhit for completeness). We currently only add support for [uk]probes > > but leave the possibility open for other probes like tracepoint. > > > > Signed-off-by: Daniel Xu > ... > > +int perf_kprobe_event_query(struct perf_event *event, void __user *inf= o) > > +{ > > + struct perf_event_query_probe __user *uquery =3D info; > > + struct perf_event_query_probe query =3D {}; > > + struct trace_event_call *call =3D event->tp_event; > > + struct trace_kprobe *tk =3D (struct trace_kprobe *)call->data; > > + u64 ncopy; > > + > > + if (!capable(CAP_SYS_ADMIN)) > > + return -EPERM; > > + if (copy_from_user(&query, uquery, > > + offsetofend(struct perf_event_query_probe, s= ize))) > > + return -EFAULT; > > + > > + ncopy =3D min_t(u64, query.size, sizeof(query)); > > + query.nhit =3D trace_kprobe_nhit(tk); > > + query.nmissed =3D tk->rp.kp.nmissed; > > + > > + if (copy_to_user(uquery, &query, ncopy)) > > + return -EFAULT; >=20 > shouldn't kernel update query.size before copying back? > Otherwise how user space would know which fields > were populated? Ah yes, sorry. Will add that.