diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93c9b850a9f6392fc6e3e612f0913b83f424541b..8b34b7d94053ac15e4da1e40e34d654aef4994b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -470,3 +470,9 @@ continuation-stealing-locked: variables: EMPER_CONTINUATION_STEALING_MODE: 'locked' EMPER_LOCKED_WS_QUEUE: 'true' + +continuation-stealing-madv-free: + extends: + - .test + variables: + EMPER_CONTINUATION_STEALING_MADVISE_STACK: 'free' diff --git a/CONTINUATION-STEALING b/CONTINUATION-STEALING index 1a03e4fada6215fb22f98f55a6824b2de12a13dc..633da347d5108923c5e866de5bc90db0fa55be50 100644 --- a/CONTINUATION-STEALING +++ b/CONTINUATION-STEALING @@ -1,3 +1,9 @@ +Continuation Stealing Stats: +- Steal count +- unmap stats: + - how often, how large, how long does it take? + - how often was resumable 'false' + TODO: - From Nico's branch: WsClV3Queue, WsClV4Queue - EMPER_FIBRIL_SYNC, that is FibrilDeque and FibrilLock (which appears to be just a spin lock?) not yet ported. Ask Nico the rationale behind that. diff --git a/emper/Context.cpp b/emper/Context.cpp index f2607ac442eb164003640b62ec245d0664a9033b..075a2a21ea488bbcca872671edcf34b97290c23c 100644 --- a/emper/Context.cpp +++ b/emper/Context.cpp @@ -41,7 +41,7 @@ void Context::unmap(void* from) const { const size_t PAGE_SIZE_MASK = 4 * 1024 - 1; const uintptr_t start = ((uintptr_t) context + PAGE_SIZE_MASK) & ~PAGE_SIZE_MASK; const uintptr_t end = (uintptr_t) from & ~PAGE_SIZE_MASK; - + const size_t length = end - start; const int advice = []{ if constexpr (emper::CONTINUATION_STEALING_MADVISE_STACK == emper::ContinuationStealingMadviseStack::dontneed) { return MADV_DONTNEED; @@ -50,8 +50,11 @@ void Context::unmap(void* from) const { } }(); + + LOGD("madvise() start=" << start << ", length=" << length << ", advice=" << advice); + // NOLINTNEXTLINE(performance-no-int-to-ptr) - errno = madvise((void*) start, (end - start), advice); + errno = madvise((void*) start, length, advice); if (errno) { DIE_MSG_ERRNO("Unmapping unused stack space failed"); } diff --git a/tests/test-runner/continuation-stealing-test-runner.cpp b/tests/test-runner/continuation-stealing-test-runner.cpp new file mode 100644 index 0000000000000000000000000000000000000000..452c0815d256bcddef4fd44e9f54127aec6b1df5 --- /dev/null +++ b/tests/test-runner/continuation-stealing-test-runner.cpp @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright © 2022 Florian Schmaus +#include <cstdlib> + +#include "Emper.hpp" +#include "emper-common.h" +#include "test-runner.hpp" + +auto main(UNUSED_ARG int argc, UNUSED_ARG char* argv[]) -> int { + if constexpr (!emper::CONTINUATION_STEALING || emper::BUILD_WITH_CLANG) { + exit(77); + } + + return testMain(); +}