mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Rik van Riel <riel@surriel.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	mingo@kernel.org, luto@kernel.org, x86@kernel.org, efault@gmx.de,
	dave.hansen@intel.com
Subject: Re: [PATCH 11/11] mm,sched: conditionally skip lazy TLB mm refcounting
Date: Fri, 3 Aug 2018 17:56:18 +0200	[thread overview]
Message-ID: <20180803155618.GB2494@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20180801100255.4278-12-riel@surriel.com>

On Wed, Aug 01, 2018 at 06:02:55AM -0400, Rik van Riel wrote:
> Conditionally skip lazy TLB mm refcounting. When an architecture has
> CONFIG_ARCH_NO_ACTIVE_MM_REFCOUNTING enabled, an mm that is used in
> lazy TLB mode anywhere will get shot down from exit_mmap, and there
> in no need to incur the cache line bouncing overhead of refcounting
> a lazy TLB mm.
> 
> Implement this by moving the refcounting of a lazy TLB mm to helper
> functions, which skip the refcounting when it is not necessary.
> 
> Deal with use_mm and unuse_mm by fully splitting out the refcounting
> of the lazy TLB mm a kernel thread may have when entering use_mm from
> the refcounting of the mm that use_mm is about to start using.


> @@ -2803,16 +2803,29 @@ context_switch(struct rq *rq, struct task_struct *prev,
>  	 * membarrier after storing to rq->curr, before returning to
>  	 * user-space.
>  	 */
> +	/*
> +	 * kernel -> kernel	lazy + transfer active
> +	 *   user -> kernel	lazy + grab_lazy_mm active
> +	 *
> +	 * kernel ->   user	switch + drop_lazy_mm active
> +	 *   user ->   user	switch
> +	 */
> +	if (!mm) {				// to kernel
>  		next->active_mm = oldmm;
>  		enter_lazy_tlb(oldmm, next);
> +
> +		if (prev->mm)			// from user
> +			grab_lazy_mm(oldmm);
> +		else
> +			prev->active_mm = NULL;
> +	} else {				// to user
>  		switch_mm_irqs_off(oldmm, mm, next);
>  
> +		if (!prev->mm) {		// from kernel
> +			/* will drop_lazy_mm() in finish_task_switch(). */
> +			rq->prev_mm = oldmm;
> +			prev->active_mm = NULL;
> +		}
>  	}

So this still confuses the heck out of me; and the Changelog doesn't
seem to even mention it. You still track and swizzle ->active_mm but no
longer refcount it.

Why can't we skip the ->active_mm swizzle and keep ->active_mm == ->mm.

Doing the swizzle but not the refcount just makes me itch.

  reply	other threads:[~2018-08-03 15:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 10:02 [PATCH v2 0/11] x86,tlb,mm: more lazy TLB cleanups & optimizations Rik van Riel
2018-08-01 10:02 ` [PATCH 01/11] x86,tlb: clarify memory barrier in switch_mm_irqs_off Rik van Riel
2018-08-01 10:02 ` [PATCH 02/11] smp: use __cpumask_set_cpu in on_each_cpu_cond Rik van Riel
2018-08-01 10:02 ` [PATCH 03/11] smp,cpumask: introduce on_each_cpu_cond_mask Rik van Riel
2018-08-01 10:02 ` [PATCH 04/11] x86,mm: use on_each_cpu_cond for TLB flushes Rik van Riel
2018-08-01 10:02 ` [PATCH 05/11] mm,tlb: turn dummy defines into inline functions Rik van Riel
2018-08-01 10:02 ` [PATCH 06/11] mm,x86: skip cr4 and ldt reload when mm stays the same Rik van Riel
2018-08-01 10:02 ` [PATCH 07/11] x86,mm: remove leave_mm cpu argument Rik van Riel
2018-08-01 10:02 ` [PATCH 08/11] arch,mm: add config variable to skip lazy TLB mm refcounting Rik van Riel
2018-08-01 10:02 ` [PATCH 09/11] mm,x86: shoot down lazy TLB references at exit_mmap time Rik van Riel
2018-08-01 10:02 ` [PATCH 10/11] x86,tlb: really leave mm on shootdown Rik van Riel
2018-08-01 10:02 ` [PATCH 11/11] mm,sched: conditionally skip lazy TLB mm refcounting Rik van Riel
2018-08-03 15:56   ` Peter Zijlstra [this message]
2018-08-03 16:40     ` Rik van Riel
2018-08-03 17:25       ` Peter Zijlstra
2018-08-03 17:39         ` Rik van Riel
2018-08-06 17:50           ` 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=20180803155618.GB2494@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dave.hansen@intel.com \
    --cc=efault@gmx.de \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=riel@surriel.com \
    --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

all inboxes | Powered by JetHome®