From: Cedric Blancher <cedric.blancher@gmail.com>
To: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Matthew Wilcox <mawilcox@linuxonhyperv.com>,
Konstantin Khlebnikov <koct9i@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux MM <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] radix-tree: Fix optimisation problem
Date: Mon, 26 Sep 2016 23:48:44 +0200 [thread overview]
Message-ID: <CALXu0Udkqfhgvt-CKzYs4-rTo8fUZnsNV1xq53gMVFFgzMjgww@mail.gmail.com> (raw)
In-Reply-To: <DM2PR21MB00897967DF6E1C0D57DFA9F4CBCD0@DM2PR21MB0089.namprd21.prod.outlook.com>
You might also try to use valid, plain ISO C99 instead of perverted
gcc extensions which only cause a lot of trouble in the long run.
Ced
On 26 September 2016 at 23:28, Matthew Wilcox <mawilcox@microsoft.com> wrote:
> From: linus971@gmail.com [mailto:linus971@gmail.com] On Behalf Of Linus Torvalds
>> On Sun, Sep 25, 2016 at 12:04 PM, Linus Torvalds
>> <torvalds@linux-foundation.org> wrote:
>> > It gets rid of
>> > the ad-hoc arithmetic in radix_tree_descend(), and just makes all that
>> > be inside the is_sibling_entry() logic instead. Which got renamed and
>> > made to actually return the main sibling.
>>
>> Sadly, it looks like gcc generates bad code for this approach. Looks
>> like it ends up testing the resulting sibling pointer twice (because
>> we explicitly disable -fno-delete-null-pointer-checks in the kernel,
>> and we have no way to say "look, I know this pointer I'm returning is
>> non-null").
>>
>> So a smaller patch that keeps the old boolean "is_sibling_entry()" but
>> then actually *uses* that inside radix_tree_descend() and then tries
>> to make the nasty cast to "void **" more legible by making it use a
>> temporary variable seems to be a reasonable balance.
>>
>> At least I feel like I can still read the code, but admittedly by now
>> that may be because I've stared at those few lines so much that I feel
>> like I know what's going on. So maybe the code isn't actually any more
>> legible after all.
>>
>> .. and unlike my previous patch, it actually generates better code
>> than the original (while still passing the fixed test-suite, of
>> course). The reason seems to be exactly that temporary variable,
>> allowing us to just do
>>
>> entry = rcu_dereference_raw(*sibentry);
>>
>> rather than doing
>>
>> entry = rcu_dereference_raw(parent->slots[offset]);
>>
>> with the re-computed offset.
>>
>> So I think I'll commit this unless somebody screams.
>
> Acked-by: Matthew Wilcox <mawilcox@microsoft.com>
>
> I don't love it. But I think it's a reasonable fix for this point in the release cycle, and I have an idea for changing the representation of sibling slots that will make this moot.
>
> (Basically adopting Konstantin's idea for using the *last* entry instead of the *first*, and then using entries of the form (offset << 2 | RADIX_TREE_INTERNAL_NODE), so we can identify sibling entries without knowing the parent pointer, and we can go straight from sibling entry to slot offset as a shift rather than as a pointer subtraction).
--
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2016-09-26 21:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 18:53 [PATCH 0/2] Fix radix_tree_lookup_slot() Matthew Wilcox
2016-09-22 18:53 ` [PATCH 1/2] radix tree test suite: Test radix_tree_replace_slot() for multiorder entries Matthew Wilcox
2016-09-22 18:53 ` [PATCH 2/2] radix-tree: Fix optimisation problem Matthew Wilcox
2016-09-22 18:09 ` Linus Torvalds
2016-09-23 20:16 ` Matthew Wilcox
2016-09-24 20:21 ` Linus Torvalds
2016-09-24 20:47 ` Linus Torvalds
2016-09-24 21:04 ` Kirill A. Shutemov
2016-09-24 22:54 ` Linus Torvalds
2016-09-26 4:26 ` Ross Zwisler
2016-09-24 8:36 ` Konstantin Khlebnikov
2016-09-24 23:35 ` Cedric Blancher
2016-09-25 0:18 ` Linus Torvalds
2016-09-25 17:59 ` Cedric Blancher
2016-09-25 18:04 ` Linus Torvalds
2016-09-25 19:04 ` Linus Torvalds
2016-09-25 19:40 ` Cedric Blancher
2016-09-25 19:56 ` Linus Torvalds
2016-09-26 21:28 ` Matthew Wilcox
2016-09-26 21:48 ` Cedric Blancher [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=CALXu0Udkqfhgvt-CKzYs4-rTo8fUZnsNV1xq53gMVFFgzMjgww@mail.gmail.com \
--to=cedric.blancher@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=koct9i@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@linuxonhyperv.com \
--cc=mawilcox@microsoft.com \
--cc=ross.zwisler@linux.intel.com \
--cc=torvalds@linux-foundation.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