[systemd-devel] [PATCH v2] Detect page size runtime

fykcee1 at gmail.com fykcee1 at gmail.com
Fri Mar 18 23:18:28 PDT 2011


2011/3/19 Jan Engelhardt <jengelh at medozas.de>:
> On Saturday 2011-03-19 03:10, Lennart Poettering wrote:
>
>>On Fri, 18.03.11 03:44, fykcee1 at gmail.com (fykcee1 at gmail.com) wrote:
>>
>>> Hi all,
>>>
>>> Systemd hardcode page size as 4096(in macro.h), this is not always correct:
>>> """ Some architectures support multiple machine types with diffenent
>>> page sizes, and some machine types even support multiple page sizes
>>> themselves. """
>>>
>>> This patch tries to detect page size runtime by sysconf(_SC_PAGESIZE),
>>> and uses 4096 as a failsafe value. Note we need memset vec to zero
>>> before call mincore(src/readahead-collect.c, 129) -- if the pagesize
>>> is not correct, we may randomly record wider range or more ranges to
>>> readahead.
>>
>>Hmm, interesting. Which architecture are you using that has a page size
>>!= 4K?
>
> sparc64 would, to name one.
IA64, sparc64, powerpc, and mips, they can configure different page
size(e.g. range from 4K - 32K) at kernel config time.

Changes since v1:
1. Rename get_pagesize() to page_size(), fix C99 violation, and move
PAGE_ALIGN and page_size() to util.h and util.c.
2. page_size() now use static tls variable , it will call sysconf only
once for each thread.
3. Remove page size related stuff from readahead-*.c/h.

Note: I still keep a warning of sysconf call failure in page_size(),
this may help to indicate broken sysconf implementation on some
platform. (IMHO, sysconf(_SC_PAGESIZE) should never fail.)
Any idea?



-- 
Regards,
- cee1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Detect-page-size-runtime.patch
Type: application/octet-stream
Size: 3775 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20110319/25cd2955/attachment.obj>


More information about the systemd-devel mailing list