From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f200.google.com (mail-wr0-f200.google.com [209.85.128.200]) by kanga.kvack.org (Postfix) with ESMTP id AD5CF280842 for ; Wed, 10 May 2017 04:24:30 -0400 (EDT) Received: by mail-wr0-f200.google.com with SMTP id q91so6023734wrb.8 for ; Wed, 10 May 2017 01:24:30 -0700 (PDT) Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com. [2a00:1450:400c:c0c::242]) by mx.google.com with ESMTPS id 3si2612022wrk.214.2017.05.10.01.24.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:24:29 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id v42so6189578wrc.3 for ; Wed, 10 May 2017 01:24:29 -0700 (PDT) Date: Wed, 10 May 2017 10:24:25 +0200 From: Ingo Molnar 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: Sender: owner-linux-mm@kvack.org List-ID: 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 * 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 -- 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