From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880AbdFVHZL (ORCPT ); Thu, 22 Jun 2017 03:25:11 -0400 Received: from mail.skyhub.de ([5.9.137.197]:42572 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752804AbdFVHZJ (ORCPT ); Thu, 22 Jun 2017 03:25:09 -0400 Date: Thu, 22 Jun 2017 09:24:49 +0200 From: Borislav Petkov To: Andy Lutomirski Cc: X86 ML , "linux-kernel@vger.kernel.org" , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Rik van Riel , Dave Hansen , Arjan van de Ven , Peter Zijlstra Subject: Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm Message-ID: <20170622072449.4rc4bnvucn7usuak@pd.tnic> References: <91f24a6145b2077f992902891f8fa59abe5c8696.1498022414.git.luto@kernel.org> <20170621184424.eixb2jdyy66xq4hg@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 = bump_mm_tlb_gen(mm); > > > > and in both cases, the bumping is done on mm->context.tlb_gen. > > > > So why isn't that enough to do the flushing and we have to consult > > info.new_tlb_gen too? > > The issue is a possible race. Suppose we start at tlb_gen == 1 and > then two concurrent flushes happen. The first flush is a full flush > and sets tlb_gen to 2. The second is a partial flush and sets tlb_gen > to 3. If the second flush gets propagated to a given CPU first and it Maybe I'm still missing something, which is likely... but if the second flush gets propagated to the CPU first, the CPU will have local tlb_gen 1 and thus enforce a full flush anyway because we will go 1 -> 3 on that particular CPU. Or? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id 3B6996B02FA for ; Thu, 22 Jun 2017 03:25:10 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id 64so2181343wrp.4 for ; Thu, 22 Jun 2017 00:25:10 -0700 (PDT) Received: from mail.skyhub.de (mail.skyhub.de. [5.9.137.197]) by mx.google.com with ESMTP id s11si648570wrb.115.2017.06.22.00.25.08 for ; Thu, 22 Jun 2017 00:25:09 -0700 (PDT) Date: Thu, 22 Jun 2017 09:24:49 +0200 From: Borislav Petkov Subject: Re: [PATCH v3 05/11] x86/mm: Track the TLB's tlb_gen and update the flushing algorithm Message-ID: <20170622072449.4rc4bnvucn7usuak@pd.tnic> References: <91f24a6145b2077f992902891f8fa59abe5c8696.1498022414.git.luto@kernel.org> <20170621184424.eixb2jdyy66xq4hg@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Andy Lutomirski Cc: X86 ML , "linux-kernel@vger.kernel.org" , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Rik van Riel , Dave Hansen , Arjan van de Ven , Peter Zijlstra 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 = bump_mm_tlb_gen(mm); > > > > and in both cases, the bumping is done on mm->context.tlb_gen. > > > > So why isn't that enough to do the flushing and we have to consult > > info.new_tlb_gen too? > > The issue is a possible race. Suppose we start at tlb_gen == 1 and > then two concurrent flushes happen. The first flush is a full flush > and sets tlb_gen to 2. The second is a partial flush and sets tlb_gen > to 3. If the second flush gets propagated to a given CPU first and it Maybe I'm still missing something, which is likely... but if the second flush gets propagated to the CPU first, the CPU will have local tlb_gen 1 and thus enforce a full flush anyway because we will go 1 -> 3 on that particular CPU. Or? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org