Re: [PATCH v2] x86: enable RCU based table free

From: Vitaly Kuznetsov
Date: Fri Aug 25 2017 - 03:10:58 EST


Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> writes:

> Peter Zijlstra <peterz@xxxxxxxxxxxxx> writes:
>
>> On Thu, Aug 24, 2017 at 11:22:58AM +0200, Vitaly Kuznetsov wrote:
>>
>>> diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
>>> index c7797307fc2b..d43a7fcafee9 100644
>>> --- a/arch/x86/include/asm/tlb.h
>>> +++ b/arch/x86/include/asm/tlb.h
>>> @@ -15,4 +15,9 @@
>>>
>>> #include <asm-generic/tlb.h>
>>>
>>> +static inline void __tlb_remove_table(void *table)
>>> +{
>>> + free_page_and_swap_cache(table);
>>> +}
>>
>> Most other archs have this in pgtable.h, only ARM* has it in tlb.h.
>>
>
> Sure, I can move it in v3 if nobody objects.
>

Well, turns out it is going to be a bit tricky.

free_page_and_swap_cache() is defined in linux/swap.h but we can't just
include it from arch/x86/include/asm/pgtable.h as pgtable.h itself is
included from swap.h:

...
In file included from ./include/linux/mm.h:70:0,
from ./include/linux/memcontrol.h:29,
from ./include/linux/swap.h:8,
from ./include/linux/suspend.h:4,
from arch/x86/kernel/asm-offsets.c:12:
./arch/x86/include/asm/pgtable.h: In function â__tlb_remove_tableâ:
./arch/x86/include/asm/pgtable.h:1252:2: error: implicit declaration of function âfree_page_and_swap_cacheâ; did you mean âfile_write_and_wait_rangeâ? [-Werror=implicit-function-declaration]
free_page_and_swap_cache(table);
^~~~~~~~~~~~~~~~~~~~~~~~
...

An easy solution would be to make __tlb_remove_table() a define instead
of inline but personally I'd rather prefer to follow ARM and leave it in
tlb.h.

--
Vitaly