Re: [PATCH V6 02/16] rv: Add runtime reactors interface
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH V6 02/16] rv: Add runtime reactors interface
- From: Steven Rostedt <rostedt@xxxxxxxxxxx>
- Date: Wed, 20 Jul 2022 13:02:09 -0400
- Cc: Wim Van Sebroeck <wim@xxxxxxxxxxxxxxxxxx>, Guenter Roeck <linux@xxxxxxxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx>, Marco Elver <elver@xxxxxxxxxx>, Dmitry Vyukov <dvyukov@xxxxxxxxxx>, "Paul E. McKenney" <paulmck@xxxxxxxxxx>, Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>, Gabriele Paoloni <gpaoloni@xxxxxxxxxx>, Juri Lelli <juri.lelli@xxxxxxxxxx>, Clark Williams <williams@xxxxxxxxxx>, Tao Zhou <tao.zhou@xxxxxxxxx>, Randy Dunlap <rdunlap@xxxxxxxxxxxxx>, linux-doc@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-trace-devel@xxxxxxxxxxxxxxx
- In-reply-to: <ba11409a-df46-8fad-61a9-256277c588c0@kernel.org>
- References: <cover.1658244826.git.bristot@kernel.org> <4b5f93e3186b067073c1692d4c2b50d0b42101d5.1658244826.git.bristot@kernel.org> <20220720124133.3cdd2c44@gandalf.local.home> <ba11409a-df46-8fad-61a9-256277c588c0@kernel.org>
On Wed, 20 Jul 2022 18:50:39 +0200
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:
> On 7/20/22 18:41, Steven Rostedt wrote:
> > On Tue, 19 Jul 2022 19:27:07 +0200
> > Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:
> >
> >> +/*
> >> + * reacting_on interface.
> >> + */
> >> +static ssize_t reacting_on_read_data(struct file *filp,
> >> + char __user *user_buf,
> >> + size_t count, loff_t *ppos)
> >> +{
> >> + char *buff;
> >> +
> >> + mutex_lock(&rv_interface_lock);
> >> + buff = reacting_on ? "1\n" : "0\n";
> >> + mutex_unlock(&rv_interface_lock);
> > Again, no need for the locks, but perhaps just to keep things sane:
> >
> > buf = READ_ONCE(reacting_on) ? "1\n" : "0\n";
>
> So, for all files that only read/write a single variable, use READ_ONCE/WRITE_ONCE without
> locks? (and in all usage of that variable too).
Only if there's no races.
That is, taking the locks here provide no benefit over a READ_ONCE().
If there was some logic that checks if the value is still valid or not,
then that would be a different story.
For example:
static int enable_monitor(struct rv_monitor_def *mdef)
{
int retval;
if (!mdef->monitor->enabled) {
retval = mdef->monitor->enable();
if (retval)
return retval;
}
mdef->monitor->enabled = 1;
return 0;
}
That has logic that looks to require a lock to protect things from changing
from underneath.
-- Steve
[Index of Archives]
[Linux USB Development]
[Linux USB Development]
[Linux Audio Users]
[Yosemite Hiking]
[Linux Kernel]
[Linux SCSI]