On May 13, 2013, at 3:23 PM, Igor Galić <[email protected]> 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 <[email protected]> >> Authored: Fri May 10 15:47:51 2013 -0700 >> Committer: James Peach <[email protected]> >> 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: [email protected] > URL: http://brainsware.org/ > GPG: 6880 4155 74BD FD7C B515 2EA5 4B1D 9E08 A097 C9AE >
