Kaydet (Commit) 71aa8030 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Michael Meeks

refactor pagein, as it still seems to cause rare crashes

Change-Id: I51e6cdf79c19c3709e00dc10175527ec6583a758
Reviewed-on: https://gerrit.libreoffice.org/23872Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst b8454666
......@@ -74,37 +74,29 @@ cleanup_and_leave:
*/
int file_image_pagein (file_image * image)
{
file_image w;
long s;
size_t k;
// force touching of each page despite the optimizer
long s = -1;
volatile char c =0;
size_t idx;
if (image == NULL)
return EINVAL;
if ((w.m_base = image->m_base) == NULL)
if (image->m_base == NULL)
return EINVAL;
if ((w.m_size = image->m_size) == 0)
if (image->m_size == 0)
return 0;
if (madvise (w.m_base, w.m_size, MADV_WILLNEED) == -1)
if (madvise (image->m_base, image->m_size, MADV_WILLNEED) == -1)
return errno;
if ((s = sysconf (_SC_PAGESIZE)) == -1)
s = sysconf (_SC_PAGESIZE);
if (s == -1)
s = 0x1000;
k = (size_t)(s);
while (w.m_size > k)
{
c ^= ((char*)(w.m_base))[0];
w.m_base = (char*)(w.m_base) + k;
w.m_size -= k;
}
if (w.m_size > 0)
// force touching of each page despite the optimizer
for(idx = 0; idx < image->m_size; idx += (size_t)s)
{
c ^= ((char*)(w.m_base))[0];
c ^= ((volatile const char*)(image->m_base))[idx];
}
c ^= ((volatile const char*)(image->m_base))[image->m_size-1];
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment