linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Thornber <thornber@redhat.com>
To: Pranith Kumar <bobby.prani@gmail.com>
Cc: Anssi Hannula <anssi.hannula@iki.fi>,
	ejt@redhat.com, snitzer@redhat.com,
	LKML <linux-kernel@vger.kernel.org>,
	torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] dm cache: fix race affecting dirty block count
Date: Mon, 4 Aug 2014 11:48:26 +0100	[thread overview]
Message-ID: <20140804104826.GA494@debian> (raw)
In-Reply-To: <CAJhHMCC8hDVzeYM1OL1VhTEw=+RrpVK_fQYCbKpnJvBUEP3LyQ@mail.gmail.com>

On Sun, Aug 03, 2014 at 12:01:17AM -0400, Pranith Kumar wrote:
> Also dm_cblock_t is uint32_t, but atomic_t changes that to int. You
> should correct that to atomic64_t to preserve original semantics.

atomic_t used to have only 24 bits of range due to the Sparc
implementation holding a lock in one of the bytes.  I understand this
limitation was removed during 2.6 and the full 32 bits are now
available.

eg,

    https://github.com/jthornber/linux-2.6/commit/37682177af68478fa83429b735fa16913c2fbb2b

> These increments and decrements will still be lost if you do not use
> barriers in presence of concurrent accesses. Please see
> Documentation/memory-barriers.txt.

You do not need to use barriers for plain atomic_inc/dec().

    https://github.com/jthornber/linux-2.6/blob/thin-dev/Documentation/atomic_ops.txt#L187

You _do_ need to use a memory barrier for the ops that return a value
(such as atomic_dec_and_test()), But only if there's some other state
that needs synchronising.  See the nice example in atomic_ops.txt:

    https://github.com/jthornber/linux-2.6/blob/thin-dev/Documentation/atomic_ops.txt#L321

We just trigger a stateless event when the counter hits zero, so the
patch is fine.

- Joe

  reply	other threads:[~2014-08-04 10:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-03  2:00 [PATCH] dm cache: fix race affecting dirty block count Pranith Kumar
2014-08-03  2:08 ` Pranith Kumar
2014-08-03  2:10 ` Pranith Kumar
2014-08-03  3:33   ` Anssi Hannula
2014-08-03  4:01     ` Pranith Kumar
2014-08-04 10:48       ` Joe Thornber [this message]
2014-08-04 15:02         ` Pranith Kumar
2014-08-03  4:46   ` Pranith Kumar
2014-08-03  4:57     ` Pranith Kumar
2014-08-03  5:17       ` Pranith Kumar
2014-08-03  5:28         ` Pranith Kumar

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=20140804104826.GA494@debian \
    --to=thornber@redhat.com \
    --cc=anssi.hannula@iki.fi \
    --cc=bobby.prani@gmail.com \
    --cc=ejt@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@redhat.com \
    --cc=torvalds@linux-foundation.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).