Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1638652

Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm
Date 2017-05-10 10:30 +0200
Message-ID <tFvap-6Nl-9@gated-at.bofh.it> (permalink)
References <tECxj-3oj-5@gated-at.bofh.it> <tECxj-3oj-3@gated-at.bofh.it> <tFkeZ-6Un-3@gated-at.bofh.it> <tFsPg-5e7-7@gated-at.bofh.it> <tFv0K-6Kh-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Thomas Gleixner <tglx@linutronix.de> wrote:

> On Wed, 10 May 2017, Ingo Molnar wrote:
> > 
> > * Thomas Gleixner <tglx@linutronix.de> wrote:
> > 
> > > On Sun, 7 May 2017, Andy Lutomirski wrote:
> > > >  /* context.lock is held for us, so we don't need any locking. */
> > > >  static void flush_ldt(void *current_mm)
> > > >  {
> > > > +	struct mm_struct *mm = current_mm;
> > > >  	mm_context_t *pc;
> > > >  
> > > > -	if (current->active_mm != current_mm)
> > > > +	if (this_cpu_read(cpu_tlbstate.loaded_mm) != current_mm)
> > > 
> > > While functional correct, this really should compare against 'mm'.
> > > 
> > > >  		return;
> > > >  
> > > > -	pc = &current->active_mm->context;
> > > > +	pc = &mm->context;
> > 
> > So this appears to be the function:
> > 
> >  static void flush_ldt(void *current_mm)
> >  {
> >         struct mm_struct *mm = current_mm;
> >         mm_context_t *pc;
> > 
> >         if (this_cpu_read(cpu_tlbstate.loaded_mm) != current_mm)
> >                 return;
> > 
> >         pc = &mm->context;
> >         set_ldt(pc->ldt->entries, pc->ldt->size);
> >  }
> > 
> > why not rename 'current_mm' to 'mm' and remove the 'mm' local variable?
> 
> Because you cannot dereference a void pointer, i.e. &mm->context ....

Indeed, doh! The naming totally confused me. The way I'd write it is the canonical 
form for such callbacks:

	static void flush_ldt(void *data)
	{
		struct mm_struct *mm = data;

... which beyond unconfusing me would probably also have prevented any accidental 
use of the 'current_mm' callback argument.

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Andy Lutomirski <luto@kernel.org> - 2017-05-08 00:10 +0200
  Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded  mm Thomas Gleixner <tglx@linutronix.de> - 2017-05-09 22:50 +0200
    Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Andy Lutomirski <luto@kernel.org> - 2017-05-10 01:00 +0200
    Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Ingo Molnar <mingo@kernel.org> - 2017-05-10 08:00 +0200
      Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded  mm Thomas Gleixner <tglx@linutronix.de> - 2017-05-10 10:20 +0200
        Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Ingo Molnar <mingo@kernel.org> - 2017-05-10 10:30 +0200
          Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Andy Lutomirski <luto@kernel.org> - 2017-05-11 00:50 +0200
            Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Ingo Molnar <mingo@kernel.org> - 2017-05-11 09:20 +0200

csiph-web