From: Gabriele Monaco <gmonaco@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Mel Gorman <mgorman@suse.de>, Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org,
Gabriele Monaco <gmonaco@redhat.com>
Subject: [PATCH v2 2/4] sched: Remove mm_cid_next_scan as obsolete
Date: Fri, 13 Dec 2024 10:54:05 +0100 [thread overview]
Message-ID: <20241213095407.271357-3-gmonaco@redhat.com> (raw)
In-Reply-To: <20241213095407.271357-1-gmonaco@redhat.com>
The checks for the scan time in task_mm_cid_work are now superfluous
since the task runs in a delayed_work and the minimum periodicity is
already implied.
This patch removes those checks and the field from the mm_struct.
Additionally, we include a simple check to quickly terminate the
function if we have no work to be done (i.e. no mm_cid is allocated).
This is helpful for tasks that sleep for a long time, but also for
terminated task. We are no longer following the process' state, hence
the function continues to run after a process terminates but before its
mm is freed.
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
include/linux/mm_types.h | 7 -------
kernel/sched/core.c | 19 +++----------------
2 files changed, 3 insertions(+), 23 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 92acb827fee4..8a76a1c09234 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -829,12 +829,6 @@ struct mm_struct {
* runqueue locks.
*/
struct mm_cid __percpu *pcpu_cid;
- /*
- * @mm_cid_next_scan: Next mm_cid scan (in jiffies).
- *
- * When the next mm_cid scan is due (in jiffies).
- */
- unsigned long mm_cid_next_scan;
/**
* @nr_cpus_allowed: Number of CPUs allowed for mm.
*
@@ -1228,7 +1222,6 @@ static inline int mm_alloc_cid_noprof(struct mm_struct *mm, struct task_struct *
return -ENOMEM;
mm_init_cid(mm, p);
INIT_DELAYED_WORK(&mm->mm_cid_work, task_mm_cid_work);
- mm->mm_cid_next_scan = jiffies + msecs_to_jiffies(MM_CID_SCAN_DELAY);
schedule_delayed_work(&mm->mm_cid_work,
msecs_to_jiffies(MM_CID_SCAN_DELAY));
return 0;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e3b27b73301c..30d78fe14eff 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10520,28 +10520,15 @@ static void sched_mm_cid_remote_clear_weight(struct mm_struct *mm, int cpu,
void task_mm_cid_work(struct work_struct *work)
{
- unsigned long now = jiffies, old_scan, next_scan;
struct cpumask *cidmask;
struct delayed_work *delayed_work = container_of(work, struct delayed_work, work);
struct mm_struct *mm = container_of(delayed_work, struct mm_struct, mm_cid_work);
int weight, cpu;
- old_scan = READ_ONCE(mm->mm_cid_next_scan);
- next_scan = now + msecs_to_jiffies(MM_CID_SCAN_DELAY);
- if (!old_scan) {
- unsigned long res;
-
- res = cmpxchg(&mm->mm_cid_next_scan, old_scan, next_scan);
- if (res != old_scan)
- old_scan = res;
- else
- old_scan = next_scan;
- }
- if (time_before(now, old_scan))
- goto out;
- if (!try_cmpxchg(&mm->mm_cid_next_scan, &old_scan, next_scan))
- goto out;
cidmask = mm_cidmask(mm);
+ /* Nothing to clear for now */
+ if (cpumask_empty(cidmask))
+ goto out;
/* Clear cids that were not recently used. */
for_each_possible_cpu(cpu)
sched_mm_cid_remote_clear_old(mm, cpu);
--
2.47.1
next prev parent reply other threads:[~2024-12-13 9:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 9:54 [PATCH v2 0/4] sched: Move task_mm_cid_work to mm delayed work Gabriele Monaco
2024-12-13 9:54 ` [PATCH v2 1/4] " Gabriele Monaco
2024-12-13 14:14 ` Mathieu Desnoyers
2024-12-13 15:15 ` Gabriele Monaco
2024-12-13 9:54 ` Gabriele Monaco [this message]
2024-12-13 14:01 ` [PATCH v2 2/4] sched: Remove mm_cid_next_scan as obsolete Mathieu Desnoyers
2024-12-13 9:54 ` [PATCH v2 3/4] sched: Compact RSEQ concurrency IDs with reduced threads and affinity Gabriele Monaco
2024-12-13 14:05 ` Mathieu Desnoyers
2024-12-13 9:54 ` [PATCH v2 4/4] rseq/selftests: Add test for mm_cid compaction Gabriele Monaco
2024-12-13 14:29 ` Mathieu Desnoyers
2024-12-13 15:03 ` Gabriele Monaco
2024-12-13 11:31 ` [PATCH v2 0/4] sched: Move task_mm_cid_work to mm delayed work Gabriele Monaco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241213095407.271357-3-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox