Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753061AbdFUQi5 (ORCPT ); Wed, 21 Jun 2017 12:38:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:42188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbdFUQiz (ORCPT ); Wed, 21 Jun 2017 12:38:55 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D053A2187B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org MIME-Version: 1.0 In-Reply-To: <20170621103322.pwi6koe7jee7hd63@pd.tnic> References: <20170621103322.pwi6koe7jee7hd63@pd.tnic> From: Andy Lutomirski Date: Wed, 21 Jun 2017 08:23:07 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 04/11] x86/mm: Give each mm TLB flush generation a unique ID To: Borislav Petkov Cc: Andy Lutomirski , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1462 Lines: 46 On Wed, Jun 21, 2017 at 3:33 AM, Borislav Petkov wrote: > On Tue, Jun 20, 2017 at 10:22:10PM -0700, Andy Lutomirski wrote: >> +#define INIT_MM_CONTEXT(mm) \ >> + .context = { \ >> + .ctx_id = 1, \ > > So ctx_id of 0 is invalid? > > Let's state that explicitly. We could even use it to sanity-check mms or > whatever. It's stated explicitly in the comment where it's declared in the same file. > >> + } >> + >> void leave_mm(int cpu); >> >> #endif /* _ASM_X86_MMU_H */ >> diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h >> index ecfcb6643c9b..e5295d485899 100644 >> --- a/arch/x86/include/asm/mmu_context.h >> +++ b/arch/x86/include/asm/mmu_context.h >> @@ -129,9 +129,14 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) >> this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY); >> } >> >> +extern atomic64_t last_mm_ctx_id; > > I think we prefer externs/variable defines at the beginning of the file, > not intermixed with functions. Done > >> +static inline u64 bump_mm_tlb_gen(struct mm_struct *mm) > > inc_mm_tlb_gen() I guess. git grep says like "inc" more :-) Done >> + * that synchronizes with switch_mm: callers are required to order > > Please end function names with parentheses. Done.