mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mihai Donțu" <mihai.dontu@gmail.com>
To: "Rogelio M. Serrano Jr." <rogelios664@gmail.com>
Cc: linux-kernel@vger.kernel.org, pageexec@freemail.hu
Subject: Re: atomic_inc and spin_lock_irq
Date: Fri, 19 Dec 2014 00:04:16 +0200	[thread overview]
Message-ID: <20141219000416.689f3ab7@mdontu-l.dsd.ro> (raw)
In-Reply-To: <CAB_-8bLk-HVWB6Mmt=rjDguou1kbGQ9c7o5nQxV3zAg+Txf7GQ@mail.gmail.com>

On Thu, 18 Dec 2014 21:07:46 +0000 Rogelio M. Serrano Jr. wrote:
> whats the difference between:
> 
> atomic_inc(&port->count);

It is intended to atomically increment a variable of a standard size
(int/long). See [1] for more information.

> and
> 
> spin_lock_irq(&port->lock);
> ++port->count;
> spin_unlock_irq(&port->lock);

These are intended to be used when larger changes are to be made in an
atomic fashion (not just increments). See [2] for details and [3] for
an example.

[1] https://en.wikipedia.org/wiki/Fetch-and-add
[2] http://lxr.free-electrons.com/source/include/linux/spinlock_api_smp.h#L104
[3] http://lxr.free-electrons.com/source/arch/x86/mm/mmio-mod.c#L265

-- 
Mihai Donțu

  reply	other threads:[~2014-12-18 22:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 21:07 Rogelio M. Serrano Jr.
2014-12-18 22:04 ` Mihai Donțu [this message]
2014-12-23  2:08 ` PaX Team

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=20141219000416.689f3ab7@mdontu-l.dsd.ro \
    --to=mihai.dontu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pageexec@freemail.hu \
    --cc=rogelios664@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

all inboxes | Powered by JetHome®