[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6445164-ab4b-86cc-731f-5f6509a7449d@linux.intel.com>
Date: Mon, 24 Jul 2017 09:54:50 -0700
From: Tim Chen <tim.c.chen@...ux.intel.com>
To: "Huang, Ying" <ying.huang@...el.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Wenwei Tao <wenwei.tww@...baba-inc.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Minchan Kim <minchan@...nel.org>,
Rik van Riel <riel@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>,
Hillf Danton <hillf.zj@...baba-inc.com>
Subject: Re: [PATCH 2/2] mm/swap: Remove lock_initialized flag from
swap_slots_cache
On 07/23/2017 07:15 PM, Huang, Ying wrote:
> Hi, Tim,
>
> Tim Chen <tim.c.chen@...ux.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
Powered by blists - more mailing lists