From: Valentin Vidic <Valentin.Vidic@CARNet.hr>
To: Marcus Wolf <marcus.wolf@smarthome-wolf.de>
Cc: devel@driverdev.osuosl.org, "Derek Robson" <robsonde@gmail.com>,
"Michael Panzlaff" <michael.panzlaff@fau.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Luca Söthe" <luca@acul.me>,
linux-kernel@vger.kernel.org,
"Marcin Ciupak" <marcin.s.ciupak@gmail.com>,
"Marcus Wolf" <linux@Wolf-Entwicklungen.de>,
"Simon Sandström" <simon@nikanor.nu>
Subject: Re: [PATCH] staging: pi433: add descriptions for mutex locks
Date: Fri, 23 Mar 2018 23:18:21 +0100 [thread overview]
Message-ID: <20180323221821.GP31333@gavran.carpriv.carnet.hr> (raw)
In-Reply-To: <20180323180027.GM31333@gavran.carpriv.carnet.hr>
On Fri, Mar 23, 2018 at 07:00:27PM +0100, Valentin Vidic wrote:
> You are right, here is what kfifo.h says:
>
> /*
> * Note about locking : There is no locking required until only * one reader
> * and one writer is using the fifo and no kfifo_reset() will be * called
> * kfifo_reset_out() can be safely used, until it will be only called
> * in the reader thread.
> * For multiple writer and one reader there is only a need to lock the writer.
> * And vice versa for only one writer and multiple reader there is only a need
> * to lock the reader.
> */
>
> In the case of pi433 there is only one reader (pi433_tx_thread) and
> there is no need for a lock there. But the char device (pi433_write)
> might have multiple writers so we leave the mutex just in that function?
Ah, but there is a kfifo_reset call in pi433_write that requires a
mutex for both readers and writers:
"Usage of kfifo_reset is dangerous. It should be only called when the
fifo is exclusived locked or when it is secured that no other thread is
accessing the fifo."
Also kfifo_reset_out would probably not help here:
"The usage of kfifo_reset_out is safe until it will be only called from
the reader thread and there is only one concurrent reader. Otherwise it
is dangerous and must be handled in the same way as kfifo_reset."
But I have an idea to remove this kfifo_reset call in pi433_write
handling partial message writes:
kfifo_reset(&device->tx_fifo); // TODO: maybe find a solution, not to discard already stored, valid entries
The writer could acquire the lock and than use kfifo_avail to check if
there is enough space to write the whole message. What do you think?
--
Valentin
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2018-03-23 22:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 9:47 Valentin Vidic
2018-03-23 10:22 ` Marcus Wolf
2018-03-23 11:42 ` Valentin Vidic
2018-03-23 15:38 ` Marcus Wolf
2018-03-23 18:00 ` Valentin Vidic
2018-03-23 22:18 ` Valentin Vidic [this message]
2018-03-24 22:09 ` [PATCH] staging: pi433: cleanup tx_fifo locking Valentin Vidic
2018-03-25 13:00 ` [PATCH] staging: pi433: add descriptions for mutex locks Marcus Wolf
2018-03-25 13:09 ` Valentin Vidic
2018-03-25 13:12 ` Marcus Wolf
2018-03-25 14:24 ` Valentin Vidic
2018-04-08 14:15 ` Marcus Wolf
2018-04-12 17:15 ` Valentin Vidic
2018-04-19 9:25 ` Marcus Wolf
2018-04-19 9:47 ` Valentin Vidic
2018-04-19 9:55 ` Marcus Wolf
2018-04-08 15:22 ` Marcus Wolf
2018-04-12 18:46 ` Valentin Vidic
2018-04-19 9:33 ` Marcus Wolf
2018-04-19 10:25 ` [PATCH v2] staging: pi433: cleanup tx_fifo locking Valentin Vidic
2018-04-19 10:40 ` Marcus Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180323221821.GP31333@gavran.carpriv.carnet.hr \
--to=valentin.vidic@carnet.hr \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@Wolf-Entwicklungen.de \
--cc=luca@acul.me \
--cc=marcin.s.ciupak@gmail.com \
--cc=marcus.wolf@smarthome-wolf.de \
--cc=michael.panzlaff@fau.de \
--cc=robsonde@gmail.com \
--cc=simon@nikanor.nu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®