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=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 BA686C433DF for ; Tue, 13 Oct 2020 19:11:09 +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 3B2C820E65 for ; Tue, 13 Oct 2020 19:11:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xSarvDsq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lechnology.com header.i=@lechnology.com header.b="kTfO6894" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B2C820E65 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lechnology.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: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Gal+JaUgg+BN4aRwDP68/aUhY/YkLdJR7nBY9ItyXCE=; b=xSarvDsqD7UzCZywGOxq2bplL Nk03WB1VXQyA2VugnU7tHsX+nzqmX9P4hjsruimqAYE/EBKACHEFFbls5hAc31fzBF4JL+fxAXI6Z 3Y8VMr2RFTnc+Lyd6sZW8qcewn0P5uQoDBcEj6nH5PLt1SERZ5JmoBqUnF35al1jKO4ep8E90sWwF NfkWvSkPzQEkZnE2InyxflAP5T5oNiNT2/0Z0OUIX9DSocsh91cV30JZBQA+7HlLxuBeFq+6brSnT 6nbC97NVEBZdRBW7Dq8OVmxiGwe0+t5hMencMlkzIUxojAmL6cA1Mt3Qzl0jLSo00Jh6xKddGFtkQ V3jEUcyQg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSPg1-0004wL-6p; Tue, 13 Oct 2020 19:09:37 +0000 Received: from vern.gendns.com ([98.142.107.122]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSPfx-0004uF-If for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2020 19:09:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jZT/uATnG2o72Hv+NB/ghQjoMMH5tGI4CdsZ0nvbYXk=; b=kTfO6894m4jP1mJIN/flhtoo/a g1XiQfEPqz80vbKG6Ek+ynL5NI+k2zab9L+m8isH4nWfGnfXzd1KDmtpQKzFX8Acl+xH8BYq5i9yW lgf6u9u9o1EhfQBL89Ysofjg/8Q9a0P+obRGTgPbKEJPkD5KswaytWNV6uppa+cEaSND3zWnWsGRT vYzUvOwI9NcxfPHNqYMEF8BEKRPb79I1MWzDmSudVLkNA5aHpfn5VNemgra9u2omslowqwLxsyWp9 wf2QDnIFcu5sI7dU764T4K1bRqqPoAHZ4X9CdfclQzFkEtvSquFuchm8/OA8LiIKI3HiSp9B5183C gpGLHsog==; Received: from [2600:1700:4830:165f::19e] (port=47662) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kSPfD-0001IG-Hd; Tue, 13 Oct 2020 15:08:47 -0400 Subject: Re: [PATCH v5 4/5] docs: counter: Document character device interface To: William Breathitt Gray References: <54190f9875b81b6aa5483a7710b084053a44abb8.1601170670.git.vilhelm.gray@gmail.com> <20201008080909.GA31561@amd> <20201008122845.GA3314@shinobu> <20201013185851.GB32722@shinobu> From: David Lechner Message-ID: <09949c56-19da-1937-418b-99a1a9260c4c@lechnology.com> Date: Tue, 13 Oct 2020 14:08:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201013185851.GB32722@shinobu> Content-Language: en-US X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201013_150933_664304_697C6CE0 X-CRM114-Status: GOOD ( 18.53 ) 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, mcoquelin.stm32@gmail.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Pavel Machek , syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, jic23@kernel.org, alexandre.torgue@st.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/13/20 1:58 PM, William Breathitt Gray wrote: > On Mon, Oct 12, 2020 at 12:04:10PM -0500, David Lechner wrote: >> On 10/8/20 7:28 AM, William Breathitt Gray wrote: >>> On Thu, Oct 08, 2020 at 10:09:09AM +0200, Pavel Machek wrote: >>>> Hi! >>>> >>>>> + int main(void) >>>>> + { >>>>> + struct pollfd pfd = { .events = POLLIN }; >>>>> + struct counter_event event_data[2]; >>>>> + >>>>> + pfd.fd = open("/dev/counter0", O_RDWR); >>>>> + >>>>> + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches); >>>>> + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches + 1); >>>>> + ioctl(pfd.fd, COUNTER_LOAD_WATCHES_IOCTL); >>>>> + >>>>> + for (;;) { >>>>> + poll(&pfd, 1, -1); >>>> >>>> Why do poll, when you are doing blocking read? >>>> >>>>> + read(pfd.fd, event_data, sizeof(event_data)); >>>> >>>> Does your new chrdev always guarantee returning complete buffer? >>>> >>>> If so, should it behave like that? >>>> >>>> Best regards, >>>> Pavel >>>> -- >>>> (english) http://www.livejournal.com/~pavelmachek >>>> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html >>> >>> I suppose you're right: a poll() should be redundant now with this >>> version of the character device implementation because buffers will >>> always return complete; so a blocking read() should achieve the same >>> behavior that a poll() with read() would. >>> >>> I'll give some more time for additional feedback to come in for this >>> version of the patchset, and then likely remove support for poll() in >>> the v6 submission. >>> >>> William Breathitt Gray >>> >> >> I hope that you mean that you will just remove it from the example >> and not from the chardev. Otherwise it won't be possible to >> integrate this with an event loop. > > Would you elaborate a bit further on this? My thought process is that > because users must set the Counter Events they want to watch, and only > those Counter Events show up in the character device node, a blocking > read() would effectively behave the same as poll() with read(); if none > of the Counter Events occur, the read() just blocks until one does, thus > making the use of a poll() call redundant. > > William Breathitt Gray > If the counter device was the only file descriptor being read, then yes it wouldn't matter. But if we are using this in combination with other file descriptors, then it is common to poll all of the file descriptors using a single syscall to see which one is ready to read rather than doing a non-blocking read on all of the file descriptors, which would result in many unnecessary syscalls. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel