From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by kanga.kvack.org (Postfix) with ESMTP id BC3EC6B0292 for ; Thu, 25 May 2017 21:39:12 -0400 (EDT) Received: by mail-qk0-f197.google.com with SMTP id 36so87260957qkz.10 for ; Thu, 25 May 2017 18:39:12 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id e58si4822608qta.179.2017.05.25.18.39.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 18:39:12 -0700 (PDT) Message-ID: <1495762747.29205.63.camel@redhat.com> Subject: Re: [PATCH v3 2/8] x86/mm: Change the leave_mm() condition for local TLB flushes From: Rik van Riel Date: Thu, 25 May 2017 21:39:07 -0400 In-Reply-To: <61de238db6d9c9018db020c41047ce32dac64488.1495759610.git.luto@kernel.org> References: <61de238db6d9c9018db020c41047ce32dac64488.1495759610.git.luto@kernel.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-linux-mm@kvack.org List-ID: To: Andy Lutomirski , X86 ML Cc: "linux-kernel@vger.kernel.org" , Borislav Petkov , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Dave Hansen , Nadav Amit , Michal Hocko , Arjan van de Ven On Thu, 2017-05-25 at 17:47 -0700, Andy Lutomirski wrote: > > +++ b/arch/x86/mm/tlb.c > @@ -311,7 +311,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, > unsigned long start, > A goto out; > A } > A > - if (!current->mm) { > + if (this_cpu_read(cpu_tlbstate.state) != TLBSTATE_OK) { > A leave_mm(smp_processor_id()); Unless -mm changed leave_mm (I did not check), this is not quite correct yet. The reason is leave_mm (at least in the latest Linus tree) ignores the cpu argument for one of its checks. You should probably fix that in an earlier patch, assuming you haven't already done so in -mm. void leave_mm(int cpu) { A A A A A A A A struct mm_struct *active_mm = this_cpu_read(cpu_tlbstate.active_mm); A A A A A A A A if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) A A A A A A A A A A A A A A A A BUG(); A A A A A A A A if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) { A A A A A A A A A A A A A A A A cpumask_clear_cpu(cpu, mm_cpumask(active_mm)); A A A A A A A A A A A A A A A A load_cr3(swapper_pg_dir); -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763558AbdEZBjM (ORCPT ); Thu, 25 May 2017 21:39:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56528 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbdEZBjL (ORCPT ); Thu, 25 May 2017 21:39:11 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E01963D941 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=riel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E01963D941 Message-ID: <1495762747.29205.63.camel@redhat.com> Subject: Re: [PATCH v3 2/8] x86/mm: Change the leave_mm() condition for local TLB flushes From: Rik van Riel To: Andy Lutomirski , X86 ML Cc: "linux-kernel@vger.kernel.org" , Borislav Petkov , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Nadav Amit , Dave Hansen , Nadav Amit , Michal Hocko , Arjan van de Ven Date: Thu, 25 May 2017 21:39:07 -0400 In-Reply-To: <61de238db6d9c9018db020c41047ce32dac64488.1495759610.git.luto@kernel.org> References: <61de238db6d9c9018db020c41047ce32dac64488.1495759610.git.luto@kernel.org> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 26 May 2017 01:39:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2017-05-25 at 17:47 -0700, Andy Lutomirski wrote: > > +++ b/arch/x86/mm/tlb.c > @@ -311,7 +311,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, > unsigned long start, >   goto out; >   } >   > - if (!current->mm) { > + if (this_cpu_read(cpu_tlbstate.state) != TLBSTATE_OK) { >   leave_mm(smp_processor_id()); Unless -mm changed leave_mm (I did not check), this is not quite correct yet. The reason is leave_mm (at least in the latest Linus tree) ignores the cpu argument for one of its checks. You should probably fix that in an earlier patch, assuming you haven't already done so in -mm. void leave_mm(int cpu) {         struct mm_struct *active_mm = this_cpu_read(cpu_tlbstate.active_mm);         if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)                 BUG();         if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {                 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));                 load_cr3(swapper_pg_dir);