From: Ingo Oeser <netdev@axxeo.de>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: fixing sk_stream_rfree()
Date: Tue, 18 Apr 2006 13:49:36 +0200 [thread overview]
Message-ID: <200604181349.36949.netdev@axxeo.de> (raw)
In-Reply-To: <20060414.205927.13626300.davem@davemloft.net>
Hi David,
You wrote:
> 2) We can't turn sk_forward_alloc easily into an atomic_t. The
> masking operation in __sk_stream_mem_reclaim() does not translate
> readily into an atomic_t op:
>
> sk->sk_forward_alloc &= SK_STREAM_MEM_QUANTUM - 1;
>
> That line has always driven me nuts, but I know that it is there
> to handle partial page allocations existing when that function
> is called.
>
> I guess for #2 we could change those two lines into:
>
> int n = atomic_read(&sk->sk_forward_alloc) /
> SK_STREAM_MEM_QUANTUM;
>
> atomic_sub(n, sk->sk_prot->memory_allocated);
> sk->sk_forward_alloc -= n * SK_STREAM_MEM_QUANTUM;
>
> in order to make it "atomic_t op" translatable.
It is possible. Just view this as an register with size SK_STREAM_MEM_QUANTUM.
Mask on every read and always after the read.
Always add/subtract the intended value.
Wraparound happens within the modulo/mask value.
This works without problems as long as SK_STREAM_MEM_QUANTUM
is a power of two. If not, just use modulo arithmetics.
The non-atomic wrapround doesn't change the atomic nature of
read, add, sub. Only problem is atomic_dec_and_test() or similiar ops.
Regards
Ingo Oeser
prev parent reply other threads:[~2006-04-18 11:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-15 3:59 fixing sk_stream_rfree() David S. Miller
2006-04-15 8:23 ` David S. Miller
2006-04-15 9:03 ` David S. Miller
2006-04-16 11:18 ` Herbert Xu
2006-04-17 5:32 ` David S. Miller
2006-04-17 6:17 ` Herbert Xu
2006-04-17 20:27 ` Jesse Brandeburg
2006-04-17 20:29 ` David S. Miller
2006-04-17 21:09 ` Jesse Brandeburg
2006-04-17 21:40 ` Herbert Xu
2006-04-17 21:56 ` Jesse Brandeburg
2006-04-18 11:49 ` Ingo Oeser [this message]
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=200604181349.36949.netdev@axxeo.de \
--to=netdev@axxeo.de \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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 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).