lkml.org 
[lkml]   [2017]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache
From
Date
On 07/23/2017 07:15 PM, Huang, Ying wrote:
> Hi, Tim,
>
> Tim Chen <tim.c.chen@linux.intel.com> writes:
>
>> We will only reach the lock initialization code
>> in alloc_swap_slot_cache when the cpu's swap_slots_cache's slots
>> have not been allocated and swap_slots_cache has not been initialized
>> previously. So the lock_initialized check is redundant and unnecessary.
>> Remove lock_initialized flag from swap_slots_cache to save memory.
>
> Is there a race condition with CPU offline/online when preempt is enabled?
>
> CPU A CPU B
> ----- -----
> get_swap_page()
> get cache[B], cache[B]->slots != NULL
> preempted and moved to CPU A
> be offlined
> be onlined
> alloc_swap_slot_cache()
> mutex_lock(cache[B]->alloc_lock)
> mutex_init(cache[B]->alloc_lock) !!!
>
> The cache[B]->alloc_lock will be reinitialized when it is still held.

Looks like for this case the lock_initialized flag is still needed
to prevent such races and prevent re-initialization of taken locks.

Okay, let's scrap patch 2.

Thanks.

Tim

\
 
 \ /
  Last update: 2017-07-24 18:56    [W:0.708 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site