From: Takashi Iwai <tiwai@suse.de>
To: Ricard Wanderlof <ricard.wanderlof@axis.com>
Cc: "Arvid Nihlgård Lindell" <arvidnl@axis.com>,
"Andreas x Larsson" <andrelan@axis.com>,
alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] alsa-lib:Make snd_atomic_write_* truly atomic
Date: Tue, 17 May 2016 17:37:32 +0200 [thread overview]
Message-ID: <s5hfutgn1ab.wl-tiwai@suse.de> (raw)
In-Reply-To: <alpine.DEB.2.02.1605171718010.31333@lnxricardw1.se.axis.com>
On Tue, 17 May 2016 17:28:43 +0200,
Ricard Wanderlof wrote:
>
>
> On Tue, 17 May 2016, Takashi Iwai wrote:
>
> > No, my proposal is to make all snd_atomic_*() NOP unless a configure
> > option is passed.
>
> Ok, I must honestly say I hadn't studied the actual pcm_plugin.c code in
> great detail before (I didn't create the patch but was in the train of
> discussion at the time). I had just assumed that the w->begin and w->end
> variables were some form of counters used outside the atomic functions,
> but I can see now that they are not.
>
> Looking at it now it appears that all this atomic stuff is trying to
> accomplish is to avoid the (sole) read in snd_pcm_plugin_status() from
> happening during one of the many potential writes in the other functions
> in the file, and the only reason for that in turn seems to be to get the
> acceses to *pcm->appl.ptr and *pcm->hw.ptr as well as other things needed
> for the return snd_pcm_status_t* consistent.
>
> But that in turn means that fixing the atomicity of the w->begin and
> w->end accesses as proposed in the patch just glosses over that particular
> implementation issue; if indeed something is calling the functions doing
> the writes concurrently, something else is bound to get screwed up, unless
> by chance the two calls touch different variables, or the timing is such
> that two things aren't touched at the same time.
>
> Right now it feels a bit uncomfortable to fix it in this way. It's just
> luck if it doesn't die somewhere else. Or am I missing something (highly
> likely)?
Right, the current atomic ops usage is only covering the very light
locking scheme that might casually work for some cases. But it never
works for heavy use, and a more proper way of concurrent accesses
would be needed in anyway. That's the reason I proposed to drop off
these. This makes things looking safe although they are not really
usable.
But how dangerous is this move? I'm not 100% sure so far...
Takashi
prev parent reply other threads:[~2016-05-17 15:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 10:42 [PATCH] alsa-lib:Make snd_atomic_write_* truly atomic Andreas x Larsson
2016-04-13 13:49 ` Takashi Iwai
2016-05-12 12:51 ` Ricard Wanderlof
2016-05-12 13:04 ` Takashi Iwai
2016-05-12 14:17 ` Ricard Wanderlof
2016-05-12 14:47 ` Takashi Iwai
2016-05-12 16:09 ` Ricard Wanderlof
2016-05-13 12:26 ` Ricard Wanderlof
2016-05-13 12:37 ` Takashi Iwai
2016-05-17 12:11 ` Ricard Wanderlof
2016-05-17 12:21 ` Takashi Iwai
2016-05-17 13:29 ` Ricard Wanderlof
2016-05-17 13:37 ` Takashi Iwai
2016-05-17 15:28 ` Ricard Wanderlof
2016-05-17 15:37 ` Takashi Iwai [this message]
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=s5hfutgn1ab.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=andrelan@axis.com \
--cc=arvidnl@axis.com \
--cc=ricard.wanderlof@axis.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.