[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119115132.GN3121378@hirez.programming.kicks-ass.net>
Date: Thu, 19 Nov 2020 12:51:32 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, x86@...nel.org,
Linus Torvalds <torvalds@...uxfoundation.org>,
Christoph Hellwig <hch@....de>,
Matthew Wilcox <willy@...radead.org>,
Daniel Vetter <daniel@...ll.ch>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>
Subject: Re: [patch V4 5/8] sched: highmem: Store local kmaps in task struct
On Wed, Nov 18, 2020 at 08:48:43PM +0100, Thomas Gleixner wrote:
> @@ -4073,6 +4089,7 @@ prepare_task_switch(struct rq *rq, struc
> perf_event_task_sched_out(prev, next);
> rseq_preempt(prev);
> fire_sched_out_preempt_notifiers(prev, next);
> + kmap_local_sched_out();
> prepare_task(next);
> prepare_arch_switch(next);
> }
> @@ -4139,6 +4156,7 @@ static struct rq *finish_task_switch(str
> finish_lock_switch(rq);
> finish_arch_post_lock_switch();
> kcov_finish_switch(current);
> + kmap_local_sched_in();
>
> fire_sched_in_preempt_notifiers(current);
> /*
> +void __kmap_local_sched_out(void)
> +{
> + struct task_struct *tsk = current;
> + pte_t *kmap_pte = kmap_get_pte();
> + int i;
> +
> + /* Clear kmaps */
> + for (i = 0; i < tsk->kmap_ctrl.idx; i++) {
> + }
> +}
> +
> +void __kmap_local_sched_in(void)
> +{
> + struct task_struct *tsk = current;
> + pte_t *kmap_pte = kmap_get_pte();
> + int i;
> +
> + /* Restore kmaps */
> + for (i = 0; i < tsk->kmap_ctrl.idx; i++) {
> + }
> +}
So even in the optimal case, this adds an unconditional load of
tsk->kmap_ctrl.idx to schedule() (2 misses, one pre and one post).
Munging preempt-notifiers behind a static_branch, which in that same
optimal case, avoided touching curr->preempt_notifier, resulted in a
measurable performance improvement. See commit:
1cde2930e154 ("sched/preempt: Add static_key() to preempt_notifiers")
Can we fudge some state in a cacheline we're already touching to avoid
this?
Powered by blists - more mailing lists