[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0b8a59a0-517f-1387-ad00-cb47fb5fc50c@redhat.com>
Date: Tue, 17 Dec 2019 09:00:59 -0500
From: Waiman Long <longman@...hat.com>
To: Kirill Tkhai <ktkhai@...tuozzo.com>,
Michal Hocko <mhocko@...nel.org>
Cc: Mike Kravetz <mike.kravetz@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Matthew Wilcox <willy@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
Andi Kleen <ak@...ux.intel.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
Subject: Re: [PATCH v2] mm/hugetlb: Defer freeing of huge pages if in non-task
context
On 12/17/19 5:50 AM, Kirill Tkhai wrote:
> On 17.12.2019 12:31, Michal Hocko wrote:
>> On Mon 16-12-19 20:25:08, Waiman Long wrote:
>> [...]
>>> Both the hugetbl_lock and the subpool lock can be acquired in
>>> free_huge_page(). One way to solve the problem is to make both locks
>>> irq-safe.
>> Please document why we do not take this, quite natural path and instead
>> we have to come up with an elaborate way instead. I believe the primary
>> motivation is that some operations under those locks are quite
>> expensive. Please add that to the changelog and ideally to the code as
>> well. We probably want to fix those anyway and then this would be a
>> temporary workaround.
>>
>>> Another alternative is to defer the freeing to a workqueue job.
>>>
>>> This patch implements the deferred freeing by adding a
>>> free_hpage_workfn() work function to do the actual freeing. The
>>> free_huge_page() call in a non-task context saves the page to be freed
>>> in the hpage_freelist linked list in a lockless manner.
>> Do we need to over complicate this (presumably) rare event by a lockless
>> algorithm? Why cannot we use a dedicated spin lock for for the linked
>> list manipulation? This should be really a trivial code without an
>> additional burden of all the lockless subtleties.
> Why not llist_add()/llist_del_all() ?
>
The llist_add() and llist_del_all() are just simple helpers. Because
this lockless case involve synchronization of two variables, the llist
helpers do not directly apply here. So the rests cannot be used. It will
look awkward it is partially converted to use the helpers. If we convert
to use a lock as suggested by Michal, using the helpers will be an
overkill as xchg() will not be needed.
Cheers,
Longman
Powered by blists - more mailing lists