Re: [PATCH 2/2] Optimize compound_head() by avoiding a shared pageflag

From: Andrew Morton
Date: Sat Apr 07 2007 - 01:24:21 EST


On Thu, 5 Apr 2007 15:36:57 -0700 (PDT) Christoph Lameter <clameter@xxxxxxx> wrote:

> Unalias PG_tail for performance reasons
>
> If PG_tail is an alias then we need to check PageCompound before PageTail.
> This is particularly bad because the slab and others have to use these tests
> in performance critical paths.
>
> This patch uses one of the freed up software suspend flags that is defined
> next to PG_compound.

I get a reject from this because it is dependent upon later patches. As
the Official Protector Of Page Flags, I'm going to drop it.

Did you investigate

static inline int page_tail(struct page *page)
{
return ((page->flags & (PG_compound|PG_tail)) == (PG_compound|PG_tail));
}

and

static inline int page_tail(struct page *page)
{
return unlikely(PageCompound(page)) && unlikely(PageTail(page));
}

?

In the latter case we _should_ have a not-taken branch to not-inline code.
If the compiler doesn't do that, we can make the PageTail() test an
out-of-line function. Or make the whole thing an uninlined function.

More work needed, please. I don't expect that a not-taken branch to
not-inline code is worth a new page flag. Especially as it does not
actually reduce the number of branch decisions in the common case.

(I'm assuming in all of this that !PageCompound() is the very common case
with slub. If that is not true, we need to talk).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/