From: Eric Dumazet <eric.dumazet@gmail.com>
To: Peter LaDow <petela@gocougs.wsu.edu>
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org,
netfilter@vger.kernel.org
Subject: Re: Process Hang in __read_seqcount_begin
Date: Fri, 26 Oct 2012 23:05:52 +0200 [thread overview]
Message-ID: <1351285552.30380.20.camel@edumazet-glaptop> (raw)
In-Reply-To: <CAN8Q1Ed1J-jmO9LppcA=rFXPvxFkk-J9mMb2-NhDYyAQKO2jvQ@mail.gmail.com>
On Fri, 2012-10-26 at 11:51 -0700, Peter LaDow wrote:
> (I've added netfilter and linux-rt-users to try to pull in more help).
>
> On Fri, Oct 26, 2012 at 9:48 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Upstream kernel is fine, there is no race, as long as :
> >
> > local_bh_disable() disables BH and preemption.
>
> Looking at the unpatched code in net/ipv4/netfilter/ip_tables.c, it
> doesn't appear that any of the code checks the return value for
> xt_write_receq_begin to determine if it is safe to write. And neither
> does the newly patched code. How did the mainline code prevent
> corruption of the tables it is updating?
>
Do you know what is per cpu data in linux kernel ?
> Why isn't there something like
>
> while ( (addend = xt_write_recseq_begin()) == 0 );
>
> To make sure that only one person has write access to the tables?
> Better yet, why not use a seqlock_t instead?
>
Because its not needed. Really I dont know why you want that.
Once you are sure a thread cannot be interrupted by a softirq, and
cannot migrate to another cpu, access to percpu data doesnt need other
synchronization at all.
Following sequence is safe :
addend = (__this_cpu_read(xt_recseq.sequence) + 1) & 1;
/*
* This is kind of a write_seqcount_begin(), but addend is 0 or 1
* We dont check addend value to avoid a test and conditional jump,
* since addend is most likely 1
*/
__this_cpu_add(xt_recseq.sequence, addend);
Because any other thread will use a different percpu data.
next prev parent reply other threads:[~2012-10-26 21:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAN8Q1EdobyFuAvtajGRSqNsCG+XoPA+FkwN=2j_H126mmfEjTQ@mail.gmail.com>
[not found] ` <1350925299.8609.978.camel@edumazet-glaptop>
[not found] ` <CAN8Q1EeqmHMHD-VUgr7Wzv0Z_DAD1SrEniftg==L14d+hGwu+Q@mail.gmail.com>
[not found] ` <CAN8Q1EcTRsHjCJD90q0bKRJFMvi7Vn8YRsyQTAHNtTFVuuNdWQ@mail.gmail.com>
[not found] ` <CAN8Q1EeB2kC6A_YP9zdtp_qYHMG5FF7-Usjx7Rz5pv--bjhqkQ@mail.gmail.com>
[not found] ` <1351053164.6537.95.camel@edumazet-glaptop>
[not found] ` <CAN8Q1Ef9sCAG8-KNWXEeuRUcmFNcg93mMG=HRQw6i3UuGtJCVg@mail.gmail.com>
[not found] ` <1351270087.30380.9.camel@edumazet-glaptop>
2012-10-26 18:51 ` Process Hang in __read_seqcount_begin Peter LaDow
2012-10-26 20:53 ` Thomas Gleixner
2012-10-26 21:05 ` Eric Dumazet [this message]
2012-10-26 21:25 ` Peter LaDow
2012-10-26 21:54 ` Thomas Gleixner
2012-10-30 23:09 ` Peter LaDow
2012-10-31 0:33 ` Thomas Gleixner
2012-07-28 20:43 Peter LaDow
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=1351285552.30380.20.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=petela@gocougs.wsu.edu \
/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