From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752596AbdEJIYq (ORCPT ); Wed, 10 May 2017 04:24:46 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35261 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526AbdEJIYa (ORCPT ); Wed, 10 May 2017 04:24:30 -0400 Date: Wed, 10 May 2017 10:24:25 +0200 From: Ingo Molnar To: Thomas Gleixner Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , Borislav Petkov , Linus Torvalds , Andrew Morton , Mel Gorman , "linux-mm@kvack.org" , Rik van Riel , Dave Hansen , Nadav Amit , Michal Hocko , Arjan van de Ven Subject: Re: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm Message-ID: <20170510082425.5ks5okbjne7xgjtv@gmail.com> References: <1a124281c99741606f1789140f9805beebb119da.1494160201.git.luto@kernel.org> <20170510055727.g6wojjiis36a6nvm@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 * Thomas Gleixner wrote: > On Wed, 10 May 2017, Ingo Molnar wrote: > > > > * Thomas Gleixner 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 = ¤t->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