You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/05/13 19:47:19 UTC

git commit: TS-1892: Move msync and friends to ink_memory.h

Updated Branches:
  refs/heads/master 07466943b -> f17658ac4


TS-1892: Move msync and friends to ink_memory.h

ink_memory.h is really a better place for memory management APIs.
Also rename them from safe_*() to ats_*() to fit with our standard
conventions.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f17658ac
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f17658ac
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f17658ac

Branch: refs/heads/master
Commit: f17658ac4d8b55a2a558ae1cc988a2295d3b1b77
Parents: 0746694
Author: James Peach <jp...@apache.org>
Authored: Fri May 10 15:47:51 2013 -0700
Committer: James Peach <jp...@apache.org>
Committed: Mon May 13 10:26:17 2013 -0700

----------------------------------------------------------------------
 CHANGES                                  |    2 +
 configure.ac                             |    1 +
 iocore/eventsystem/P_UnixSocketManager.h |   25 ---------
 iocore/eventsystem/SocketManager.cc      |   67 -------------------------
 iocore/hostdb/MultiCache.cc              |   16 +++---
 lib/ts/ink_memory.cc                     |   56 +++++++++++++++++++++
 lib/ts/ink_memory.h                      |   52 +++++++++++++++----
 7 files changed, 109 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 186f001..46cb558 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
   Changes with Apache Traffic Server 3.3.3
 
 
+  *) [TS-1892] Move msync APIs to ink_memory.h.
+
   *) [TS-1890] Authproxy plugin caching and reliability fixes.
 
   *) [TS-1868] TSREMAP_*_STOP does not stop remap plugin evaluation chain.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fe90f88..c569669 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1337,6 +1337,7 @@ AM_CONDITIONAL([BUILD_HTTP_LOAD], [test x"$ac_cv_func_epoll_ctl" = x"yes"])
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES
 
+AC_CHECK_HEADERS([sys/types.h sys/mman.h])
 TS_FLAG_HEADERS([sys/epoll.h \
                   sys/event.h \
                   sys/param.h \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/iocore/eventsystem/P_UnixSocketManager.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/P_UnixSocketManager.h b/iocore/eventsystem/P_UnixSocketManager.h
index d11fee4..498d468 100644
--- a/iocore/eventsystem/P_UnixSocketManager.h
+++ b/iocore/eventsystem/P_UnixSocketManager.h
@@ -554,29 +554,4 @@ SocketManager::dup(int s)
   return res;
 }
 
-int safe_msync(caddr_t addr, size_t len, caddr_t end, int flags);
-
-#ifndef MADV_NORMAL
-#define MADV_NORMAL 0
-#endif
-
-#ifndef MADV_RANDOM
-#define MADV_RANDOM 1
-#endif
-
-#ifndef MADV_SEQUENTIAL
-#define MADV_SEQUENTIAL 2
-#endif
-
-#ifndef MADV_WILLNEED
-#define MADV_WILLNEED 3
-#endif
-
-#ifndef MADV_DONTNEED
-#define MADV_DONTNEED 4
-#endif
-
-int safe_madvise(caddr_t addr, size_t len, caddr_t end, int flags);
-int safe_mlock(caddr_t addr, size_t len, caddr_t end);
-
 #endif /*P_UnixSocketManager_h_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/iocore/eventsystem/SocketManager.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/SocketManager.cc b/iocore/eventsystem/SocketManager.cc
index 8c41d6f..d02ec87 100644
--- a/iocore/eventsystem/SocketManager.cc
+++ b/iocore/eventsystem/SocketManager.cc
@@ -31,13 +31,6 @@
 #include <sys/filio.h>
 #endif
 
-#if defined(solaris)
-// XXX: Those are already included from ink_platform.h!!!
-#include <sys/types.h>
-#include <sys/mman.h>
-extern "C" int madvise(caddr_t, size_t, int); // FIXME: why is this not being found
-#endif
-
 #include "P_EventSystem.h"
 
 SocketManager socketManager;
@@ -53,72 +46,12 @@ SocketManager::~SocketManager()
 }
 
 int
