Re: [patch] speed up / fix the new generic semaphore code (fix AIM740% regression with 2.6.26-rc1)
From: Linus Torvalds
Date: Thu May 08 2008 - 19:08:22 EST
On Thu, 8 May 2008, Linus Torvalds wrote:
>
> Some of it is that "page_to_pfn(page)", which involves a nasty division
> (divide by sizeof(struct page)). It gets turned into that shift and
> multiply, but it's still quite expensive with big constants etc.
Btw, sparse will complain about those, because the source code *looks*
really cheap.
The normal "page_to_pfn()" looks trivial:
((unsigned long)((page) - mem_map) + ARCH_PFN_OFFSET)
which looks like a trivial subtraction and addition of a constant, but the
subtraction is on C pointers, and basically turns into
((unsigned long)page - (unsigned long)mem_map) / sizeof(struct page)
and because "struct page" is not some nice power-of-two in size, that
division is rather nasty even though it's a constant size.
Linus
--
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/