From: "Yin, Fengwei" <fengwei.yin@intel.com>
To: "Huang, Ying" <ying.huang@intel.com>,
Ryan Roberts <ryan.roberts@arm.com>
Cc: David Hildenbrand <david@redhat.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Gao Xiang <xiang@kernel.org>, Yu Zhao <yuzhao@google.com>,
Yang Shi <shy828301@gmail.com>, Michal Hocko <mhocko@suse.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Barry Song <21cnbao@gmail.com>, Chris Li <chrisl@kernel.org>
Subject: Re: [PATCH v4 5/6] mm: vmscan: Avoid split during shrink_folio_list()
Date: Mon, 18 Mar 2024 18:00:19 +0800 [thread overview]
Message-ID: <a75ea34a-7512-4169-b987-95f11a7f3dd0@intel.com> (raw)
In-Reply-To: <878r2gwahg.fsf@yhuang6-desk2.ccr.corp.intel.com>
On 3/18/2024 10:16 AM, Huang, Ying wrote:
> Ryan Roberts <ryan.roberts@arm.com> writes:
>
>> Hi Yin Fengwei,
>>
>> On 15/03/2024 11:12, David Hildenbrand wrote:
>>> On 15.03.24 11:49, Ryan Roberts wrote:
>>>> On 15/03/2024 10:43, David Hildenbrand wrote:
>>>>> On 11.03.24 16:00, Ryan Roberts wrote:
>>>>>> Now that swap supports storing all mTHP sizes, avoid splitting large
>>>>>> folios before swap-out. This benefits performance of the swap-out path
>>>>>> by eliding split_folio_to_list(), which is expensive, and also sets us
>>>>>> up for swapping in large folios in a future series.
>>>>>>
>>>>>> If the folio is partially mapped, we continue to split it since we want
>>>>>> to avoid the extra IO overhead and storage of writing out pages
>>>>>> uneccessarily.
>>>>>>
>>>>>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>>>>>> ---
>>>>>> mm/vmscan.c | 9 +++++----
>>>>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>>>>
>>>>>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>>>>>> index cf7d4cf47f1a..0ebec99e04c6 100644
>>>>>> --- a/mm/vmscan.c
>>>>>> +++ b/mm/vmscan.c
>>>>>> @@ -1222,11 +1222,12 @@ static unsigned int shrink_folio_list(struct list_head
>>>>>> *folio_list,
>>>>>> if (!can_split_folio(folio, NULL))
>>>>>> goto activate_locked;
>>>>>> /*
>>>>>> - * Split folios without a PMD map right
>>>>>> - * away. Chances are some or all of the
>>>>>> - * tail pages can be freed without IO.
>>>>>> + * Split partially mapped folios map
>>>>>> + * right away. Chances are some or all
>>>>>> + * of the tail pages can be freed
>>>>>> + * without IO.
>>>>>> */
>>>>>> - if (!folio_entire_mapcount(folio) &&
>>>>>> + if (!list_empty(&folio->_deferred_list) &&
>>>>>> split_folio_to_list(folio,
>>>>>> folio_list))
>>>>>> goto activate_locked;
>>>>>
>>>>> Not sure if we might have to annotate that with data_race().
>>>>
>>>> I asked that exact question to Matthew in another context bt didn't get a
>>>> response. There are examples of checking if the deferred list is empty with and
>>>> without data_race() in the code base. But list_empty() is implemented like this:
>>>>
>>>> static inline int list_empty(const struct list_head *head)
>>>> {
>>>> return READ_ONCE(head->next) == head;
>>>> }
>>>>
>>>> So I assumed the READ_ONCE() makes everything safe without a lock? Perhaps not
>>>> sufficient for KCSAN?
I don't think READ_ONCE() can replace the lock.
>>>
>>> Yeah, there is only one use of data_race with that list.
>>>
>>> It was added in f3ebdf042df4 ("THP: avoid lock when check whether THP is in
>>> deferred list").
>>>
>>> Looks like that was added right in v1 of that change [1], so my best guess is
>>> that it is not actually required.
>>>
>>> If not required, likely we should just cleanup the single user.
>>>
>>> [1]
>>> https://lore.kernel.org/linux-mm/20230417075643.3287513-2-fengwei.yin@intel.com/
>>
>> Do you have any recollection of why you added the data_race() markup?
>
> Per my understanding, this is used to mark that the code accesses
> folio->_deferred_list without lock intentionally, while
> folio->_deferred_list may be changed in parallel. IIUC, this is what
> data_race() is used for. Or, my understanding is wrong?
Yes. This is my understanding also.
Regards
Yin, Fengwei
>
> --
> Best Regards,
> Huang, Ying
next prev parent reply other threads:[~2024-03-18 10:00 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 15:00 [PATCH v4 0/6] Swap-out mTHP without splitting Ryan Roberts
2024-03-11 15:00 ` [PATCH v4 1/6] mm: swap: Remove CLUSTER_FLAG_HUGE from swap_cluster_info:flags Ryan Roberts
2024-03-11 15:00 ` [PATCH v4 2/6] mm: swap: free_swap_and_cache_nr() as batched free_swap_and_cache() Ryan Roberts
2024-03-20 11:10 ` Ryan Roberts
2024-03-20 14:13 ` David Hildenbrand
2024-03-20 14:21 ` Ryan Roberts
2024-03-11 15:00 ` [PATCH v4 3/6] mm: swap: Simplify struct percpu_cluster Ryan Roberts
2024-03-12 7:52 ` Huang, Ying
2024-03-12 8:51 ` Ryan Roberts
2024-03-13 1:34 ` Huang, Ying
2024-03-11 15:00 ` [PATCH v4 4/6] mm: swap: Allow storage of all mTHP orders Ryan Roberts
2024-03-12 7:51 ` Huang, Ying
2024-03-12 9:40 ` Ryan Roberts
2024-03-13 1:33 ` Huang, Ying
2024-03-20 12:22 ` Ryan Roberts
2024-03-21 4:39 ` Huang, Ying
2024-03-21 12:21 ` Ryan Roberts
2024-03-22 2:38 ` Can you help us on memory barrier usage? (was Re: [PATCH v4 4/6] mm: swap: Allow storage of all mTHP orders) Huang, Ying
2024-03-22 9:23 ` Ryan Roberts
2024-03-25 3:20 ` Huang, Ying
2024-03-22 13:19 ` Chris Li
2024-03-23 2:11 ` Akira Yokosawa
2024-03-25 0:01 ` Paul E. McKenney
2024-03-25 3:16 ` Huang, Ying
2024-03-26 17:08 ` Ryan Roberts
2024-03-25 3:00 ` Huang, Ying
2024-03-22 2:39 ` [PATCH v4 4/6] mm: swap: Allow storage of all mTHP orders Huang, Ying
2024-03-22 9:39 ` Ryan Roberts
2024-03-11 15:00 ` [PATCH v4 5/6] mm: vmscan: Avoid split during shrink_folio_list() Ryan Roberts
2024-03-11 22:30 ` Barry Song
2024-03-12 8:12 ` Ryan Roberts
2024-03-12 8:40 ` Barry Song
2024-03-15 10:43 ` David Hildenbrand
2024-03-15 10:49 ` Ryan Roberts
2024-03-15 11:12 ` David Hildenbrand
2024-03-15 11:38 ` Ryan Roberts
2024-03-18 2:16 ` Huang, Ying
2024-03-18 10:00 ` Yin, Fengwei [this message]
2024-03-18 10:05 ` David Hildenbrand
2024-03-18 15:35 ` Ryan Roberts
2024-03-18 15:36 ` Ryan Roberts
2024-03-19 2:20 ` Yin Fengwei
2024-03-19 14:40 ` Ryan Roberts
2024-03-19 2:31 ` Yin Fengwei
2024-03-11 15:00 ` [PATCH v4 6/6] mm: madvise: Avoid split during MADV_PAGEOUT and MADV_COLD Ryan Roberts
2024-03-13 7:19 ` Barry Song
2024-03-13 9:03 ` Ryan Roberts
2024-03-13 9:16 ` Barry Song
2024-03-13 9:36 ` Ryan Roberts
2024-03-13 10:37 ` Barry Song
2024-03-13 11:08 ` Ryan Roberts
2024-03-13 11:37 ` Barry Song
2024-03-13 12:02 ` Ryan Roberts
2024-03-13 9:19 ` Lance Yang
2024-03-13 14:02 ` Lance Yang
2024-03-20 13:49 ` Ryan Roberts
2024-03-20 14:35 ` Lance Yang
2024-03-20 17:38 ` Ryan Roberts
2024-03-21 1:38 ` Lance Yang
2024-03-21 13:38 ` Ryan Roberts
2024-03-21 14:55 ` Lance Yang
2024-03-21 15:24 ` Ryan Roberts
2024-03-22 0:56 ` Lance Yang
[not found] ` <ffeee7da-e625-40dc-8da8-b70e4e6ef935@redhat.com>
2024-03-15 10:55 ` Ryan Roberts
2024-03-15 11:13 ` David Hildenbrand
2024-03-20 13:57 ` Ryan Roberts
2024-03-20 14:09 ` David Hildenbrand
2024-03-12 8:01 ` [PATCH v4 0/6] Swap-out mTHP without splitting Huang, Ying
2024-03-12 8:49 ` Ryan Roberts
2024-03-12 13:56 ` Ryan Roberts
2024-03-13 1:15 ` Huang, Ying
2024-03-13 8:50 ` Ryan Roberts
2024-03-12 8:45 ` Ryan Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a75ea34a-7512-4169-b987-95f11a7f3dd0@intel.com \
--to=fengwei.yin@intel.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=xiang@kernel.org \
--cc=ying.huang@intel.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox