lkml.org 
[lkml]   [2017]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC 09/10] x86/mm: Rework lazy TLB to track the actual loaded mm
On Wed, May 10, 2017 at 1:24 AM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Thomas Gleixner <tglx@linutronix.de> wrote:
>
>> On Wed, 10 May 2017, Ingo Molnar wrote:
>> >
>> > * Thomas Gleixner <tglx@linutronix.de> 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 = &current->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.
>
>

void *data and void *info both seem fairly common in the kernel. How
about my personal favorite for non-kernel work, though: void *mm_void?
It documents what the parameter means and avoids the confusion.

--Andy

\
 
 \ /
  Last update: 2017-05-11 00:43    [W:0.069 / U:0.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site