Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1694891

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

From Tim Chen <tim.c.chen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache
Date 2017-07-24 19:00 +0200
Message-ID <u6OS5-7yA-7@gated-at.bofh.it> (permalink)
References <u5OUa-2dk-11@gated-at.bofh.it> <u5OUa-2dk-9@gated-at.bofh.it> <u6B8u-79T-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache Tim Chen <tim.c.chen@linux.intel.com> - 2017-07-22 00:50 +0200
  Re: [PATCH 2/2] mm/swap: Remove lock_initialized flag from swap_slots_cache "Huang\, Ying" <ying.huang@intel.com> - 2017-07-24 04:20 +0200
    Re: [PATCH 2/2] mm/swap: Remove lock_initialized flag from  swap_slots_cache Tim Chen <tim.c.chen@linux.intel.com> - 2017-07-24 19:00 +0200

csiph-web