-safe_msync(caddr_t addr, size_t len, caddr_t end, int flags)
-{
-  (void) end;
-  // align start back to page boundary
-  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(socketManager.pagesize - 1));
-  // align length to page boundry covering region
-  size_t l = (len + (addr - a) + (socketManager.pagesize - 1)) & ~(socketManager.pagesize - 1);
-  if ((a + l) > end)
-    l = end - a;                // strict limit
-#if defined(linux)
-/* Fix INKqa06500
-   Under Linux, msync(..., MS_SYNC) calls are painfully slow, even on
-   non-dirty buffers. This is true as of kernel 2.2.12. We sacrifice
-   restartability under OS in order to avoid a nasty performance hit
-   from a kernel global lock. */
-#if 0
-  // this was long long ago
-  if (flags & MS_SYNC)
-    flags = (flags & ~MS_SYNC) | MS_ASYNC;
-#endif
-#endif
-  int res = msync(a, l, flags);
-  return res;
-}
-
-int
-safe_madvise(caddr_t addr, size_t len, caddr_t end, int flags)
-{
-  (void) end;
-#if defined(linux)
-  (void) addr;
-  (void) len;
-  (void) end;
-  (void) flags;
-  return 0;
-#else
-  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(socketManager.pagesize - 1));
-  size_t l = (len + (addr - a) + socketManager.pagesize - 1)
-    & ~(socketManager.pagesize - 1);
-  int res = 0;
-  res = madvise(a, l, flags);
-  return res;
-#endif
-}
-
-int
-safe_mlock(caddr_t addr, size_t len, caddr_t end)
-{
-
-  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(socketManager.pagesize - 1));
-  size_t l = (len + (addr - a) + socketManager.pagesize - 1)
-    & ~(socketManager.pagesize - 1);
-  if ((a + l) > end)
-    l = end - a;                // strict limit
-  int res = mlock(a, l);
-  return res;
-}
-
-int
 SocketManager::ink_bind(int s, struct sockaddr const* name, int namelen, short Proto)
 {
   (void) Proto;
   return safe_bind(s, name, namelen);
 }
 
