[v7,0/1] Add thread affinity
mbox series

Message ID 20241029085837.3615699-1-chenghaoyang@chromium.org
Headers show
Series
  • Add thread affinity
Related show

Message

Cheng-Hao Yang Oct. 29, 2024, 8:57 a.m. UTC
Hi folks,

This patch adds a method to set thread affinity, which is needed to
ensure performance in mtkisp7 pipeline handler and IPA.

This passes gitlab pipeline:
https://gitlab.freedesktop.org/chenghaoyang/libcamera/-/pipelines/1299712

v7:
- Add unit tests.

v6:
- Set thread affinity before run(), if it was not started yet.

v5:
- Return failure if any index is invalid.
- Drop the check of max size.

v4:
- Use `sizeof(data_->cpuset_.value())`.

v3:
- Keep the cpu indices in ThreadData.

v2:
- Check cpu indices within [0, `std::thread::hardware_concurrency()`).
- Limit max size of cpus to be CPU_SETSIZE.

BR,
Harvey

Han-Lin Chen (1):
  libcamera: add method to set thread affinity

 include/libcamera/base/thread.h |  5 ++++
 src/libcamera/base/thread.cpp   | 47 +++++++++++++++++++++++++++++++++
 test/threads.cpp                | 40 ++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)