lkml.org 
[lkml]   [2008]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] speed up / fix the new generic semaphore code (fix AIM7 40% regression with 2.6.26-rc1)


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


\
 
 \ /
  Last update: 2008-05-09 01:11    [W:0.160 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site