-
 int
 SocketManager::close(int s)
 {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/iocore/hostdb/MultiCache.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc
index 1691940..79a859e 100644
--- a/iocore/hostdb/MultiCache.cc
+++ b/iocore/hostdb/MultiCache.cc
@@ -928,7 +928,7 @@ MultiCacheBase::sync_heap(int part)
 {
   if (heap_size) {
     int b_per_part = heap_size / MULTI_CACHE_PARTITIONS;
-    if (safe_msync(data + level_offset[2] + buckets * bucketsize[2] +
+    if (ats_msync(data + level_offset[2] + buckets * bucketsize[2] +
                    b_per_part * part, b_per_part, data + totalsize, MS_SYNC) < 0)
       return -1;
   }
@@ -950,16 +950,16 @@ MultiCacheBase::sync_partition(int partition)
   int n = buckets_of_partition(partition);
   // L3
   if (levels > 2) {
-    if (safe_msync(data + level_offset[2] + b * bucketsize[2], n * bucketsize[2], data + totalsize, MS_SYNC) < 0)
+    if (ats_msync(data + level_offset[2] + b * bucketsize[2], n * bucketsize[2], data + totalsize, MS_SYNC) < 0)
       res = -1;
   }
   // L2
   if (levels > 1) {
-    if (safe_msync(data + level_offset[1] + b * bucketsize[1], n * bucketsize[1], data + totalsize, MS_SYNC) < 0)
+    if (ats_msync(data + level_offset[1] + b * bucketsize[1], n * bucketsize[1], data + totalsize, MS_SYNC) < 0)
       res = -1;
   }
   // L1
-  if (safe_msync(data + b * bucketsize[0], n * bucketsize[0], data + totalsize, MS_SYNC) < 0)
+  if (ats_msync(data + b * bucketsize[0], n * bucketsize[0], data + totalsize, MS_SYNC) < 0)
     res = -1;
   return res;
 }
@@ -968,7 +968,7 @@ int
 MultiCacheBase::sync_header()
 {
   *mapped_header = *(MultiCacheHeader *) this;
-  return safe_msync((char *) mapped_header, STORE_BLOCK_SIZE, (char *) mapped_header + STORE_BLOCK_SIZE, MS_SYNC);
+  return ats_msync((char *) mapped_header, STORE_BLOCK_SIZE, (char *) mapped_header + STORE_BLOCK_SIZE, MS_SYNC);
 }
 
 int
@@ -1012,7 +1012,7 @@ struct MultiCacheSync: public Continuation
       return EVENT_CONT;
     }
     *mc->mapped_header = mc->header_snap;
-    ink_assert(!safe_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
+    ink_assert(!ats_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
                            (char *) mc->mapped_header + STORE_BLOCK_SIZE, MS_SYNC));
     partition = 0;
     SET_HANDLER((MCacheSyncHandler) & MultiCacheSync::mcEvent);
@@ -1137,8 +1137,8 @@ struct MultiCacheHeapGC: public Continuation
 
       if (after - before > 0)
       {
-        ink_assert(!safe_msync(before, after - before, mc->heap + mc->totalsize, MS_SYNC));
-        ink_assert(!safe_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
+        ink_assert(!ats_msync(before, after - before, mc->heap + mc->totalsize, MS_SYNC));
+        ink_assert(!ats_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
                                (char *) mc->mapped_header + STORE_BLOCK_SIZE, MS_SYNC));
       }
       // update table to point to new entries

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/lib/ts/ink_memory.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
index 90450c6..600c24d 100644
--- a/lib/ts/ink_memory.cc
+++ b/lib/ts/ink_memory.cc
@@ -159,3 +159,59 @@ ats_mallopt(int param ATS_UNUSED, int value ATS_UNUSED)
 #endif // ! TS_HAS_JEMALLOC
   return 0;
 }
+
+int
+ats_msync(caddr_t addr, size_t len, caddr_t end, int flags)
+{
+  unsigned pagesize = ats_pagesize();
+
+  // align start back to page boundary
+  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
+  // align length to page boundry covering region
+  size_t l = (len + (addr - a) + (pagesize - 1)) & ~(pagesize - 1);
+  if ((a + l) > end)
+    l = end - a;                // strict limit
+#if defined(linux)
+/* Fix INKqa06500
+   Under Linux, msync(..., MS_SYNC) calls are painfully slow, even on
+   non-dirty buffers. This is true as of kernel 2.2.12. We sacrifice
+   restartability under OS in order to avoid a nasty performance hit
+   from a kernel global lock. */
+#if 0
+  // this was long long ago
+  if (flags & MS_SYNC)
+    flags = (flags & ~MS_SYNC) | MS_ASYNC;
+#endif
+#endif
+  int res = msync(a, l, flags);
+  return res;
+}
+
+int
+ats_madvise(caddr_t addr, size_t len, int flags)
+{
+#if defined(linux)
+  (void) addr;
+  (void) len;
+  (void) flags;
+  return 0;
+#else
+  unsigned pagesize = ats_pagesize();
+  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
+  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
+  int res = 0;
+  res = madvise(a, l, flags);
+  return res;
+#endif
+}
+
+int
+ats_mlock(caddr_t addr, size_t len)
+{
+  unsigned pagesize = ats_pagesize();
+
+  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
+  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
+  int res = mlock(a, l);
+  return res;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/lib/ts/ink_memory.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_memory.h b/lib/ts/ink_memory.h
index 9358aca..c612dd1 100644
--- a/lib/ts/ink_memory.h
+++ b/lib/ts/ink_memory.h
@@ -32,6 +32,14 @@
 #include <unistd.h>
 #endif
 
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
 #if TS_HAS_JEMALLOC
 #include <jemalloc/jemalloc.h>
 /* TODO: Should this have a value ? */
@@ -43,18 +51,42 @@
 #endif // ! HAVE_MALLOC_H
 #endif // ! TS_HAS_JEMALLOC
 
+#ifndef MADV_NORMAL
+#define MADV_NORMAL 0
+#endif
+
+#ifndef MADV_RANDOM
+#define MADV_RANDOM 1
+#endif
+
+#ifndef MADV_SEQUENTIAL
+#define MADV_SEQUENTIAL 2
+#endif
+
+#ifndef MADV_WILLNEED
+#define MADV_WILLNEED 3
+#endif
+
+#ifndef MADV_DONTNEED
+#define MADV_DONTNEED 4
+#endif
+
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif                          /* __cplusplus */
-  void *ats_malloc(size_t size);
-  void *ats_calloc(size_t nelem, size_t elsize);
-  void *ats_realloc(void *ptr, size_t size);
-  void *ats_memalign(size_t alignment, size_t size);
-  void ats_free(void *ptr);
-  void* ats_free_null(void *ptr);
-  void ats_memalign_free(void *ptr);
-  int ats_mallopt(int param, int value);
+
+  void *  ats_malloc(size_t size);
+  void *  ats_calloc(size_t nelem, size_t elsize);
+  void *  ats_realloc(void *ptr, size_t size);
+  void *  ats_memalign(size_t alignment, size_t size);
+  void    ats_free(void *ptr);
+  void *  ats_free_null(void *ptr);
+  void    ats_memalign_free(void *ptr);
+  int     ats_mallopt(int param, int value);
+
+  int     ats_msync(caddr_t addr, size_t len, caddr_t end, int flags);
+  int     ats_madvise(caddr_t addr, size_t len, int flags);
+  int     ats_mlock(caddr_t addr, size_t len);
 
   static inline unsigned ats_pagesize(void) {
 #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)


Re: git commit: TS-1892: Move msync and friends to ink_memory.h

Posted by James Peach <ja...@me.com>.
On May 13, 2013, at 3:23 PM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> Updated Branches:
>>  refs/heads/master 07466943b -> f17658ac4
>> 
>> 
>> TS-1892: Move msync and friends to ink_memory.h
>> 
>> ink_memory.h is really a better place for memory management APIs.
>> Also rename them from safe_*() to ats_*() to fit with our standard
>> conventions.
>> 
> [snip]
>> Branch: refs/heads/master
>> Commit: f17658ac4d8b55a2a558ae1cc988a2295d3b1b77
>> Parents: 0746694
>> Author: James Peach <jp...@apache.org>
>> Authored: Fri May 10 15:47:51 2013 -0700
>> Committer: James Peach <jp...@apache.org>
>> Committed: Mon May 13 10:26:17 2013 -0700
>> 
>> ----------------------------------------------------------------------
>> CHANGES                                  |    2 +
>> configure.ac                             |    1 +
>> iocore/eventsystem/P_UnixSocketManager.h |   25 ---------
>> iocore/eventsystem/SocketManager.cc      |   67
>> -------------------------
>> iocore/hostdb/MultiCache.cc              |   16 +++---
>> lib/ts/ink_memory.cc                     |   56
>> +++++++++++++++++++++
>> lib/ts/ink_memory.h                      |   52 +++++++++++++++----
>> 7 files changed, 109 insertions(+), 110 deletions(-)
>> ----------------------------------------------------------------------
>> 
>> 
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/CHANGES
>> ----------------------------------------------------------------------
>> diff --git a/CHANGES b/CHANGES
>> index 186f001..46cb558 100644
>> --- a/CHANGES
>> +++ b/CHANGES
>> @@ -2,6 +2,8 @@
>>   Changes with Apache Traffic Server 3.3.3
>> 
>> 
>> +  *) [TS-1892] Move msync APIs to ink_memory.h.
>> +
>>   *) [TS-1890] Authproxy plugin caching and reliability fixes.
>> 
>>   *) [TS-1868] TSREMAP_*_STOP does not stop remap plugin evaluation
>>   chain.
>> 
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/configure.ac
>> ----------------------------------------------------------------------
>> diff --git a/configure.ac b/configure.ac
>> index fe90f88..c569669 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1337,6 +1337,7 @@ AM_CONDITIONAL([BUILD_HTTP_LOAD], [test
>> x"$ac_cv_func_epoll_ctl" = x"yes"])
>> #
>> -----------------------------------------------------------------------------
>> # 5. CHECK FOR HEADER FILES
>> 
>> +AC_CHECK_HEADERS([sys/types.h sys/mman.h])
>> TS_FLAG_HEADERS([sys/epoll.h \
>>                   sys/event.h \
>>                   sys/param.h \
> 
> What's the difference between those two?

TS_FLAG_HEADERS forces me to add extra autoconf variables. I don't really get why it's used; seems to just create more maintenance work.

> 
> 
>> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/lib/ts/ink_memory.cc
>> ----------------------------------------------------------------------
>> diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
>> index 90450c6..600c24d 100644
>> --- a/lib/ts/ink_memory.cc
>> +++ b/lib/ts/ink_memory.cc
>> @@ -159,3 +159,59 @@ ats_mallopt(int param ATS_UNUSED, int value
>> ATS_UNUSED)
>> #endif // ! TS_HAS_JEMALLOC
>>   return 0;
>> }
>> +
>> +int
>> +ats_msync(caddr_t addr, size_t len, caddr_t end, int flags)
>> +{
>> +  unsigned pagesize = ats_pagesize();
>> +
>> +  // align start back to page boundary
>> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
>> +  // align length to page boundry covering region
>> +  size_t l = (len + (addr - a) + (pagesize - 1)) & ~(pagesize - 1);
>> +  if ((a + l) > end)
>> +    l = end - a;                // strict limit
>> +#if defined(linux)
>> +/* Fix INKqa06500
>> +   Under Linux, msync(..., MS_SYNC) calls are painfully slow, even on
>> +   non-dirty buffers. This is true as of kernel 2.2.12. We sacrifice
>> +   restartability under OS in order to avoid a nasty performance hit
>> +   from a kernel global lock. */
>> +#if 0
>> +  // this was long long ago
> 
> if that is the case, we should remove it.

Sure, but as a separate commit.

> 
>> +  if (flags & MS_SYNC)
>> +    flags = (flags & ~MS_SYNC) | MS_ASYNC;
>> +#endif
>> +#endif
>> +  int res = msync(a, l, flags);
>> +  return res;
>> +}
>> +
>> +int
>> +ats_madvise(caddr_t addr, size_t len, int flags)
>> +{
>> +#if defined(linux)
>> +  (void) addr;
>> +  (void) len;
>> +  (void) flags;
>> +  return 0;
> 
> wut?

*shrug*

I'm just moving code around here :)


> 
>> +#else
>> +  unsigned pagesize = ats_pagesize();
>> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
>> +  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
>> +  int res = 0;
>> +  res = madvise(a, l, flags);
>> +  return res;
>> +#endif
>> +}
>> +
>> +int
>> +ats_mlock(caddr_t addr, size_t len)
>> +{
>> +  unsigned pagesize = ats_pagesize();
>> +
>> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
>> +  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
>> +  int res = mlock(a, l);
>> +  return res;
>> +}
>> 
> 
> -- 
> Igor Galić
> 
> Tel: +43 (0) 664 886 22 883
> Mail: i.galic@brainsware.org
> URL: http://brainsware.org/
> GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE
> 


Re: git commit: TS-1892: Move msync and friends to ink_memory.h

Posted by Igor Galić <i....@brainsware.org>.

----- Original Message -----
> Updated Branches:
>   refs/heads/master 07466943b -> f17658ac4
> 
> 
> TS-1892: Move msync and friends to ink_memory.h
> 
> ink_memory.h is really a better place for memory management APIs.
> Also rename them from safe_*() to ats_*() to fit with our standard
> conventions.
> 
[snip]
> Branch: refs/heads/master
> Commit: f17658ac4d8b55a2a558ae1cc988a2295d3b1b77
> Parents: 0746694
> Author: James Peach <jp...@apache.org>
> Authored: Fri May 10 15:47:51 2013 -0700
> Committer: James Peach <jp...@apache.org>
> Committed: Mon May 13 10:26:17 2013 -0700
> 
> ----------------------------------------------------------------------
>  CHANGES                                  |    2 +
>  configure.ac                             |    1 +
>  iocore/eventsystem/P_UnixSocketManager.h |   25 ---------
>  iocore/eventsystem/SocketManager.cc      |   67
>  -------------------------
>  iocore/hostdb/MultiCache.cc              |   16 +++---
>  lib/ts/ink_memory.cc                     |   56
>  +++++++++++++++++++++
>  lib/ts/ink_memory.h                      |   52 +++++++++++++++----
>  7 files changed, 109 insertions(+), 110 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/CHANGES
> ----------------------------------------------------------------------
> diff --git a/CHANGES b/CHANGES
> index 186f001..46cb558 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -2,6 +2,8 @@
>    Changes with Apache Traffic Server 3.3.3
>  
>  
> +  *) [TS-1892] Move msync APIs to ink_memory.h.
> +
>    *) [TS-1890] Authproxy plugin caching and reliability fixes.
>  
>    *) [TS-1868] TSREMAP_*_STOP does not stop remap plugin evaluation
>    chain.
> 
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/configure.ac
> ----------------------------------------------------------------------
> diff --git a/configure.ac b/configure.ac
> index fe90f88..c569669 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1337,6 +1337,7 @@ AM_CONDITIONAL([BUILD_HTTP_LOAD], [test
> x"$ac_cv_func_epoll_ctl" = x"yes"])
>  #
>  -----------------------------------------------------------------------------
>  # 5. CHECK FOR HEADER FILES
>  
> +AC_CHECK_HEADERS([sys/types.h sys/mman.h])
>  TS_FLAG_HEADERS([sys/epoll.h \
>                    sys/event.h \
>                    sys/param.h \

What's the difference between those two?


> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f17658ac/lib/ts/ink_memory.cc
> ----------------------------------------------------------------------
> diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
> index 90450c6..600c24d 100644
> --- a/lib/ts/ink_memory.cc
> +++ b/lib/ts/ink_memory.cc
> @@ -159,3 +159,59 @@ ats_mallopt(int param ATS_UNUSED, int value
> ATS_UNUSED)
>  #endif // ! TS_HAS_JEMALLOC
>    return 0;
>  }
> +
> +int
> +ats_msync(caddr_t addr, size_t len, caddr_t end, int flags)
> +{
> +  unsigned pagesize = ats_pagesize();
> +
> +  // align start back to page boundary
> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
> +  // align length to page boundry covering region
> +  size_t l = (len + (addr - a) + (pagesize - 1)) & ~(pagesize - 1);
> +  if ((a + l) > end)
> +    l = end - a;                // strict limit
> +#if defined(linux)
> +/* Fix INKqa06500
> +   Under Linux, msync(..., MS_SYNC) calls are painfully slow, even on
> +   non-dirty buffers. This is true as of kernel 2.2.12. We sacrifice
> +   restartability under OS in order to avoid a nasty performance hit
> +   from a kernel global lock. */
> +#if 0
> +  // this was long long ago

if that is the case, we should remove it.

> +  if (flags & MS_SYNC)
> +    flags = (flags & ~MS_SYNC) | MS_ASYNC;
> +#endif
> +#endif
> +  int res = msync(a, l, flags);
> +  return res;
> +}
> +
> +int
> +ats_madvise(caddr_t addr, size_t len, int flags)
> +{
> +#if defined(linux)
> +  (void) addr;
> +  (void) len;
> +  (void) flags;
> +  return 0;

wut?

> +#else
> +  unsigned pagesize = ats_pagesize();
> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
> +  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
> +  int res = 0;
> +  res = madvise(a, l, flags);
> +  return res;
> +#endif
> +}
> +
> +int
> +ats_mlock(caddr_t addr, size_t len)
> +{
> +  unsigned pagesize = ats_pagesize();
> +
> +  caddr_t a = (caddr_t) (((uintptr_t) addr) & ~(pagesize - 1));
> +  size_t l = (len + (addr - a) + pagesize - 1) & ~(pagesize - 1);
> +  int res = mlock(a, l);
> +  return res;
> +}
> 

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE