From: Alex Rousskov Date: Fri, 8 Apr 2011 00:08:15 +0000 (-0600) Subject: Used one-for-all constant page size for now; need to be made configurable. X-Git-Tag: take06~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1ad401770cb70481324120b655cced6bdd7263d;p=thirdparty%2Fsquid.git Used one-for-all constant page size for now; need to be made configurable. --- diff --git a/src/ipc/mem/PagePool.cc b/src/ipc/mem/PagePool.cc index f04da8db50..60aee9738c 100644 --- a/src/ipc/mem/PagePool.cc +++ b/src/ipc/mem/PagePool.cc @@ -25,7 +25,7 @@ Ipc::Mem::PagePool::PagePool(const String &id, const unsigned int capacity, cons pageIndex(PageIndexId(id), capacity), shm(id.termedBuf()) { - shm.create(pageSize * capacity + sizeof(Shared)); + shm.create(sizeof(Shared) + pageSize*capacity); assert(shm.mem()); shared = new (shm.mem()) Shared(capacity, pageSize); } diff --git a/src/ipc/mem/Pages.cc b/src/ipc/mem/Pages.cc index 4b95a08d21..4427481225 100644 --- a/src/ipc/mem/Pages.cc +++ b/src/ipc/mem/Pages.cc @@ -19,17 +19,10 @@ static const String PagePoolId = "squid-page-pool"; static Ipc::Mem::PagePool *ThePagePool = 0; -// XXX: temporary function until we have a better page size handling -static unsigned int -calculatePageSize() -{ - unsigned int max_objsize = 0; - for (int i = 0; i < Config.cacheSwap.n_configured; ++i) { - const SwapDir *const sd = dynamic_cast(INDEXSD(i)); - if (sd->max_objsize > max_objsize) - max_objsize = sd->max_objsize; - } - return max_objsize; +// XXX: make configurable +size_t +Ipc::Mem::PageSize() { + return 16*1024; } void @@ -37,7 +30,7 @@ Ipc::Mem::Init() { Must(!ThePagePool); // XXX: pool capacity and page size should be configurable/meaningful - ThePagePool = new PagePool(PagePoolId, 1024, calculatePageSize()); + ThePagePool = new PagePool(PagePoolId, 1024, PageSize()); } void diff --git a/src/ipc/mem/Pages.h b/src/ipc/mem/Pages.h index c18e14903c..bf07d99584 100644 --- a/src/ipc/mem/Pages.h +++ b/src/ipc/mem/Pages.h @@ -42,6 +42,9 @@ uint64_t Level(); /// approximate total number of shared memory bytes we can allocate now inline uint64_t Available() { return Limit() - Level(); } +/// returns page size in bytes; all pages are assumed to be the same size +size_t PageSize(); + } // namespace Mem } // namespace Ipc