All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nuutti Kotivuori <naked@iki.fi>
To: netfilter-devel@lists.netfilter.org
Subject: Re: [PATCH] Very first try: ipt_connrate patch.
Date: Mon, 16 Feb 2004 14:34:41 +0200	[thread overview]
Message-ID: <878yj39p9a.fsf@iki.fi> (raw)
In-Reply-To: 4030A6F8.5030606@trash.net

Patrick McHardy wrote:
> Nuutti Kotivuori wrote:
>> +void
>> +ip_conntrack_rate_count(struct ip_conntrack_rate *ctr,
>> +			unsigned int len)

[...]

>
> You need locking here. Other CPUs can change ctr->avgrate between
> reading and updating it. The xchg operation becomes unneccessary
> with proper locking.

Right. I didn't see any locking in resolve_normal_ct, so I assumed no
locking was needed. Then I peeked in the functions it calls and every
one of them gets the ip_conntrack_lock.

But, I am a bit confused on the best way to handle locking. For
example, ip_conntrack_proto_tcp has only one RWLOCK which it uses. I
can undestand this for the actual connection tracking table, but for
the subentries in it... well, why would writing to one conntrack
element block reading from another conntrack element - or simultaneous
writing to two different conntrack elements and so on. Shouldn't there
be some locking per connection tracking entry, so other entries could
simultaneously be processed on other processors?

SMP performance and correctness is an important issue for me, as I am
specifically running this on an SMP machine. Luckily I haven't ran
into any problems yet - thanks for spotting this. I shall implement
things as proto_tcp does it for now.

-- Naked

  reply	other threads:[~2004-02-16 12:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-08 19:56 [PATCH] Very first try: ipt_connrate patch Nuutti Kotivuori
2004-02-14 20:14 ` Harald Welte
2004-02-16  2:22   ` Nuutti Kotivuori
2004-02-19 18:28     ` Harald Welte
2004-02-19 19:05       ` Nuutti Kotivuori
2004-02-16 11:18 ` Patrick McHardy
2004-02-16 12:34   ` Nuutti Kotivuori [this message]
2004-02-16 13:07     ` Patrick McHardy
2004-02-16 16:19       ` Nuutti Kotivuori

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=878yj39p9a.fsf@iki.fi \
    --to=naked@iki.fi \
    --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.