public inbox for [email protected]
 help / color / mirror / Atom feed
From: Bijan Mottahedeh <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [RFC 2/2] io_uring: report pinned memory usage
Date: Thu, 11 Jun 2020 19:23:37 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Long term, it makes sense to separate reporting and enforcing of pinned
memory usage.

Signed-off-by: Bijan Mottahedeh <[email protected]>

It is useful to view
---
 fs/io_uring.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4248726..cf3acaa 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -7080,6 +7080,8 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
 static void io_unaccount_mem(struct user_struct *user, unsigned long nr_pages)
 {
 	atomic_long_sub(nr_pages, &user->locked_vm);
+	if (current->mm)
+		atomic_long_sub(nr_pages, &current->mm->pinned_vm);
 }
 
 static int io_account_mem(struct user_struct *user, unsigned long nr_pages)
@@ -7096,6 +7098,8 @@ static int io_account_mem(struct user_struct *user, unsigned long nr_pages)
 			return -ENOMEM;
 	} while (atomic_long_cmpxchg(&user->locked_vm, cur_pages,
 					new_pages) != cur_pages);
+	if (current->mm)
+		atomic_long_add(nr_pages, &current->mm->pinned_vm);
 
 	return 0;
 }
-- 
1.8.3.1


  parent reply	other threads:[~2020-06-12  2:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  2:23 [RFC 0/2] io_uring: disallow overlapping ranges for buffer registration Bijan Mottahedeh
2020-06-12  2:23 ` [RFC 1/2] " Bijan Mottahedeh
2020-06-12 15:16   ` Jens Axboe
2020-06-12 18:22     ` Bijan Mottahedeh
2020-06-14 15:56       ` Jens Axboe
2020-06-12  2:23 ` Bijan Mottahedeh [this message]
2020-06-12 15:16   ` [RFC 2/2] io_uring: report pinned memory usage Jens Axboe
2020-06-12 15:19     ` Jens Axboe
2020-06-12 15:50       ` Jens Axboe
2020-06-13  4:43       ` Bijan Mottahedeh
2020-06-14 15:57         ` Jens Axboe

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=1591928617-19924-3-git-send-email-bijan.mottahedeh@oracle.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /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