]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Used one-for-all constant page size for now; need to be made configurable.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 8 Apr 2011 00:08:15 +0000 (18:08 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 8 Apr 2011 00:08:15 +0000 (18:08 -0600)
src/ipc/mem/PagePool.cc
src/ipc/mem/Pages.cc
src/ipc/mem/Pages.h

index f04da8db50cd704acec25e74a15b20fa2faa510e..60aee9738c729caeb258ac69cfaf9cb59fdb28e9 100644 (file)
@@ -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);
 }
index 4b95a08d21a9579f50d3fd515d2522bc49b9743d..4427481225b44c2a0e72a5ddc3d40f1c5fc5d7ab 100644 (file)
 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<SwapDir *>(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
index c18e14903c1f5c953d4db415d47d0480623b697a..bf07d995847ec5ce47dd493912ac36425348f08a 100644 (file)
@@ -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