From: Arnd Bergmann <arnd@arndb.de>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Prarit Bhargava <prarit@redhat.com>,
"Greg Kroah-Hartman" <greg@kroah.com>,
Dave Young <dyoung@redhat.com>
Subject: Re: [PATCH 1/2] lkdtm: use atomic_t to replace count_lock
Date: Thu, 2 Feb 2012 13:44:19 +0000 [thread overview]
Message-ID: <201202021344.19455.arnd@arndb.de> (raw)
In-Reply-To: <4F2A90B4.1050709@gmail.com>
On Thursday 02 February 2012, Cong Wang wrote:
> > In order to have an atomic here, you have to use a loop around
> > atomic_cmpxchg, like
> >
> >
> > int old, new;
> > old = atomic_read(&count);
> > do {
> > new = old ? old - 1 : cpoint_count;
> > old = cmpxchg(&count, old, new);
> > } while (old != new);
> >
> > I suppose you could also just keep the spinlock and move lkdtm_do_action()
> > outside of it?
>
> If we still need spinlock, I think we don't need to bother atomic_t at all.
Yes, it's one or the other: If you use the cmpxchg loop, you don't need a
spinlock and vice versa.
Arnd
next prev parent reply other threads:[~2012-02-02 13:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-01 6:58 Cong Wang
2012-02-01 6:58 ` [PATCH 2/2] lkdtm: avoid calling sleeping functions in interrupt context Cong Wang
2012-02-01 15:27 ` [PATCH 1/2] lkdtm: use atomic_t to replace count_lock Arnd Bergmann
2012-02-02 13:33 ` Cong Wang
2012-02-02 13:44 ` Arnd Bergmann [this message]
2012-02-02 14:27 ` Cong Wang
2012-02-02 14:55 ` Arnd Bergmann
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=201202021344.19455.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=dyoung@redhat.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prarit@redhat.com \
--cc=xiyou.wangcong@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome