Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp819867pxb; Thu, 25 Feb 2021 16:30:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJz276yM5Q4AoxczEGJlddyCD1AK+P5cZp4gGeiMXKgx3Yg516pmI6DF3/LgIKsLshhDLVcs X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr281200ejo.247.1614299415397; Thu, 25 Feb 2021 16:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614299415; cv=none; d=google.com; s=arc-20160816; b=xoZkLFfAojGlr3CfReov44MyvoBPMNpYfiqLuU/8HMwCgosNr0xKBeulH/4KbbkiBP tGQt/pMVgpSPQgU6dis1Ydalt9O7pquhPUd1V8kGXjf1j4YLkM/WnItmDRObjZH/zefT +/CqenLDqIfvBDLWCTraxGCDznQixxFpFbd058fL65il+AuQQgfgy7AC0aSHlDu5Rznq +24zMDBEqfVs+dLthCyEWSTALe8WvfR/Bg+E3nj0a74jWW3hSFCoSTgY1egS1B5MahiC o3ZlFJ+FVa+tqjj073lLUV2EkL84teMiFYy+TvXncZzF+CZToW4bpkADLNcBjOpf+4Rv Jxsg== 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=s+E1myvL+FQNMLBHh7YhNNO6xrcap4dEx+GlOPcwYn0=; b=C23w6yG+eHLkpNr8sp3opDmaZBwkUBw8QUZ1a2Bzi68m0LX/F9gr6N8q6PuPP0ynyv RfxhYVzl9m2iOUL5f168q8EgoPTucyq3NdHC5jC+IB+gCjDdm6TukgTqCTsIHNa+ut0Q 3PW83xc0DEBy0TJ/9/cVRLSCsOV7onOFAbRgSN3sMU+Ua9FLxuiauL1HUDpHqpVSMV+W 2fMKFwPDjU5sjD6haM2Jyfn0IFQnfz3qxtNuvkKNkUvU3qpjX9mlWQdHpf57a+KRlWHT WqD7j0Sxfmx2DH+re/Rov96pG65hfVUBOG6quawyntmYglgZiht9YmqFaPbu99pmraCH wKyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eqbKJ6bI; 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 d4si4374856ejb.594.2021.02.25.16.29.53; Thu, 25 Feb 2021 16:30:15 -0800 (PST) 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=20161025 header.b=eqbKJ6bI; 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 S232812AbhBZA2Z (ORCPT + 99 others); Thu, 25 Feb 2021 19:28:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhBZA2I (ORCPT ); Thu, 25 Feb 2021 19:28:08 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF66C061574; Thu, 25 Feb 2021 16:27:28 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id d2so4782703pjs.4; Thu, 25 Feb 2021 16:27:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s+E1myvL+FQNMLBHh7YhNNO6xrcap4dEx+GlOPcwYn0=; b=eqbKJ6bIiWeOJUgULqrl1KIIkrtbyYy+Q6N60mi+a7TonVXtuRDW47W+klAkHew56a 2W5OMyFOTJmXsVT5ETL7ck42vyFPTugKtM9M5pxmfAloxRQo4kqtZE+7Ig9bAlilN6N+ Xj48m0+LYl6kOx+D7P5/MUB7wVWiOKlpm+1FiXLjDNfv14jPHAVxPZF+4NbyOWMkyajt NfYif2Jp42/SPKVTI6o0GzYcv+jJVpbP8qCbbR9qJ41+02K7X2oDtocSruSSHI+wfzE4 6zNhoUPLJcWgLpngoIcl9nOmuRYUOKl6UtA85P8na522ytOHPZn2/UxSSbYS7lN0ryp1 YAIw== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s+E1myvL+FQNMLBHh7YhNNO6xrcap4dEx+GlOPcwYn0=; b=gA/OMO/VGUOU9VBEGvKAeFUuOy62bGQdFidrih+c9f5augW4Ct/7RQuN5/AA0E7B/j J95uYt+iWUlHxwUD2JEVU30JWQXLItmqwxFTevtnlFi9BQ3brpRot2J1sbuC+e6w6Ynr +ZZi4QEGFNvHm27aqr4VeKmyYTw7PhkeXJ7sTfbWGhjuw+SkMLb37mxpsO6xRSLn9PO+ 0h96kkUvnXyTzFxLTW+JfLUTLdSMCcho5OBHbk+6GfoAnal20DNEVGfeONZYjaAts2CU hlhnNbrJ2XLGxcbycgEc6A76a7t2j6Wpo865NdZvXXEHz7dTFSqDZGFNCkSgUEeZiWIO v//w== X-Gm-Message-State: AOAM531HLtPkwowqE3SFl9/wSZZ7SUBdSZSmaEH9qDArA7t+UVVSp1pL IbKXl1tFdZCIxQjko2DBTkE= X-Received: by 2002:a17:90b:4a0b:: with SMTP id kk11mr514890pjb.95.1614299248296; Thu, 25 Feb 2021 16:27:28 -0800 (PST) Received: from shinobu (113x37x72x20.ap113.ftth.ucom.ne.jp. [113.37.72.20]) by smtp.gmail.com with ESMTPSA id q4sm7800846pfq.103.2021.02.25.16.27.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 16:27:27 -0800 (PST) Date: Fri, 26 Feb 2021 09:27:19 +0900 From: William Breathitt Gray To: Pavel Machek Cc: Jonathan Cameron , kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de Subject: Re: [PATCH v8 18/22] docs: counter: Document character device interface Message-ID: References: <350cafba81d3220b64efdb019bd76c08eb1e5d10.1613131238.git.vilhelm.gray@gmail.com> <20210214174819.6757e2b0@archlinux> <20210222101133.GB14587@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EjvxlyKqXuKwBAVF" Content-Disposition: inline In-Reply-To: <20210222101133.GB14587@amd> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EjvxlyKqXuKwBAVF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 22, 2021 at 11:11:33AM +0100, Pavel Machek wrote: > Hi! >=20 > > > +* COUNTER_ENABLE_EVENTS_IOCTL: > > > + Enables monitoring the events specified by the Counter watches that > > > + were queued by ``COUNTER_ADD_WATCH_IOCTL``. If events are already > > > + enabled, the new set of watches replaces the old one. Calling this > > > + ioctl also has the effect of clearing the queue of watches added by > > > + ``COUNTER_ADD_WATCH_IOCTL``. > > > + > > > +* COUNTER_DISABLE_EVENTS_IOCTL: > > > + Stops monitoring the previously enabled events. > >=20 > > Is there a way to remove a watch?=20 >=20 > Is there a way to eat all kernel memory and crash the system by adding > too many watches? There can only ever be as many watches as there are Counter components for the respective Counter device. This is enforced by counter_set_event_node() which checks whether a particular watch has been created before and returns an EINVAL if it so has. > > > +For example, the following userspace code opens ``/dev/counter0``, > > > +configures the ``COUNTER_EVENT_INDEX`` event channel 0 to gather Cou= nt 0 > > > +and Count 1, and prints out the data as it becomes available on the > > > +character device node:: > > > + > >=20 > > Consider adding an example program under tools/ > >=20 > > > + #include > > > + #include > > > + #include > > > + #include > > > + #include > > > + #include > > > + > > > + struct counter_watch watches[2] =3D { > > > + { > > > + .component.type =3D COUNTER_COMPONENT_COUNT, > > > + .component.scope =3D COUNTER_SCOPE_COUNT, > > > + .component.parent =3D 0, > >=20 > > Good to add comments on what these elements actually are? >=20 > > > + fd =3D open("/dev/counter0", O_RDWR); > > > + > > > + ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches); > > > + ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches + 1); > > > + ioctl(fd, COUNTER_ENABLE_EVENTS_IOCTL); >=20 > > > + for (;;) { > > > + read(fd, event_data, sizeof(event_data)); >=20 > If this goes to tools it really should have error handling and > handling of short read. >=20 > Best regards, > Pavel >=20 > --=20 > http://www.livejournal.com/~pavelmachek Ack. I'll improve the error handling for this. William Breathitt Gray --EjvxlyKqXuKwBAVF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAmA4QGcACgkQhvpINdm7 VJKWJw/9GRJWjfb/0hc9uFqEfRRMHfpTYcUMnoHAZLdRvq4x0y+IvSO+GwI+knBV /peeZ3Pb7Y+LgR859jKBq3eGAjQutYpTGf06a8KyWFBmC8mZklZGfMrxNRsQfvCJ Ug2UrJRi/pfFN+/NuFBws/oEORNMkra+xF81HOc877HJXVchWEwoHos7mNVGrBeZ iLJOOLW6s5o4CrjJE9voDUthSCkZBvqjZo6Y0ulFyX/Z2rMv9Ey0v/+rRzAbWRRo 4/T4ITdlDxN56OX0HV5CMMt1gZhACQDdNLO8owXc+8qXxGPsKnyHhYbswFVk7iv6 xS05D4XJnic6orhBlvWq6WJ43IgHGtLTmOrbdpeuP8DBpHBZx50EDpNysajG2sr9 5v7twAvRJGVe1boJryMZ1sfb0/07CxvifSeJNzvrK/wHjHQyZk62w3Jx9eZ5t45c 8mqSyUbpSFdoUN2XivYYXpAu+m0myUKFr2iGT9uATuW+xLFb1T6qv4sKwgQpNv7c hLS1OFzLHSy9QsOOM0/oU4Ian53VZKMk+BNck2shidCXIYzt8vsqJgqHYpOV41MK YpnCriW4/fTS1LQoBDJKPNREtN7X7+QA3O+TvsPwnIxlBgnDmzuK85N3ofg55Eyy N51/6UHDZLWvqY+jrzrB1ZHHDiMQfNYmbMqEfl3nha1c4hC02QU= =ULaJ -----END PGP SIGNATURE----- --EjvxlyKqXuKwBAVF--