Re: [PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/23/2017 07:15 PM, Huang, Ying wrote:
> Hi, Tim,
> 
> Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx> 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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux