Re: [RFC PATCH] sched: Fix performance regression introduced by mm_cid

From: Mathieu Desnoyers
Date: Tue Apr 04 2023 - 09:36:17 EST


On 2023-04-04 05:05, Peter Zijlstra wrote:
On Mon, Apr 03, 2023 at 02:13:42PM -0400, Mathieu Desnoyers wrote:
void sched_mm_cid_exit_signals(struct task_struct *t)
{
struct mm_struct *mm = t->mm;
- unsigned long flags;
+ struct rq_flags rf;
+ struct rq *rq;
if (!mm)
return;
- local_irq_save(flags);
+
+ preempt_disable();
+ rq = this_rq();
+ rq_lock_irqsave(rq, &rf);
mm_cid_put(mm, t->mm_cid);
- t->mm_cid = -1;
+ t->last_mm_cid = t->mm_cid = -1;
t->mm_cid_active = 0;
- local_irq_restore(flags);
+ rq_unlock_irqrestore(rq, &rf);
+ preempt_enable();
}

FWIW a *slightly* cheaper form is:

preempt_disable();
rq = this_rq();
rq_lock_irqsave(rq, &rf);
preempt_enable_noresched(); /* holding spinlock */
...
rq_unlock_irqrestore(rq, &rf);

Good point, updated for next round.

Thanks,

Mathieu



--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com