From f8276812e6bf3aaefe22cdf9135b06e344298273 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 13 Jan 2023 13:32:29 +0100 Subject: [PATCH 1/3] Minor cleanups --- filter/decl.m4 | 2 +- proto/mrt/mrt.c | 4 ++-- sysdep/bsd/krt-sock.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/filter/decl.m4 b/filter/decl.m4 index d0c86912..b6026867 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -589,7 +589,7 @@ f_linearize_concat(const struct f_inst * const inst[], uint count, uint results) for (uint i=0; ilen = linearize(out, inst[i], out->len); - out->results = results; + out->results = results; #ifdef LOCAL_DEBUG f_dump_line(out, 0); diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c index 321c6395..d1c334e1 100644 --- a/proto/mrt/mrt.c +++ b/proto/mrt/mrt.c @@ -113,13 +113,13 @@ mrt_buffer_flush(buffer *b) } #define MRT_DEFINE_TYPE(S, T) \ - static inline void mrt_put_##S##_(buffer *b, T x) \ + static inline void UNUSED mrt_put_##S##_(buffer *b, T x) \ { \ put_##S(b->pos, x); \ b->pos += sizeof(T); \ } \ \ - static inline void mrt_put_##S(buffer *b, T x) \ + static inline void UNUSED mrt_put_##S(buffer *b, T x) \ { \ mrt_buffer_need(b, sizeof(T)); \ put_##S(b->pos, x); \ diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 540c246f..1f793293 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -206,7 +206,7 @@ struct ks_msg memcpy(p, body, (l > sizeof(*p) ? sizeof(*p) : l));\ body += l;} -static inline void +static inline void UNUSED sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa) { uint len = OFFSETOF(struct sockaddr_dl, sdl_data); From 54234c9eae978463a2518446da399470ff916252 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 13 Jan 2023 16:44:42 +0100 Subject: [PATCH 2/3] Build: Fix cleanup of nest/proto-build.c --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index fa534872..95ab1489 100644 --- a/Makefile.in +++ b/Makefile.in @@ -219,7 +219,7 @@ install-docs: # Cleanup clean:: - rm -f $(objdir)/sysdep/paths.h + rm -f $(objdir)/sysdep/paths.h $(objdir)/nest/proto-build.c rm -f $(addprefix $(exedir)/,bird birdc birdcl) find $(objdir) -name "*.[od]" -exec rm -f '{}' '+' From 928a1cb034e6f9e8edcdd1dc07264cd703e00827 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 17 Jan 2023 17:13:50 +0100 Subject: [PATCH 3/3] Alloc: Disable transparent huge pages The usage pattern implemented in allocator seems to be incompatible with transparent huge pages, as memory released using madvise(MADV_DONTNEED) with regular page size and alignment does not seem to trigger demotion of huge pages back to regular pages, even when significant number of pages is released. Even if demotion is triggered when system memory is low, it still breaks memory accounting. --- sysdep/cf/README | 3 +++ sysdep/cf/linux.h | 1 + sysdep/unix/alloc.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/sysdep/cf/README b/sysdep/cf/README index 68078bbe..af65aaec 100644 --- a/sysdep/cf/README +++ b/sysdep/cf/README @@ -14,3 +14,6 @@ CONFIG_DONTROUTE_UNICAST Use MSG_DONTROUTE flag for unicast packets (def for Fre CONFIG_USE_HDRINCL Use IP_HDRINCL instead of control messages for source address on raw IP sockets. CONFIG_RESTRICTED_PRIVILEGES Implements restricted privileges using drop_uid() + +CONFIG_MADV_DONTNEED_TO_FREE To free pages, use MADV_DONTNEED instead of MADV_FREE (linux) +CONFIG_DISABLE_THP Disable transparent huge pages (linux) diff --git a/sysdep/cf/linux.h b/sysdep/cf/linux.h index 9c37dd8a..5edc4969 100644 --- a/sysdep/cf/linux.h +++ b/sysdep/cf/linux.h @@ -24,6 +24,7 @@ #define CONFIG_INCLUDE_SYSPRIV_H "sysdep/linux/syspriv.h" #define CONFIG_MADV_DONTNEED_TO_FREE +#define CONFIG_DISABLE_THP #ifndef AF_MPLS #define AF_MPLS 28 diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index e7c4e6b0..5d9c6bcd 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -19,6 +19,10 @@ #include #endif +#ifdef CONFIG_DISABLE_THP +#include +#endif + long page_size = 0; #ifdef HAVE_MMAP @@ -218,6 +222,12 @@ global_free_pages_cleanup_event(void *data UNUSED) void resource_sys_init(void) { +#ifdef CONFIG_DISABLE_THP + /* Disable transparent huge pages, they do not work properly with madvice(MADV_DONTNEED) */ + if (prctl(PR_SET_THP_DISABLE, (unsigned long) 1, (unsigned long) 0, (unsigned long) 0, (unsigned long) 0) < 0) + die("prctl(PR_SET_THP_DISABLE) failed: %m"); +#endif + #ifdef HAVE_MMAP ASSERT_DIE(global_free_pages.cnt == 0);