From: Stephane Ouellette <ouellettes@videotron.ca>
To: Henrik Nordstrom <hno@marasystems.com>
Cc: Netfilter Development Mailinglist <netfilter-devel@lists.netfilter.org>
Subject: Re: [PATCH] for some issues in tcp window tracking patch
Date: Sat, 22 May 2004 09:04:02 -0400 [thread overview]
Message-ID: <40AF4FC2.1060808@videotron.ca> (raw)
In-Reply-To: Pine.LNX.4.44.0405220040040.28306-100000@filer.marasystems.com
Henrik Nordstrom wrote:
>On Fri, 21 May 2004, Patrick McHardy wrote:
>
>
>
>>I missed that question. It's probably not neccessary, we will get a
>>small race when zapping conntracks, but according to this comment in
>>unreplied() we already have one anyway.
>>
>>
>
>What I thought.. a __set_bit should be sufficient here, right?
>
>Is there any good description somewhere on how these memory barriers
>works and when they are needed, or more precisely what is the difference
>between set_bit and __set_bit in terms of when/how/why each should be
>used?
>
>
Henrick,
some CPUs can reorder memory accesses in order to optimize bus
usage. Compilers can reorder instructions to optimize cache and
register usage. Memory barriers are used to avoid races when the order
of execution is important.
For example, suppose you create a proc file with create_proc_entry() :
myprocfile = create_proc_entry( . . . );
myprocfile->fops = my_driver_proc_fops;
myprocfile->data = &my_data_structure;
.
.
.
Many people don't check that "data" is not NULL in the file
operation procedures and that's OK as long as you can make sure that the
"data" pointer is set BEFORE you set the "fops" pointer... So, here's
our example reworked :
myprocfile = create_proc_entry( . . . );
myprocfile->data = &my_data_structure;
myprocfile->fops = my_driver_proc_fops;
.
.
.
This is much better but still imperfect. GCC could reorder the
instructions to better use the cache and/or processor registers. We
need to introduce a write memory barrier to GARANTEE that the "data"
pointer is set BEFORE the "fops" pointer :
myprocfile = create_proc_entry( . . . );
myprocfile->data = &my_data_structure;
wmb();
myprocfile->fops = my_driver_proc_fops;
.
.
.
In this case, a write memory barriers forbids write accesses to cross
the barrier in either direction. That's our garantee that "data" is
ALWAYS valid inside the file operation procedures...
Regards,
Stephane Ouellette
>But in this case there is many races.. a test_bit followed by a set_bit
>is not atomic unles governed by a surrounding lock independent of if
>there is memory barriers of not around the operations, and the flushing of
>unconfirmed sessions is inherently racy anyway without strict locking. If
>there is strict locking then memory barriers in the set_bit should be
>completely irrelevant. Right?
>
>Regards
>Henrik
>
>
>
next prev parent reply other threads:[~2004-05-22 13:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-16 23:48 [PATCH] for some issues in tcp window tracking patch Pablo Neira
2004-05-16 23:51 ` Pablo Neira
2004-05-17 13:00 ` Jozsef Kadlecsik
2004-05-17 21:41 ` Patrick McHardy
2004-05-18 9:57 ` Pablo Neira
2004-05-18 21:10 ` Pablo Neira
2004-05-19 8:51 ` Jozsef Kadlecsik
2004-05-19 10:14 ` Pablo Neira
2004-05-20 11:27 ` Jozsef Kadlecsik
2004-05-20 23:18 ` Pablo Neira
2004-05-21 1:40 ` Henrik Nordstrom
2004-05-21 2:23 ` Patrick McHardy
2004-05-21 9:58 ` Henrik Nordstrom
2004-05-21 16:07 ` Patrick McHardy
2004-05-21 22:56 ` Henrik Nordstrom
2004-05-22 13:04 ` Stephane Ouellette [this message]
2004-05-22 14:31 ` Patrick McHardy
2004-05-21 9:33 ` Pablo Neira
2004-05-21 8:11 ` Willy Tarreau
2004-05-21 10:06 ` Pablo Neira
2004-05-21 10:14 ` Pablo Neira
2004-05-21 12:13 ` Jozsef Kadlecsik
2004-05-21 23:01 ` Pablo Neira
2004-05-22 12:54 ` Jozsef Kadlecsik
2004-06-01 9:48 ` Jozsef Kadlecsik
2004-06-01 12:26 ` Pablo Neira
2004-06-02 5:13 ` Willy Tarreau
2004-06-08 9:55 ` Jozsef Kadlecsik
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=40AF4FC2.1060808@videotron.ca \
--to=ouellettes@videotron.ca \
--cc=hno@marasystems.com \
--cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.