Changeset 92231 in webkit


Ignore:
Timestamp:
Aug 2, 2011 2:19:05 PM (13 years ago)
Author:
msaboff@apple.com
Message:

Virtual copying of FastMalloc allocated memory causes madvise MADV_FREE_REUSABLE errors
https://bugs.webkit.org/show_bug.cgi?id=65502

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

With the fix of the issues causing madvise MADV_FREE_REUSABLE to fail,
added an assert to the return code of madvise to catch any regressions.

  • wtf/TCSystemAlloc.cpp:

(TCMalloc_SystemRelease):

Source/WebCore:

Change the vm_copy in PurgeableBuffer::create to be a memcpy. The
vm_copy causes the process to have additional references to the same
memory region. These additional reference caused madvise(MADV_FREE_REUSABLE)
to fail when it encountered such pages.

No tests added this is a resource defect and not a functional issue.

  • platform/mac/PurgeableBufferMac.cpp:

(WebCore::PurgeableBuffer::create):

Source/WebKit2:

Changed OOL message to use MACH_MSG_PHYSICAL_COPY flag instead of virtual flag
so that the original memory region isn't referenced by the message and ultimately
the receiving process. The additional reference caused madvise(MADV_FREE_REUSABLE)
to fail when it encountered such pages.

  • Platform/CoreIPC/mac/ConnectionMac.cpp:

(CoreIPC::Connection::sendOutgoingMessage):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r92230 r92231  
     12011-08-01  Michael Saboff  <msaboff@apple.com>
     2
     3        Virtual copying of FastMalloc allocated memory causes madvise MADV_FREE_REUSABLE errors
     4        https://bugs.webkit.org/show_bug.cgi?id=65502
     5
     6        Reviewed by Anders Carlsson.
     7
     8        With the fix of the issues causing madvise MADV_FREE_REUSABLE to fail,
     9        added an assert to the return code of madvise to catch any regressions.
     10
     11        * wtf/TCSystemAlloc.cpp:
     12        (TCMalloc_SystemRelease):
     13
    1142011-08-02  Anders Carlsson  <andersca@apple.com>
    215
  • trunk/Source/JavaScriptCore/wtf/TCSystemAlloc.cpp

    r76716 r92231  
    393393void TCMalloc_SystemRelease(void* start, size_t length)
    394394{
    395     while (madvise(start, length, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
     395    int madviseResult;
     396
     397    while ((madviseResult = madvise(start, length, MADV_FREE_REUSABLE)) == -1 && errno == EAGAIN) { }
     398
     399    // Although really advisory, if madvise fail, we want to know about it.
     400    ASSERT_UNUSED(madviseResult, madviseResult != -1);
    396401}
    397402
  • trunk/Source/WebCore/ChangeLog

    r92227 r92231  
     12011-08-01  Michael Saboff  <msaboff@apple.com>
     2
     3        Virtual copying of FastMalloc allocated memory causes madvise MADV_FREE_REUSABLE errors
     4        https://bugs.webkit.org/show_bug.cgi?id=65502
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Change the vm_copy in PurgeableBuffer::create to be a memcpy.  The
     9        vm_copy causes the process to have additional references to the same
     10        memory region.  These additional reference caused madvise(MADV_FREE_REUSABLE)
     11        to fail when it encountered such pages.
     12
     13        No tests added this is a resource defect and not a functional issue.
     14
     15        * platform/mac/PurgeableBufferMac.cpp:
     16        (WebCore::PurgeableBuffer::create):
     17
    1182011-08-02  Stephen White  <senorblanco@chromium.org>
    219
  • trunk/Source/WebCore/platform/mac/PurgeableBufferMac.cpp

    r85603 r92231  
    6565        return nullptr;
    6666
    67     ret = vm_copy(mach_task_self(), reinterpret_cast<vm_address_t>(data), size, buffer);
    68 
    69     ASSERT(ret == KERN_SUCCESS);
    70     if (ret != KERN_SUCCESS) {
    71         vm_deallocate(mach_task_self(), buffer, size);
    72         return nullptr;
    73     }
     67    memcpy(reinterpret_cast<char*>(buffer), data, size);
    7468
    7569    return adoptPtr(new PurgeableBuffer(reinterpret_cast<char*>(buffer), size));
  • trunk/Source/WebKit2/ChangeLog

    r92199 r92231  
     12011-08-01  Michael Saboff  <msaboff@apple.com>
     2
     3        Virtual copying of FastMalloc allocated memory causes madvise MADV_FREE_REUSABLE errors
     4        https://bugs.webkit.org/show_bug.cgi?id=65502
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Changed OOL message to use MACH_MSG_PHYSICAL_COPY flag instead of virtual flag
     9        so that the original memory region isn't referenced by the message and ultimately
     10        the receiving process.  The additional reference caused madvise(MADV_FREE_REUSABLE)
     11        to fail when it encountered such pages.
     12
     13        * Platform/CoreIPC/mac/ConnectionMac.cpp:
     14        (CoreIPC::Connection::sendOutgoingMessage):
     15
    1162011-07-29  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    217
  • trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp

    r78247 r92231  
    156156        messageBodyIsOOL = true;
    157157
    158         attachments.append(Attachment(arguments->buffer(), arguments->bufferSize(), MACH_MSG_VIRTUAL_COPY, false));
     158        attachments.append(Attachment(arguments->buffer(), arguments->bufferSize(), MACH_MSG_PHYSICAL_COPY, false));
    159159        numberOfOOLMemoryDescriptors++;
    160160        messageSize = machMessageSize(0, numberOfPortDescriptors, numberOfOOLMemoryDescriptors);
Note: See TracChangeset for help on using the changeset viewer.