From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
x86@kernel.org, Linus Torvalds <torvalds@linuxfoundation.org>,
Christoph Hellwig <hch@lst.de>,
Matthew Wilcox <willy@infradead.org>,
Daniel Vetter <daniel@ffwll.ch>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>
Subject: Re: [patch V4 5/8] sched: highmem: Store local kmaps in task struct
Date: Thu, 19 Nov 2020 12:51:32 +0100 [thread overview]
Message-ID: <20201119115132.GN3121378@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20201118204007.372935758@linutronix.de>
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?
next prev parent reply other threads:[~2020-11-19 11:52 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 19:48 [patch V4 0/8] mm/highmem: Preemptible variant of kmap_atomic & friends Thomas Gleixner
2020-11-18 19:48 ` [patch V4 1/8] mm/highmem: Provide and use CONFIG_DEBUG_KMAP_LOCAL Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 2/8] mm/highmem: Provide CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP Thomas Gleixner
2020-11-18 21:13 ` Linus Torvalds
2020-11-19 8:46 ` Mel Gorman
2020-11-19 17:19 ` Linus Torvalds
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 3/8] x86: Support kmap_local() forced debugging Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2021-01-06 23:01 ` [BUG] from " Steven Rostedt
2021-01-07 1:03 ` Linus Torvalds
2021-01-07 1:16 ` Steven Rostedt
2021-01-07 1:49 ` Steven Rostedt
2021-01-07 1:49 ` Jakub Kicinski
2021-01-07 2:11 ` Willem de Bruijn
2021-01-07 4:44 ` Willem de Bruijn
2021-01-07 19:47 ` Linus Torvalds
2021-01-07 20:52 ` Steven Rostedt
2021-01-07 21:07 ` Willem de Bruijn
2020-11-18 19:48 ` [patch V4 4/8] sched: Make migrate_disable/enable() independent of RT Thomas Gleixner
2020-11-19 9:38 ` Mel Gorman
2020-11-19 11:14 ` Peter Zijlstra
2020-11-19 12:14 ` Mel Gorman
2020-11-19 14:17 ` Steven Rostedt
2020-11-19 17:23 ` Linus Torvalds
2020-11-19 18:28 ` Peter Zijlstra
2020-11-20 1:33 ` Thomas Gleixner
2020-11-20 9:29 ` Peter Zijlstra
2020-11-22 23:16 ` Andy Lutomirski
2020-11-23 21:15 ` Thomas Gleixner
2020-11-23 21:25 ` Thomas Gleixner
2020-11-23 22:07 ` Andy Lutomirski
2020-11-23 23:10 ` Thomas Gleixner
2020-11-24 10:29 ` [tip: sched/core] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 5/8] sched: highmem: Store local kmaps in task struct Thomas Gleixner
2020-11-19 11:33 ` Peter Zijlstra
2020-11-19 11:51 ` Peter Zijlstra [this message]
2020-11-19 12:12 ` Peter Zijlstra
2020-11-19 14:11 ` Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 6/8] mm/highmem: Provide kmap_local* Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 7/8] io-mapping: Provide iomap_local variant Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-18 19:48 ` [patch V4 8/8] x86/crashdump/32: Simplify copy_oldmem_page() Thomas Gleixner
2020-11-24 14:20 ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-24 8:03 ` [patch V4 0/8] mm/highmem: Preemptible variant of kmap_atomic & friends Peter Zijlstra
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=20201119115132.GN3121378@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=daniel@ffwll.ch \
--cc=dietmar.eggemann@arm.com \
--cc=hch@lst.de \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=torvalds@linuxfoundation.org \
--cc=vincent.guittot@linaro.org \
--cc=willy@infradead.org \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).