Skip to content

Commit

Permalink
[LibOS] Fix memmgr free list performance bug
Browse files Browse the repository at this point in the history
The `CHECK_LIST_HEAD` macro in `common/include/list.h` is used in memmgr
to traverse the free list and perform assertion checks. However, the
loop is not removed by the compiler even in release mode, leading to
unnecessary overhead. This commit fixes this by changing the macro to
`(void)0` in release mode.

Signed-off-by: Adrian Lutsch <[email protected]>
  • Loading branch information
adrianlut authored and mkow committed Nov 12, 2024
1 parent 87c752f commit 0997103
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
(CURSOR) != (HEAD)->first && (HEAD)->first; (CURSOR) = (TMP), (TMP) = (TMP)->FIELD.next)

/* Assertion code written in Gramine project */
#ifdef DEBUG
#define CHECK_LIST_HEAD(TYPE, HEAD, FIELD) \
do { \
TYPE pos; \
Expand All @@ -290,6 +291,9 @@
assert(pos->FIELD.next->FIELD.prev == pos); \
} \
} while (0)
#else
#define CHECK_LIST_HEAD(TYPE, HEAD, FIELD) ((void)0)
#endif

// Add NEW to OLD at position first (assuming first is all we need for now)
// Can probably drop TYPE with some preprocessor smarts
Expand Down

0 comments on commit 0997103

Please sign in to comment.