From: David Laight <David.Laight@ACULAB.COM>
To: 'Marcelo Ricardo Leitner' <marcelo.leitner@gmail.com>
Cc: "'linux-sctp@vger.kernel.org'" <linux-sctp@vger.kernel.org>,
"'netdev@vger.kernel.org'" <netdev@vger.kernel.org>
Subject: RE: Use of genradix in sctp
Date: Fri, 21 Aug 2020 21:18:42 +0000 [thread overview]
Message-ID: <9f5b892bcf4f41f9b32990fb6049fce2@AcuMS.aculab.com> (raw)
In-Reply-To: <20200821204636.GO3399@localhost.localdomain>
From: 'Marcelo Ricardo Leitner'
> Sent: 21 August 2020 21:47
...
> >
> > 2) Optimise the genradix lookup for the case where there
> > is a single page - it can be completely inlined.
>
> And/or our struct sizes.
>
> __idx_to_offset() will basically do:
> if (!is_power_of_2(obj_size)) {
> return (idx / objs_per_page) * PAGE_SIZE +
> (idx % objs_per_page) * obj_size;
> } else {
> return idx * obj_size;
>
> if we can get it to his the else block, it saves some CPU cycles already (at
> the expense of memory).
I'm penning some changes to the genradix code:
That expression can be written:
idx * obj_size + (idx / objs_per_page) * (PAGE_SIZE % obj_size)
which is simpler and doesn't need the is_power_of_2() test.
You can then do the early test:
if (idx * obj_size <= PAGE_SIZE - obj_size) && root && !llevel)
return root + idx * obj_size;
in the inline function.
A slight increase in code size, but a reduction in code path.
(Better still if you increment 'level'.)
Which catches most SCTP uses and the only other place I've found it used.
There is actually a nasty bug in the genradix code.
If the cmpxchg 'fails' when adding extra root levels then the page
can get reused later - but child[0] has been set.
This could add a loop to the tree!
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2020-08-21 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 15:38 Use of genradix in sctp David Laight
2020-08-18 21:38 ` 'Marcelo Ricardo Leitner'
2020-08-19 8:18 ` David Laight
2020-08-21 20:46 ` 'Marcelo Ricardo Leitner'
2020-08-21 21:18 ` David Laight [this message]
2020-08-21 21:39 ` David Laight
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=9f5b892bcf4f41f9b32990fb6049fce2@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--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).