* Added new(vip_io_alloc) operators allocating memory from the VIP I/O
heap. * Allocate IOBuffers, IORequests, and cookies on the VIP I/O heap, if necessary. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26969 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,14 +53,22 @@ IORequestChunk::~IORequestChunk()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
IORequestChunk::operator delete(void* address, size_t size)
|
||||||
|
{
|
||||||
|
io_request_free(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
IOBuffer*
|
IOBuffer*
|
||||||
IOBuffer::Create(size_t count)
|
IOBuffer::Create(uint32 count, bool vip)
|
||||||
{
|
{
|
||||||
IOBuffer* buffer = (IOBuffer*)malloc(
|
size_t size = sizeof(IOBuffer) + sizeof(iovec) * (count - 1);
|
||||||
sizeof(IOBuffer) + sizeof(iovec) * (count - 1));
|
IOBuffer* buffer
|
||||||
|
= (IOBuffer*)(vip ? vip_io_request_malloc(size) : malloc(size));
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -68,6 +76,7 @@ IOBuffer::Create(size_t count)
|
|||||||
buffer->fVecCount = 0;
|
buffer->fVecCount = 0;
|
||||||
buffer->fUser = false;
|
buffer->fUser = false;
|
||||||
buffer->fPhysical = false;
|
buffer->fPhysical = false;
|
||||||
|
buffer->fVIP = vip;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -76,6 +85,9 @@ IOBuffer::Create(size_t count)
|
|||||||
void
|
void
|
||||||
IOBuffer::Delete()
|
IOBuffer::Delete()
|
||||||
{
|
{
|
||||||
|
if (fVIP)
|
||||||
|
vip_io_request_free(this);
|
||||||
|
else
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +601,7 @@ status_t
|
|||||||
IORequest::Init(off_t offset, size_t firstVecOffset, const iovec* vecs,
|
IORequest::Init(off_t offset, size_t firstVecOffset, const iovec* vecs,
|
||||||
size_t count, size_t length, bool write, uint32 flags)
|
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)
|
if (fBuffer == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -651,8 +663,8 @@ IORequest::CreateSubRequest(off_t parentOffset, off_t offset, size_t length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create subrequest
|
// create subrequest
|
||||||
IORequest* subRequest = new(std::nothrow) IORequest;
|
IORequest* subRequest = (fFlags & B_VIP_IO_REQUEST) != 0
|
||||||
// TODO: Heed B_VIP_IO_REQUEST!
|
? new(vip_io_alloc) IORequest : new(std::nothrow) IORequest;
|
||||||
if (subRequest == NULL)
|
if (subRequest == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
@@ -1205,6 +1217,9 @@ vip_io_request_allocator_init()
|
|||||||
"heap\n");
|
"heap\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dprintf("vip_io_request_allocator_init(): created VIP I/O heap: %p\n",
|
||||||
|
sVIPHeap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include <condition_variable.h>
|
#include <condition_variable.h>
|
||||||
@@ -28,7 +30,7 @@ typedef struct IOOperation io_operation;
|
|||||||
|
|
||||||
class IOBuffer : public DoublyLinkedListLinkImpl<IOBuffer> {
|
class IOBuffer : public DoublyLinkedListLinkImpl<IOBuffer> {
|
||||||
public:
|
public:
|
||||||
static IOBuffer* Create(size_t count);
|
static IOBuffer* Create(uint32 count, bool vip);
|
||||||
void Delete();
|
void Delete();
|
||||||
|
|
||||||
bool IsVirtual() const { return !fPhysical; }
|
bool IsVirtual() const { return !fPhysical; }
|
||||||
@@ -66,6 +68,7 @@ private:
|
|||||||
|
|
||||||
bool fUser;
|
bool fUser;
|
||||||
bool fPhysical;
|
bool fPhysical;
|
||||||
|
bool fVIP;
|
||||||
size_t fLength;
|
size_t fLength;
|
||||||
size_t fVecCount;
|
size_t fVecCount;
|
||||||
size_t fCapacity;
|
size_t fCapacity;
|
||||||
@@ -90,6 +93,8 @@ public:
|
|||||||
DoublyLinkedListLink<IORequestChunk>*
|
DoublyLinkedListLink<IORequestChunk>*
|
||||||
ListLink() { return &fListLink; }
|
ListLink() { return &fListLink; }
|
||||||
|
|
||||||
|
void operator delete(void* address, size_t size);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetStatus(status_t status)
|
void SetStatus(status_t status)
|
||||||
{ fStatus = status; }
|
{ fStatus = status; }
|
||||||
@@ -249,6 +254,7 @@ struct IORequest : IORequestChunk, DoublyLinkedListLinkImpl<IORequest> {
|
|||||||
bool IsWrite() const { return fIsWrite; }
|
bool IsWrite() const { return fIsWrite; }
|
||||||
bool IsRead() const { return !fIsWrite; }
|
bool IsRead() const { return !fIsWrite; }
|
||||||
team_id Team() const { return fTeam; }
|
team_id Team() const { return fTeam; }
|
||||||
|
uint32 Flags() const { return fFlags; }
|
||||||
|
|
||||||
IOBuffer* Buffer() const { return fBuffer; }
|
IOBuffer* Buffer() const { return fBuffer; }
|
||||||
off_t Offset() const { return fOffset; }
|
off_t Offset() const { return fOffset; }
|
||||||
@@ -331,4 +337,22 @@ void io_request_free(void* address);
|
|||||||
void vip_io_request_allocator_init();
|
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
|
#endif // IO_REQUESTS_H
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ struct iterative_io_cookie {
|
|||||||
off_t request_offset;
|
off_t request_offset;
|
||||||
io_request_finished_callback next_finished_callback;
|
io_request_finished_callback next_finished_callback;
|
||||||
void* next_finished_cookie;
|
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
|
iterative_io_cookie* iterationCookie
|
||||||
= new(std::nothrow) iterative_io_cookie;
|
= (request->Flags() & B_VIP_IO_REQUEST) != 0
|
||||||
// TODO: Heed B_VIP_IO_REQUEST!
|
? new(vip_io_alloc) iterative_io_cookie
|
||||||
|
: new(std::nothrow) iterative_io_cookie;
|
||||||
if (iterationCookie == NULL) {
|
if (iterationCookie == NULL) {
|
||||||
// no memory -- fall back to synchronous I/O
|
// no memory -- fall back to synchronous I/O
|
||||||
return do_synchronous_iterative_vnode_io(vnode, descriptor->cookie,
|
return do_synchronous_iterative_vnode_io(vnode, descriptor->cookie,
|
||||||
|
|||||||
Reference in New Issue
Block a user