Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-23 Thread Andy Lutomirski
On Fri, Jun 23, 2017 at 1:42 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 11:08:38AM -0700, Andy Lutomirski wrote: >> Yes, I agree it's confusing. There really are three numbers. Those >> numbers are: the latest generation, the generation that this CPU has >> caught up

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-23 Thread Andy Lutomirski
On Fri, Jun 23, 2017 at 1:42 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 11:08:38AM -0700, Andy Lutomirski wrote: >> Yes, I agree it's confusing. There really are three numbers. Those >> numbers are: the latest generation, the generation that this CPU has >> caught up to, and the

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-23 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 11:08:38AM -0700, Andy Lutomirski wrote: > Yes, I agree it's confusing. There really are three numbers. Those > numbers are: the latest generation, the generation that this CPU has > caught up to, and the generation that the requester of the flush we're > currently

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-23 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 11:08:38AM -0700, Andy Lutomirski wrote: > Yes, I agree it's confusing. There really are three numbers. Those > numbers are: the latest generation, the generation that this CPU has > caught up to, and the generation that the requester of the flush we're > currently

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 10:22 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 08:55:36AM -0700, Andy Lutomirski wrote: >> > Ah, simple: we control the flushing with info.new_tlb_gen and >> > mm->context.tlb_gen. I.e., this check: >> > >> > >> > if (f->end !=

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 10:22 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 08:55:36AM -0700, Andy Lutomirski wrote: >> > Ah, simple: we control the flushing with info.new_tlb_gen and >> > mm->context.tlb_gen. I.e., this check: >> > >> > >> > if (f->end != TLB_FLUSH_ALL && >> >

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 08:55:36AM -0700, Andy Lutomirski wrote: > > Ah, simple: we control the flushing with info.new_tlb_gen and > > mm->context.tlb_gen. I.e., this check: > > > > > > if (f->end != TLB_FLUSH_ALL && > > f->new_tlb_gen == local_tlb_gen + 1 && > >

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 08:55:36AM -0700, Andy Lutomirski wrote: > > Ah, simple: we control the flushing with info.new_tlb_gen and > > mm->context.tlb_gen. I.e., this check: > > > > > > if (f->end != TLB_FLUSH_ALL && > > f->new_tlb_gen == local_tlb_gen + 1 && > >

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 7:59 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 07:48:21AM -0700, Andy Lutomirski wrote: >> On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: >> > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: >> >> > I'm

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 7:59 AM, Borislav Petkov wrote: > On Thu, Jun 22, 2017 at 07:48:21AM -0700, Andy Lutomirski wrote: >> On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: >> > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: >> >> > I'm certainly still missing

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 07:48:21AM -0700, Andy Lutomirski wrote: > On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: > > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: > >> > I'm certainly still missing something here: > >> > > >> > We have f->new_tlb_gen

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Thu, Jun 22, 2017 at 07:48:21AM -0700, Andy Lutomirski wrote: > On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: > > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: > >> > I'm certainly still missing something here: > >> > > >> > We have f->new_tlb_gen and mm_tlb_gen

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: >> > I'm certainly still missing something here: >> > >> > We have f->new_tlb_gen and mm_tlb_gen to control the flushing, i.e., we >> > do once >> > >> >

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Andy Lutomirski
On Thu, Jun 22, 2017 at 12:24 AM, Borislav Petkov wrote: > On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: >> > I'm certainly still missing something here: >> > >> > We have f->new_tlb_gen and mm_tlb_gen to control the flushing, i.e., we >> > do once >> > >> >

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: > > I'm certainly still missing something here: > > > > We have f->new_tlb_gen and mm_tlb_gen to control the flushing, i.e., we > > do once > > > > bump_mm_tlb_gen(mm); > > > > and once > > > > info.new_tlb_gen =

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-22 Thread Borislav Petkov
On Wed, Jun 21, 2017 at 07:46:05PM -0700, Andy Lutomirski wrote: > > I'm certainly still missing something here: > > > > We have f->new_tlb_gen and mm_tlb_gen to control the flushing, i.e., we > > do once > > > > bump_mm_tlb_gen(mm); > > > > and once > > > > info.new_tlb_gen =

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Andy Lutomirski
On Wed, Jun 21, 2017 at 11:44 AM, Borislav Petkov wrote: > On Tue, Jun 20, 2017 at 10:22:11PM -0700, Andy Lutomirski wrote: >> + this_cpu_write(cpu_tlbstate.ctxs[0].ctx_id, next->context.ctx_id); >> + this_cpu_write(cpu_tlbstate.ctxs[0].tlb_gen, >> +

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Andy Lutomirski
On Wed, Jun 21, 2017 at 11:44 AM, Borislav Petkov wrote: > On Tue, Jun 20, 2017 at 10:22:11PM -0700, Andy Lutomirski wrote: >> + this_cpu_write(cpu_tlbstate.ctxs[0].ctx_id, next->context.ctx_id); >> + this_cpu_write(cpu_tlbstate.ctxs[0].tlb_gen, >> +

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Borislav Petkov
On Tue, Jun 20, 2017 at 10:22:11PM -0700, Andy Lutomirski wrote: > There are two kernel features that would benefit from tracking > how up-to-date each CPU's TLB is in the case where IPIs aren't keeping > it up to date in real time: > > - Lazy mm switching currently works by switching to init_mm

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Borislav Petkov
On Tue, Jun 20, 2017 at 10:22:11PM -0700, Andy Lutomirski wrote: > There are two kernel features that would benefit from tracking > how up-to-date each CPU's TLB is in the case where IPIs aren't keeping > it up to date in real time: > > - Lazy mm switching currently works by switching to init_mm

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Andy Lutomirski
On Wed, Jun 21, 2017 at 1:32 AM, Thomas Gleixner wrote: > On Tue, 20 Jun 2017, Andy Lutomirski wrote: >> struct flush_tlb_info { >> + /* >> + * We support several kinds of flushes. >> + * >> + * - Fully flush a single mm. flush_mm will be set, flush_end

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Andy Lutomirski
On Wed, Jun 21, 2017 at 1:32 AM, Thomas Gleixner wrote: > On Tue, 20 Jun 2017, Andy Lutomirski wrote: >> struct flush_tlb_info { >> + /* >> + * We support several kinds of flushes. >> + * >> + * - Fully flush a single mm. flush_mm will be set, flush_end will be > > flush_mm

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Thomas Gleixner
On Tue, 20 Jun 2017, Andy Lutomirski wrote: > struct flush_tlb_info { > + /* > + * We support several kinds of flushes. > + * > + * - Fully flush a single mm. flush_mm will be set, flush_end will be flush_mm is the *mm member in the struct, right? You might rename that as a

Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm

2017-06-21 Thread Thomas Gleixner
On Tue, 20 Jun 2017, Andy Lutomirski wrote: > struct flush_tlb_info { > + /* > + * We support several kinds of flushes. > + * > + * - Fully flush a single mm. flush_mm will be set, flush_end will be flush_mm is the *mm member in the struct, right? You might rename that as a