From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Jarkko Sakkinen
<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: ops_sem and tpm_mutex
Date: Tue, 5 Jul 2016 10:01:00 -0600 [thread overview]
Message-ID: <20160705160100.GA715@obsidianresearch.com> (raw)
In-Reply-To: <20160705110647.GA28275-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Tue, Jul 05, 2016 at 02:06:47PM +0300, Jarkko Sakkinen wrote:
> This is the basic pattern. Basically we always loose the benefit of
> RW-lock because in every use case we also lock a mutex.
The only purpose of the rw lock is protect against unregister, and
that is the benifit it provides.
> What I was thinking that maybe we could have kref for ops instead
> of lock. In the places where we now use read lock you could use
> kref_get_unless_zero() to avoid races with tpm_chip_unregister().
No, it needs to be a lock, the unregister path must block and sleep,
and a kref cannot do that alone, by the time you build in the locking
you've made something more expensive than a rwlock.
The performance alternative is to use srcu for the rwlock, but since
we don't really have a performance concern in TPM I would rather not
see such complexity.
Another alternative would be to merge the rw-lock and mutex together
(ie hold mutex before touching ops at all), however this semantically
changes things by linking the lifetime and concurrancy models
together.
I belive I looked at that before doing the rwsem and decided it was a
huge amount of tricky work.
Jason
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
prev parent reply other threads:[~2016-07-05 16:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-05 11:06 ops_sem and tpm_mutex Jarkko Sakkinen
[not found] ` <20160705110647.GA28275-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-07-05 16:01 ` Jason Gunthorpe [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=20160705160100.GA715@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).