lkml.org 
[lkml]   [2022]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH net-next v3 18/25] io_uring: account locked pages for non-fixed zc
    Date
    Fixed buffers are RLIMIT_MEMLOCK accounted, however it doesn't cover iovec
    based zerocopy sends. Do the accounting on the io_uring side.

    Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
    ---
    io_uring/net.c | 1 +
    io_uring/notif.c | 6 ++++++
    2 files changed, 7 insertions(+)

    diff --git a/io_uring/net.c b/io_uring/net.c
    index ef492f1360c8..d5b00e07e72b 100644
    --- a/io_uring/net.c
    +++ b/io_uring/net.c
    @@ -834,6 +834,7 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
    ret = import_single_range(WRITE, zc->buf, zc->len, &iov, &msg.msg_iter);
    if (unlikely(ret))
    return ret;
    + mm_account_pinned_pages(&notif->uarg.mmp, zc->len);

    msg_flags = zc->msg_flags | MSG_ZEROCOPY;
    if (issue_flags & IO_URING_F_NONBLOCK)
    diff --git a/io_uring/notif.c b/io_uring/notif.c
    index 2e9329f97d2c..0a03d04c010b 100644
    --- a/io_uring/notif.c
    +++ b/io_uring/notif.c
    @@ -12,7 +12,13 @@ static void __io_notif_complete_tw(struct callback_head *cb)
    {
    struct io_notif *notif = container_of(cb, struct io_notif, task_work);
    struct io_ring_ctx *ctx = notif->ctx;
    + struct mmpin *mmp = &notif->uarg.mmp;

    + if (mmp->user) {
    + atomic_long_sub(mmp->num_pg, &mmp->user->locked_vm);
    + free_uid(mmp->user);
    + mmp->user = NULL;
    + }
    if (likely(notif->task)) {
    io_put_task(notif->task, 1);
    notif->task = NULL;
    --
    2.36.1
    \
     
     \ /
      Last update: 2022-07-05 17:05    [W:3.538 / U:0.160 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site