[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.22.394.2006241255180.35388@chino.kir.corp.google.com>
Date: Wed, 24 Jun 2020 13:00:19 -0700 (PDT)
From: David Rientjes <rientjes@...gle.com>
To: Minchan Kim <minchan@...nel.org>
cc: Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Christian Brauner <christian.brauner@...ntu.com>,
linux-mm <linux-mm@...ck.org>, linux-api@...r.kernel.org,
oleksandr@...hat.com, Suren Baghdasaryan <surenb@...gle.com>,
Tim Murray <timmurray@...gle.com>,
Sandeep Patil <sspatil@...gle.com>,
Sonny Rao <sonnyrao@...gle.com>,
Brian Geffon <bgeffon@...gle.com>,
Michal Hocko <mhocko@...e.com>,
Johannes Weiner <hannes@...xchg.org>,
Shakeel Butt <shakeelb@...gle.com>,
John Dias <joaodias@...gle.com>,
Joel Fernandes <joel@...lfernandes.org>,
Jann Horn <jannh@...gle.com>,
alexander.h.duyck@...ux.intel.com, sj38.park@...il.com,
Arjun Roy <arjunroy@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>, Jens Axboe <axboe@...nel.dk>,
Daniel Colascione <dancol@...gle.com>,
Christian Brauner <christian@...uner.io>,
Kirill Tkhai <ktkhai@...tuozzo.com>,
SeongJae Park <sjpark@...zon.de>, linux-man@...r.kernel.org
Subject: Re: [PATCH v8 1/4] mm/madvise: pass task and mm to do_madvise
On Mon, 22 Jun 2020, Minchan Kim wrote:
> Patch series "introduce memory hinting API for external process", v8.
>
> Now, we have MADV_PAGEOUT and MADV_COLD as madvise hinting API. With
> that, application could give hints to kernel what memory range are
> preferred to be reclaimed. However, in some platform(e.g., Android), the
> information required to make the hinting decision is not known to the app.
> Instead, it is known to a centralized userspace daemon(e.g.,
> ActivityManagerService), and that daemon must be able to initiate reclaim
> on its own without any app involvement.
>
> To solve the concern, this patch introduces new syscall -
> process_madvise(2). Bascially, it's same with madvise(2) syscall but it
> has some differences.
>
> 1. It needs pidfd of target process to provide the hint
>
> 2. It supports only MADV_{COLD|PAGEOUT|MERGEABLE|UNMEREABLE} at this
> moment. Other hints in madvise will be opened when there are explicit
> requests from community to prevent unexpected bugs we couldn't support.
>
> 3. Only privileged processes can do something for other process's
> address space.
>
> For more detail of the new API, please see "mm: introduce external memory
> hinting API" description in this patchset.
>
> This patch (of 4):
>
> In upcoming patches, do_madvise will be called from external process
> context so we shouldn't asssume "current" is always hinted process's
> task_struct.
>
> Furthermore, we must not access mm_struct via task->mm, but obtain it
> via access_mm() once (in the following patch) and only use that pointer
> [1], so pass it to do_madvise() as well. Note the vma->vm_mm pointers
> are safe, so we can use them further down the call stack.
>
> And let's pass *current* and current->mm as arguments of do_madvise so
> it shouldn't change existing behavior but prepare next patch to make
> review easy.
>
> Note: io_madvise passes NULL as target_task argument of do_madvise because
> it couldn't know who is target.
>
> [1] http://lore.kernel.org/r/CAG48ez27=pwm5m_N_988xT1huO7g7h6arTQL44zev6TD-h-7Tg@mail.gmail.com
>
> [vbabka@...e.cz: changelog tweak]
> [minchan@...nel.org: use current->mm for io_uring]
> Link: http://lkml.kernel.org/r/20200423145215.72666-1-minchan@kernel.org
> [akpm@...ux-foundation.org: fix it for upstream changes]
> [akpm@...ux-foundation.org: whoops]
> [rdunlap@...radead.org: add missing includes]
> Link: http://lkml.kernel.org/r/20200302193630.68771-2-minchan@kernel.org
> Signed-off-by: Minchan Kim <minchan@...nel.org>
> Reviewed-by: Suren Baghdasaryan <surenb@...gle.com>
> Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
> Cc: Jens Axboe <axboe@...nel.dk>
> Cc: Jann Horn <jannh@...gle.com>
> Cc: Tim Murray <timmurray@...gle.com>
> Cc: Daniel Colascione <dancol@...gle.com>
> Cc: Sandeep Patil <sspatil@...gle.com>
> Cc: Sonny Rao <sonnyrao@...gle.com>
> Cc: Brian Geffon <bgeffon@...gle.com>
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: Johannes Weiner <hannes@...xchg.org>
> Cc: Shakeel Butt <shakeelb@...gle.com>
> Cc: John Dias <joaodias@...gle.com>
> Cc: Joel Fernandes <joel@...lfernandes.org>
> Cc: Alexander Duyck <alexander.h.duyck@...ux.intel.com>
> Cc: SeongJae Park <sj38.park@...il.com>
> Cc: Christian Brauner <christian@...uner.io>
> Cc: Kirill Tkhai <ktkhai@...tuozzo.com>
> Cc: Oleksandr Natalenko <oleksandr@...hat.com>
> Cc: SeongJae Park <sjpark@...zon.de>
> Cc: Christian Brauner <christian.brauner@...ntu.com>
> Cc: <linux-man@...r.kernel.org>
Acked-by: David Rientjes <rientjes@...gle.com>
Powered by blists - more mailing lists