From: "Huang, Ying" <ying.huang@intel.com>
To: Barry Song <21cnbao@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Barry Song <v-songbaohua@oppo.com>,
Kairui Song <kasong@tencent.com>, Yu Zhao <yuzhao@google.com>,
David Hildenbrand <david@redhat.com>,
Chris Li <chrisl@kernel.org>, Hugh Dickins <hughd@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@suse.com>, Minchan Kim <minchan@kernel.org>,
Yosry Ahmed <yosryahmed@google.com>,
SeongJae Park <sj@kernel.org>,
Kalesh Singh <kaleshsingh@google.com>,
Suren Baghdasaryan <surenb@google.com>,
stable@vger.kernel.org, Oven Liyang <liyangouwen1@oppo.com>
Subject: Re: [PATCH] mm: avoid unconditional one-tick sleep when swapcache_prepare fails
Date: Tue, 01 Oct 2024 07:40:09 +0800 [thread overview]
Message-ID: <877caspv6u.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <CAGsJ_4w2PjN+4DKWM6qvaEUAX=FQW0rp+6Wjx1Qrq=jaAz7wsw@mail.gmail.com> (Barry Song's message of "Tue, 1 Oct 2024 02:18:13 +1300")
Barry Song <21cnbao@gmail.com> writes:
> On Sun, Sep 29, 2024 at 3:43 PM Huang, Ying <ying.huang@intel.com> wrote:
>>
>> Hi, Barry,
>>
>> Barry Song <21cnbao@gmail.com> writes:
>>
>> > From: Barry Song <v-songbaohua@oppo.com>
>> >
>> > Commit 13ddaf26be32 ("mm/swap: fix race when skipping swapcache")
>> > introduced an unconditional one-tick sleep when `swapcache_prepare()`
>> > fails, which has led to reports of UI stuttering on latency-sensitive
>> > Android devices. To address this, we can use a waitqueue to wake up
>> > tasks that fail `swapcache_prepare()` sooner, instead of always
>> > sleeping for a full tick. While tasks may occasionally be woken by an
>> > unrelated `do_swap_page()`, this method is preferable to two scenarios:
>> > rapid re-entry into page faults, which can cause livelocks, and
>> > multiple millisecond sleeps, which visibly degrade user experience.
>>
>> In general, I think that this works. Why not extend the solution to
>> cover schedule_timeout_uninterruptible() in __read_swap_cache_async()
>> too? We can call wake_up() when we clear SWAP_HAS_CACHE. To avoid
>
> Hi Ying,
> Thanks for your comments.
> I feel extending the solution to __read_swap_cache_async() should be done
> in a separate patch. On phones, I've never encountered any issues reported
> on that path, so it might be better suited for an optimization rather than a
> hotfix?
Yes. It's fine to do that in another patch as optimization.
>> overhead to call wake_up() when there's no task waiting, we can use an
>> atomic to count waiting tasks.
>
> I'm not sure it's worth adding the complexity, as wake_up() on an empty
> waitqueue should have a very low cost on its own?
wake_up() needs to call spin_lock_irqsave() unconditionally on a global
shared lock. On systems with many CPUs (such servers), this may cause
severe lock contention. Even the cache ping-pong may hurt performance
much.
--
Best Regards,
Huang, Ying
next prev parent reply other threads:[~2024-09-30 23:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 21:19 Barry Song
2024-09-29 2:39 ` Huang, Ying
2024-09-30 13:18 ` Barry Song
2024-09-30 23:40 ` Huang, Ying [this message]
2024-10-01 14:16 ` Barry Song
2024-10-02 0:40 ` Huang, Ying
2024-10-02 1:57 ` Barry Song
2024-10-02 18:30 ` Kairui Song
2024-10-03 0:38 ` Huang, Ying
2024-10-03 0:31 ` Huang, Ying
2024-10-03 23:03 ` Chris Li
2024-10-04 16:03 ` Barry Song
2024-10-08 13:08 ` Barry Song
2024-10-09 0:51 ` Huang, Ying
2024-10-22 9:21 ` Kairui Song
2024-10-23 1:57 ` Huang, Ying
2024-10-23 2:32 ` Barry Song
2024-10-03 22:53 ` Chris Li
2024-10-04 15:35 ` Barry Song
2024-10-03 22:22 ` Chris Li
2024-10-04 15:55 ` Barry Song
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=877caspv6u.fsf@yhuang6-desk2.ccr.corp.intel.com \
--to=ying.huang@intel.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kaleshsingh@google.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liyangouwen1@oppo.com \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=sj@kernel.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=v-songbaohua@oppo.com \
--cc=willy@infradead.org \
--cc=yosryahmed@google.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