From: Alistair Popple <apopple-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Jason Gunthorpe <jgg-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>,
Yosry Ahmed <yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
jhubbard-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
tjmercier-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
surenb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
mkoutny-IBi9RG/b67k@public.gmane.org,
daniel-/w4YWyX8dFk@public.gmane.org,
"Daniel P . Berrange"
<berrange-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Alex Williamson
<alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Zefan Li <lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH 14/19] mm: Introduce a cgroup for pinned memory
Date: Thu, 23 Feb 2023 09:59:35 +1100 [thread overview]
Message-ID: <87k009nvnr.fsf@nvidia.com> (raw)
In-Reply-To: <Y/YRJNwwvqp7nKKt-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Jason Gunthorpe <jgg-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> writes:
> On Wed, Feb 22, 2023 at 10:38:25PM +1100, Alistair Popple wrote:
>> When a driver unpins a page we scan the pinners list and assign
>> ownership to the next driver pinning the page by updating memcg_data and
>> removing the vm_account from the list.
>
> I don't see how this works with just the data structure you outlined??
> Every unique page needs its own list_head in the vm_account, it is
> doable just incredibly costly.
The idea was every driver already needs to allocate a pages array to
pass to pin_user_pages(), and by necessity drivers have to keep a
reference to the contents of that in one form or another. So
conceptually the equivalent of:
struct vm_account {
struct list_head possible_pinners;
struct mem_cgroup *memcg;
struct pages **pages;
[...]
};
Unpinnig involves finding a new owner by traversing the list of
page->memcg_data->possible_pinners and iterating over *pages[] to figure
out if that vm_account actually has this page pinned or not and could
own it.
Agree this is costly though. And I don't think all drivers keep the
array around so "iterating over *pages[]" may need to be a callback.
> Jason
next prev parent reply other threads:[~2023-02-22 22:59 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 7:47 [PATCH 00/19] mm: Introduce a cgroup to limit the amount of locked and pinned memory Alistair Popple
[not found] ` <cover.c238416f0e82377b449846dbb2459ae9d7030c8e.1675669136.git-series.apopple-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-06 7:47 ` [PATCH 01/19] mm: Introduce vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 02/19] drivers/vhost: Convert to use vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 03/19] drivers/vdpa: Convert vdpa to use the new vm_structure Alistair Popple
2023-02-06 7:47 ` [PATCH 04/19] infiniband/umem: Convert to use vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 05/19] RMDA/siw: " Alistair Popple
2023-02-12 17:32 ` Bernard Metzler
2023-02-06 7:47 ` [PATCH 06/19] RDMA/usnic: convert " Alistair Popple
2023-02-06 7:47 ` [PATCH 07/19] vfio/type1: Charge pinned pages to pinned_vm instead of locked_vm Alistair Popple
2023-02-06 7:47 ` [PATCH 13/19] fpga: dfl: afu: convert to use vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 14/19] mm: Introduce a cgroup for pinned memory Alistair Popple
[not found] ` <c7b5e502d1a3b9b8f6e96cbf9ca553b143c327e0.1675669136.git-series.apopple-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-06 21:01 ` Yosry Ahmed
2023-02-06 21:14 ` Tejun Heo
[not found] ` <Y+Fttp1ozejoSQzl-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-06 22:32 ` Yosry Ahmed
2023-02-06 22:36 ` Tejun Heo
[not found] ` <Y+GA6Y7SVhAW5Xm9-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-06 22:39 ` Yosry Ahmed
[not found] ` <CAJD7tka6SC1ho-dffV0bK_acoZd-5DQzBOy0xg3TkOFG1zAPMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-02-06 23:25 ` Tejun Heo
[not found] ` <Y+GMbWWP/YhtJQqe-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-06 23:34 ` Yosry Ahmed
2023-02-06 23:40 ` Jason Gunthorpe
[not found] ` <Y+GQB9I6MFN6BOFw-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-07 0:32 ` Tejun Heo
[not found] ` <Y+GcJQRhvjqFaaSp-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2023-02-07 12:19 ` Jason Gunthorpe
2023-02-15 19:00 ` Michal Hocko
[not found] ` <Y+0rxoM4w9nilUMZ-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-02-15 19:07 ` Jason Gunthorpe
[not found] ` <Y+0tWZxMUx/NZ3Ne-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-16 8:04 ` Michal Hocko
[not found] ` <Y+3jcw9vo4ml5p0M-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2023-02-16 12:45 ` Jason Gunthorpe
[not found] ` <Y+4lcq4Fge27TQIn-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-21 16:51 ` Tejun Heo
2023-02-21 17:25 ` Jason Gunthorpe
[not found] ` <Y/T+pw25oGmKqz1k-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-21 17:29 ` Tejun Heo
[not found] ` <Y/T/bkcYc9Krw4rE-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-21 17:51 ` Jason Gunthorpe
[not found] ` <Y/UEkNn0O65Pfi4e-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-21 18:07 ` Tejun Heo
[not found] ` <Y/UIURDjR9pv+gzx-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-21 19:26 ` Jason Gunthorpe
[not found] ` <Y/Ua6VcNe/DFh7X4-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-21 19:45 ` Tejun Heo
2023-02-21 19:49 ` Tejun Heo
2023-02-21 19:57 ` Jason Gunthorpe
[not found] ` <Y/UiQmuVwh2eqrfA-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-22 11:38 ` Alistair Popple
[not found] ` <87o7pmnd0p.fsf-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-22 12:57 ` Jason Gunthorpe
[not found] ` <Y/YRJNwwvqp7nKKt-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-22 22:59 ` Alistair Popple [this message]
2023-02-23 0:05 ` Christoph Hellwig
[not found] ` <Y/at3iYz/xBSPPM+-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2023-02-23 0:35 ` Alistair Popple
[not found] ` <87k009nvnr.fsf-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-23 1:53 ` Jason Gunthorpe
2023-02-23 9:12 ` Daniel P. Berrangé
[not found] ` <Y/ct88JBeQuSmCuj-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-02-23 17:31 ` Jason Gunthorpe
2023-02-23 17:18 ` T.J. Mercier
[not found] ` <CABdmKX18MY19bnsxN5W38Z9zmoaZx+S4+zzN_5XCYDBruwPrLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-02-23 17:28 ` Jason Gunthorpe
2023-02-23 18:03 ` Yosry Ahmed
[not found] ` <CAJD7tkadBRP22qP63-SjKSch1im9sHLoMzc6c2h10+ggbuxqMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-02-23 18:10 ` Jason Gunthorpe
[not found] ` <Y/esMBOyTaJnv5CW-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-23 18:14 ` Yosry Ahmed
2023-02-23 18:15 ` Tejun Heo
[not found] ` <Y/etNfwxHv8XO3iC-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2023-02-23 18:17 ` Jason Gunthorpe
[not found] ` <Y/etrtvyaiwRIo6f-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-23 18:22 ` Tejun Heo
2023-02-07 1:00 ` Waiman Long
2023-02-07 1:03 ` Tejun Heo
[not found] ` <Y+GjSTu9vE/A/EKG-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2023-02-07 1:50 ` Alistair Popple
2023-02-06 7:47 ` [PATCH 15/19] mm/util: Extend vm_account to charge pages against the pin cgroup Alistair Popple
2023-02-06 7:47 ` [PATCH 16/19] mm/util: Refactor account_locked_vm Alistair Popple
2023-02-06 7:47 ` [PATCH 17/19] mm: Convert mmap and mlock to use account_locked_vm Alistair Popple
2023-02-06 7:47 ` [PATCH 18/19] mm/mmap: Charge locked memory to pins cgroup Alistair Popple
2023-02-06 21:12 ` Yosry Ahmed
2023-02-06 7:47 ` [PATCH 19/19] selftests/vm: Add pins-cgroup selftest for mlock/mmap Alistair Popple
2023-02-16 11:01 ` [PATCH 00/19] mm: Introduce a cgroup to limit the amount of locked and pinned memory David Hildenbrand
2023-02-06 7:47 ` [PATCH 08/19] vfio/spapr_tce: Convert accounting to pinned_vm Alistair Popple
2023-02-06 7:47 ` [PATCH 09/19] io_uring: convert to use vm_account Alistair Popple
[not found] ` <44e6ead48bc53789191b22b0e140aeb82459e75f.1675669136.git-series.apopple-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-06 15:29 ` Jens Axboe
[not found] ` <52d41a7e-1407-e74f-9206-6dd583b7b6b5-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2023-02-07 1:03 ` Alistair Popple
2023-02-07 14:28 ` Jens Axboe
[not found] ` <eff3cc48-7279-2fbf-fdbd-f35eff2124d0-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2023-02-07 14:55 ` Jason Gunthorpe
[not found] ` <Y+JmdMJhPEGN0Zw+-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2023-02-07 17:05 ` Jens Axboe
[not found] ` <53816439-6473-1c4f-2134-02cd1c46cfe8-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2023-02-13 11:30 ` Alistair Popple
2023-02-06 7:47 ` [PATCH 10/19] net: skb: Switch to using vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 11/19] xdp: convert to use vm_account Alistair Popple
2023-02-06 7:47 ` [PATCH 12/19] kvm/book3s_64_vio: Convert account_locked_vm() to vm_account_pinned() Alistair Popple
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=87k009nvnr.fsf@nvidia.com \
--to=apopple-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=berrange-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=daniel-/w4YWyX8dFk@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=jgg-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=jhubbard-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=mhocko-IBi9RG/b67k@public.gmane.org \
--cc=mkoutny-IBi9RG/b67k@public.gmane.org \
--cc=surenb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tjmercier-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=yosryahmed-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).