From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF6E9C433E0 for ; Fri, 26 Feb 2021 00:29:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7B5064EBA for ; Fri, 26 Feb 2021 00:29:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7B5064EBA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y1W5xWQ9waSm4XrFlxe5wnz3SZlZGZki9GZTPD2PuA0=; b=z+XHS8c6Lnbkrw8unxqESTm5g lKfnq9sjZ7Ifmjfc/bgybrdupuYjyhZeDUhRuIZn6igkGl8dtnl4P8eI1ZcPy9Mdt9hmAXI02GTNC jQJTp8Ym0SxrJmZHQ/SE8tToCwOJDRBaPuUdUjWn2xn0P2c3JJryDL2jd/TRLRFM6UkvRLKQfxILT MdM4cgz25nzV7VQ0n3xB0sVvEIHtkOtPloPwNyjg9Hf9pRFj3y8kTVXlghffsciN5/SXp0WutwuLr AK9NAkPfMZpT/7TX63XQmduZvJDwh5l/LOosliG+6IqgLLjQHGJ/OlU7VxLbFZz5/vn9dR9+3r7vR F4E4F+8/g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFQyj-0007Mn-HF; Fri, 26 Feb 2021 00:27:33 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lFQyg-0007MN-FX for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2021 00:27:31 +0000 Received: by mail-pj1-x1030.google.com with SMTP id s23so4793934pji.1 for ; Thu, 25 Feb 2021 16:27:30 -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=lbZv9wWU12kk3Ii/JuqCY5QmsjHhgjyw4GY3zJVJ7vC1Uq6XlqcmjEFCW2GJMkCDM9 5YVtQsB2Uzu4xrrnbemPmPlaJVcEk6T33zi0fuZdb369Kw23QuoH1DYvXoAYN1EBZbVn KXczuxe9RrGX1QCF1eq46Smn+GzCNFX3qV/vZ4VySS0Vk/7lE6dVFRKS9TPH6fEOaj8c MdIAq10FTOR0tD4thLQGCevzMh/VjnzM77Fe0KfWBiLc6JS9EMroE4bdPMIs9yklONp5 LzKpTcTGBh8l1YdXBt2XNcIe1kxQjP/T1wbSrWn+R53+9B5bgVTNHK3bWwcvBAHGj6ZS j31w== X-Gm-Message-State: AOAM532ZFd1iDkvvJJPH4O6jsPnmqKs7JUEOlgjNqocUfdRl7Zhm3nik uggFCjlZFOBuNs7YQROxawOS0v8W8i/VHg== X-Google-Smtp-Source: ABdhPJyBWK8l+Vs9F7nSxWHA9Ox00Bl2mkrTMaen0lTs6mgq6C+dK8ZKuwfA4zP9ufteNrOiEt1yzw== 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 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 In-Reply-To: <20210222101133.GB14587@amd> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210225_192730_589009_28C54006 X-CRM114-Status: GOOD ( 22.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org, a.fatoum@pengutronix.de, david@lechnology.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org, o.rempel@pengutronix.de, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, fabrice.gasnier@st.com, syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, Jonathan Cameron , alexandre.torgue@st.com Content-Type: multipart/mixed; boundary="===============5745512661536502380==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============5745512661536502380== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EjvxlyKqXuKwBAVF" Content-Disposition: inline --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-- --===============5745512661536502380== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============5745512661536502380==--