public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Nicholas Murphy <nmurphy@eecs.harvard.edu>
To: Josh Stone <jistone@redhat.com>
Cc: systemtap@sourceware.org
Subject: Re: associative array synchronization question
Date: Fri, 20 Jul 2012 20:37:00 -0000	[thread overview]
Message-ID: <5096CB06-32BC-4DFD-8B7B-2912830C3573@eecs.harvard.edu> (raw)
In-Reply-To: <5009BB84.5060308@redhat.com>

Thank you!  That's clearer.

What does it mean that you "sometimes" fail to take a lock?  Do you just skip executing the probe if you determine that you can't get the lock?

Thanks,
Nick

On Jul 20, 2012, at 4:11 PM, Josh Stone wrote:

> On 07/20/2012 12:47 PM, Nicholas Murphy wrote:
>> Sorry for the very basic question:
> 
> No need to apologize.
> 
>> it says in the documentation that any probe using an associative
>> array (which is necessarily global) will automatically hold a lock on
>> that array for the duration of the probe...is that true regardless of
>> whether the probe actually touches the array?  Or does it only lock
>> on first access?
> 
> When we take locks, we use the trylock functions (with a little spinning
> and waiting), so we won't ever block forever.  That means sometimes we
> can fail to take a lock.
> 
> We also chose to make probe handlers atomic, such that if a probe
> handler runs at all, it must run in full.  We don't want to get into a
> situation where a lock in the middle of a probe can't be obtained, thus
> ruining that probe's execution flow.
> 
> Therefore, all locks needed for a handler are attempted before anything
> is started in that handler, and held until the handler is done.  If any
> of the locks can't be obtained, the probe is skipped entirely.
> 
> So for your case, where you may be conditionally writing an array, we
> will be grabbing the write lock regardless of the condition (which we
> don't know at that time).
> 
> If your data values can fit stats types (various numeric accumulation),
> and you'll be writing values more often than you read, then a stats
> array may be a better locking choice, because it only needs a fully
> exclusive lock when reading instead.
> 
> Hope that helps, and feel free to ask followup questions.
> 
> Josh

  reply	other threads:[~2012-07-20 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 19:47 Nicholas Murphy
2012-07-20 20:12 ` Josh Stone
2012-07-20 20:37   ` Nicholas Murphy [this message]
2012-07-20 21:20     ` Josh Stone

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=5096CB06-32BC-4DFD-8B7B-2912830C3573@eecs.harvard.edu \
    --to=nmurphy@eecs.harvard.edu \
    --cc=jistone@redhat.com \
    --cc=systemtap@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).