mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: zhiguojiang <justinjiang@vivo.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 Will Deacon <will@kernel.org>,
	"Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	 Nick Piggin <npiggin@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnd Bergmann <arnd@arndb.de>,
	 Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 Muchun Song <muchun.song@linux.dev>,
	linux-arch@vger.kernel.org, cgroups@vger.kernel.org,
	 kernel test robot <lkp@intel.com>,
	opensource.kernel@vivo.com
Subject: Re: [PATCH v2 0/3] mm: tlb swap entries batch async release
Date: Wed, 7 Aug 2024 04:32:09 +0800	[thread overview]
Message-ID: <CAGsJ_4x1tLEmRFbnUYcNYtV73SyBYpBtAx_syjfcnjrom-R+4w@mail.gmail.com> (raw)
In-Reply-To: <20240806133823.5cb3f27ef30c42dad5d0c3e8@linux-foundation.org>

On Wed, Aug 7, 2024 at 4:38 AM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Thu, 1 Aug 2024 14:30:52 +0800 zhiguojiang <justinjiang@vivo.com> wrote:
>
> > > Dumb question: why can't this be done in userspace?  The exiting
> > > process does fork/exit and lets the child do all this asynchronous freeing?
> > The logic optimization for kernel releasing swap entries cannot be
> > implemented in userspace. The multiple exiting processes here own
> > their independent mm, rather than parent and child processes share the
> > same mm. Therefore, when the kernel executes multiple exiting process
> > simultaneously, they will definitely occupy multiple CPU core resources
> > to complete it.
>
> What I'm asking is why not change those userspace processes so that they
> fork off a child process which shares the MM (shared mm_struct) and
> then the original process exits, leaving the asynchronously-running
> child to clean up the MM resources.

Not Zhiguo. From my perspective as a phone engineer, this issue isn't related
to the parent-child process or the wait() function. Phones rely heavily on
mechanisms similar to the OOM killer to function efficiently. For instance,
if you're using apps like YouTube, TikTok, and Facebook, and then you
open the camera app to take a photo, the camera app becomes the foreground
process and demands a lot of memory. In this scenario, the phone might
decide to terminate the most memory-consuming and less important apps,
such as TikTok or YouTube, to free up memory for the camera app. TikTok
and YouTube become less important because they are no longer occupying
the phone's screen and have moved to the background. The faster TikTok
and YouTube can be unmapped, the quicker the camera app can launch,
enhancing the user experience.

An important reason why apps can launch very slowly is due to the time latency
of alloc_pages(). That's why I'm quite interested in Zhiguo's patchset. On the
other hand, mTHP can help alleviate the situation by releasing swap slots three
times faster in my other patch:
https://lore.kernel.org/linux-mm/20240806012409.61962-1-21cnbao@gmail.com/

This is likely another advantage of mTHP.

Thanks
Barry

  reply	other threads:[~2024-08-06 21:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 13:33 Zhiguo Jiang
2024-07-31 13:33 ` [PATCH v2 1/3] mm: move task_is_dying to h headfile Zhiguo Jiang
2024-07-31 13:33 ` [PATCH v2 2/3] mm: tlb: add tlb swap entries batch async release Zhiguo Jiang
2024-07-31 13:33 ` [PATCH v2 3/3] mm: s390: fix compilation warning Zhiguo Jiang
2024-08-05 12:04   ` David Hildenbrand
2024-08-05 12:10     ` zhiguojiang
2024-07-31 16:17 ` [PATCH v2 0/3] mm: tlb swap entries batch async release Andrew Morton
2024-08-01  6:30   ` zhiguojiang
2024-08-01  7:36     ` Barry Song
2024-08-01 10:33       ` zhiguojiang
2024-08-02 10:42         ` Barry Song
2024-08-02 14:42           ` zhiguojiang
2024-08-06 20:38     ` Andrew Morton
2024-08-06 20:32       ` Barry Song [this message]
2024-08-06 22:39         ` Andrew Morton
2024-08-06 22:21           ` 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=CAGsJ_4x1tLEmRFbnUYcNYtV73SyBYpBtAx_syjfcnjrom-R+4w@mail.gmail.com \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@kernel.org \
    --cc=arnd@arndb.de \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=justinjiang@vivo.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=npiggin@gmail.com \
    --cc=opensource.kernel@vivo.com \
    --cc=peterz@infradead.org \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®