mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v7 0/2] sched: Restructure task_mm_cid_work for predictability
@ 2025-02-19 11:31 Gabriele Monaco
  2025-02-19 11:31 ` [PATCH v7 1/2] sched: Move task_mm_cid_work to mm work_struct Gabriele Monaco
  2025-02-19 11:31 ` [PATCH v7 2/2] selftests/rseq: Add test for mm_cid compaction Gabriele Monaco
  0 siblings, 2 replies; 7+ messages in thread
From: Gabriele Monaco @ 2025-02-19 11:31 UTC (permalink / raw)
  To: linux-kernel, Mathieu Desnoyers, Peter Zijlstra, Ingo Molnar,
	Paul E. McKenney, Shuah Khan
  Cc: Gabriele Monaco

This patchset moves the task_mm_cid_work to a preemptible and migratable
context. This reduces the impact of this work to the scheduling latency
of real time tasks.
The change makes the recurrence of the task a bit more predictable.

The behaviour causing latency was introduced in commit 223baf9d17f2
("sched: Fix performance regression introduced by mm_cid") which
introduced a task work tied to the scheduler tick.
That approach presents two possible issues:
* the task work runs before returning to user and causes, in fact, a
  scheduling latency (with order of magnitude significant in PREEMPT_RT)
* periodic tasks with short runtime are less likely to run during the
  tick, hence they might not run the task work at all

Patch 1 contains the main changes, removing the task_work on the
scheduler tick and using a work_struct scheduled more reliably during
__rseq_handle_notify_resume.

Patch 2 adds a selftest to validate the functionality of the
task_mm_cid_work (i.e. to compact the mm_cids). The test fails if patch
1 of V6 ("sched: Compact RSEQ concurrency IDs with reduced threads and
affinity", applied separately) is not applied and is flaky without patch
1 of this series. We expect it to always pass with both applied.

Changes since V6 [1]:
* Switch to a simple work_struct instead of a delayed work
* Schedule the work_struct in __rseq_handle_notify_resume
* Asynchronously disable the work but make sure mm is there while we run
* Remove first patch as merged independently
* Fix commit tag for test

Changes since V5:
* Punctuation

Changes since V4 [2]:
* Fixes on the selftest
    * Polished memory allocation and cleanup
    * Handle the test failure in main

Changes since V3 [3]:
* Fixes on the selftest
    * Minor style issues in comments and indentation
    * Use of perror where possible
    * Add a barrier to align threads execution
    * Improve test failure and error handling

Changes since V2 [4]:
* Change the order of the patches
* Merge patches changing the main delayed_work logic
* Improved self-test to spawn 1 less thread and use the main one instead

Changes since V1 [5]:
* Re-arm the delayed_work at each invocation
* Cancel the work synchronously at mmdrop
* Remove next scan fields and completely rely on the delayed_work
* Shrink mm_cid allocation with nr thread/affinity (Mathieu Desnoyers)
* Add self test

[1] - https://lore.kernel.org/lkml/20250210153253.460471-1-gmonaco@redhat.com
[2] - https://lore.kernel.org/lkml/20250113074231.61638-4-gmonaco@redhat.com
[3] - https://lore.kernel.org/lkml/20241216130909.240042-1-gmonaco@redhat.com
[4] - https://lore.kernel.org/lkml/20241213095407.271357-1-gmonaco@redhat.com
[5] - https://lore.kernel.org/lkml/20241205083110.180134-2-gmonaco@redhat.com

To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
To: Paul E. McKenney <paulmck@kernel.org>
To: Shuah Khan <shuah@kernel.org>

Gabriele Monaco (2):
  sched: Move task_mm_cid_work to mm work_struct
  selftests/rseq: Add test for mm_cid compaction

 include/linux/mm_types.h                      |   8 +
 include/linux/sched.h                         |   7 +-
 kernel/rseq.c                                 |   1 +
 kernel/sched/core.c                           |  33 ++-
 kernel/sched/sched.h                          |   2 -
 tools/testing/selftests/rseq/.gitignore       |   1 +
 tools/testing/selftests/rseq/Makefile         |   2 +-
 .../selftests/rseq/mm_cid_compaction_test.c   | 200 ++++++++++++++++++
 8 files changed, 229 insertions(+), 25 deletions(-)
 create mode 100644 tools/testing/selftests/rseq/mm_cid_compaction_test.c


base-commit: 0ad2507d5d93f39619fc42372c347d6006b64319
prerequisite-patch-id: 6888a889ab5dcd50c3874005018576fdced3a5e5
-- 
2.48.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-20  8:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-19 11:31 [PATCH v7 0/2] sched: Restructure task_mm_cid_work for predictability Gabriele Monaco
2025-02-19 11:31 ` [PATCH v7 1/2] sched: Move task_mm_cid_work to mm work_struct Gabriele Monaco
2025-02-19 15:13   ` Mathieu Desnoyers
2025-02-19 16:32     ` Gabriele Monaco
2025-02-19 17:08       ` Mathieu Desnoyers
2025-02-20  8:00         ` Gabriele Monaco
2025-02-19 11:31 ` [PATCH v7 2/2] selftests/rseq: Add test for mm_cid compaction Gabriele Monaco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®