netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Werner Almesberger <wa@almesberger.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: herbert@gondor.apana.org.au, anton@samba.org, okir@suse.de,
	netdev@oss.sgi.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arp_queue: serializing unlink + kfree_skb
Date: Thu, 10 Feb 2005 01:23:04 -0300	[thread overview]
Message-ID: <20050210012304.E25338@almesberger.net> (raw)
In-Reply-To: <20050204222428.1a13a482.davem@davemloft.net>; from davem@davemloft.net on Fri, Feb 04, 2005 at 10:24:28PM -0800

David S. Miller wrote:
> 	This document is intended to serve as a guide to Linux port
> maintainers on how to implement atomic counter and bitops operations
> properly.

Finally, some light is shed into one of the most arcane areas of
the kernel ;-) Thanks !

> Unlike the above routines, it is required that explicit memory
> barriers are performed before and after the operation.  It must
> be done such that all memory operations before and after the
> atomic operation calls are strongly ordered with respect to the
> atomic operation itself.

Hmm, given that this description will not only be read by implementers
of atomic functions, but also by users, the "explicit memory barriers"
may be confusing. Who does them, the atomic_* function, or the user ?
In fact, I would call them "implicit", because they're hidden in the
atomic_foo functions :-)

> 	void smb_mb__before_atomic_dec(void);
> 	void smb_mb__after_atomic_dec(void);
> 	void smb_mb__before_atomic_inc(void);
> 	void smb_mb__after_atomic_dec(void);

s/smb_/smp/ :-)

Do they also work for atomic_add and atomic_sub, or do we have to
fall back to smb_mb or atomic_add_return (see below) there ?

> With the memory barrier semantics required of the atomic_t
> operations which return values, the above sequence of memory
> visibility can never happen.

What happens if the operation could return a value, but the user
ignores it ? E.g. if I don't like smp_mb__*, could I just use

	atomic_inc_and_test(foo);

instead of

	smp_mb__before_atomic_inc();
	atomic_inc(foo);
	smp_mb__after_atomic_dec();

? If yes, is this a good idea ?

> These routines, like the atomic_t counter operations returning
> values, require explicit memory barrier semantics around their
> execution.

Very confusing: the barriers aren't around the routines (that
is something the user would be doing), but around whatever does
the atomic stuff inside them.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/

  parent reply	other threads:[~2005-02-10  4:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31 10:29 [PATCH] arp_queue: serializing unlink + kfree_skb Olaf Kirch
2005-01-31 11:33 ` Herbert Xu
2005-02-03  0:20   ` David S. Miller
2005-02-03 11:12     ` Herbert Xu
2005-02-04  0:34       ` David S. Miller
2005-02-03 14:27   ` Anton Blanchard
2005-02-03 18:14     ` David S. Miller
2005-02-03 20:30     ` Herbert Xu
2005-02-03 22:19       ` David S. Miller
2005-02-03 23:50         ` Herbert Xu
2005-02-04  0:49           ` David S. Miller
2005-02-04  1:20             ` Herbert Xu
2005-02-04  1:23               ` David S. Miller
2005-02-04  1:55                 ` Herbert Xu
2005-02-04 11:16                   ` Olaf Kirch
2005-02-06  1:14                   ` David S. Miller
2005-02-03 23:08     ` David S. Miller
2005-02-04 11:33       ` Herbert Xu
2005-02-04 23:48         ` David S. Miller
2005-02-05  6:24           ` David S. Miller
2005-02-05  6:50             ` Herbert Xu
2005-02-10  4:23             ` Werner Almesberger [this message]
2005-02-10  4:56               ` Herbert Xu
2005-02-11  3:46                 ` David S. Miller
2005-02-11  3:50               ` David S. Miller
2005-02-11  4:27                 ` Werner Almesberger
2005-02-11  5:04                 ` Dmitry Torokhov

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=20050210012304.E25338@almesberger.net \
    --to=wa@almesberger.net \
    --cc=anton@samba.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=okir@suse.de \
    /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).