diff --git a/src/system/kernel/device_manager/io_requests.cpp b/src/system/kernel/device_manager/io_requests.cpp index 6efd77bd92..b07e0aa58d 100644 --- a/src/system/kernel/device_manager/io_requests.cpp +++ b/src/system/kernel/device_manager/io_requests.cpp @@ -53,14 +53,22 @@ IORequestChunk::~IORequestChunk() } +void +IORequestChunk::operator delete(void* address, size_t size) +{ + io_request_free(address); +} + + // #pragma mark - IOBuffer* -IOBuffer::Create(size_t count) +IOBuffer::Create(uint32 count, bool vip) { - IOBuffer* buffer = (IOBuffer*)malloc( - sizeof(IOBuffer) + sizeof(iovec) * (count - 1)); + size_t size = sizeof(IOBuffer) + sizeof(iovec) * (count - 1); + IOBuffer* buffer + = (IOBuffer*)(vip ? vip_io_request_malloc(size) : malloc(size)); if (buffer == NULL) return NULL; @@ -68,6 +76,7 @@ IOBuffer::Create(size_t count) buffer->fVecCount = 0; buffer->fUser = false; buffer->fPhysical = false; + buffer->fVIP = vip; return buffer; } @@ -76,7 +85,10 @@ IOBuffer::Create(size_t count) void IOBuffer::Delete() { - free(this); + if (fVIP) + vip_io_request_free(this); + else + free(this); } @@ -589,7 +601,7 @@ status_t IORequest::Init(off_t offset, size_t firstVecOffset, const iovec* vecs, size_t count, size_t length, bool write, uint32 flags) { - fBuffer = IOBuffer::Create(count); + fBuffer = IOBuffer::Create(count, (flags & B_VIP_IO_REQUEST) != 0); if (fBuffer == NULL) return B_NO_MEMORY; @@ -651,8 +663,8 @@ IORequest::CreateSubRequest(off_t parentOffset, off_t offset, size_t length, } // create subrequest - IORequest* subRequest = new(std::nothrow) IORequest; - // TODO: Heed B_VIP_IO_REQUEST! + IORequest* subRequest = (fFlags & B_VIP_IO_REQUEST) != 0 + ? new(vip_io_alloc) IORequest : new(std::nothrow) IORequest; if (subRequest == NULL) return B_NO_MEMORY; @@ -1205,6 +1217,9 @@ vip_io_request_allocator_init() "heap\n"); return; } + + dprintf("vip_io_request_allocator_init(): created VIP I/O heap: %p\n", + sVIPHeap); } diff --git a/src/system/kernel/device_manager/io_requests.h b/src/system/kernel/device_manager/io_requests.h index 804769a0d3..d26ad8fa26 100644 --- a/src/system/kernel/device_manager/io_requests.h +++ b/src/system/kernel/device_manager/io_requests.h @@ -8,6 +8,8 @@ #include +#include + #include #include @@ -28,7 +30,7 @@ typedef struct IOOperation io_operation; class IOBuffer : public DoublyLinkedListLinkImpl { public: - static IOBuffer* Create(size_t count); + static IOBuffer* Create(uint32 count, bool vip); void Delete(); bool IsVirtual() const { return !fPhysical; } @@ -66,6 +68,7 @@ private: bool fUser; bool fPhysical; + bool fVIP; size_t fLength; size_t fVecCount; size_t fCapacity; @@ -90,6 +93,8 @@ public: DoublyLinkedListLink* ListLink() { return &fListLink; } + void operator delete(void* address, size_t size); + protected: void SetStatus(status_t status) { fStatus = status; } @@ -249,6 +254,7 @@ struct IORequest : IORequestChunk, DoublyLinkedListLinkImpl { bool IsWrite() const { return fIsWrite; } bool IsRead() const { return !fIsWrite; } team_id Team() const { return fTeam; } + uint32 Flags() const { return fFlags; } IOBuffer* Buffer() const { return fBuffer; } off_t Offset() const { return fOffset; } @@ -331,4 +337,22 @@ void io_request_free(void* address); void vip_io_request_allocator_init(); +static const struct vip_io_alloc_t { +} vip_io_alloc = {}; + + +inline void* +operator new(size_t size, const vip_io_alloc_t& vip_io_alloc) throw () +{ + return vip_io_request_malloc(size); +} + + +inline void* +operator new[](size_t size, const vip_io_alloc_t& vip_io_alloc) throw () +{ + return vip_io_request_malloc(size); +} + + #endif // IO_REQUESTS_H diff --git a/src/system/kernel/fs/vfs_request_io.cpp b/src/system/kernel/fs/vfs_request_io.cpp index 21bbf12f2a..8ad94da6d2 100644 --- a/src/system/kernel/fs/vfs_request_io.cpp +++ b/src/system/kernel/fs/vfs_request_io.cpp @@ -23,6 +23,9 @@ struct iterative_io_cookie { off_t request_offset; io_request_finished_callback next_finished_callback; void* next_finished_cookie; + + void operator delete(void* address, size_t size) + { io_request_free(address); } }; @@ -420,8 +423,9 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs, } iterative_io_cookie* iterationCookie - = new(std::nothrow) iterative_io_cookie; - // TODO: Heed B_VIP_IO_REQUEST! + = (request->Flags() & B_VIP_IO_REQUEST) != 0 + ? new(vip_io_alloc) iterative_io_cookie + : new(std::nothrow) iterative_io_cookie; if (iterationCookie == NULL) { // no memory -- fall back to synchronous I/O return do_synchronous_iterative_vnode_io(vnode, descriptor->cookie,