public inbox for [email protected]
 help / color / mirror / Atom feed
From: Stefano Garzarella <[email protected]>
To: Jens Axboe <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 2/2] io_uring: account locked memory before potential error case
Date: Thu, 6 Aug 2020 09:42:31 +0200	[thread overview]
Message-ID: <20200806074231.mlmfbsl4shvvzodm@steredhat> (raw)
In-Reply-To: <[email protected]>

On Wed, Aug 05, 2020 at 01:02:24PM -0600, Jens Axboe wrote:
> The tear down path will always unaccount the memory, so ensure that we
> have accounted it before hitting any of them.
> 
> Signed-off-by: Jens Axboe <[email protected]>
> ---
>  fs/io_uring.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 0d857f7ca507..7c42f63fbb0a 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -8341,6 +8341,14 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
>  	ctx->user = user;
>  	ctx->creds = get_current_cred();
>  
> +	/*
> +	 * Account memory _before_ installing the file descriptor. Once
> +	 * the descriptor is installed, it can get closed at any time.
> +	 */

What about update a bit the comment?
Maybe adding the commit description in this comment.

> +	io_account_mem(ctx, ring_pages(p->sq_entries, p->cq_entries),
> +		       ACCT_LOCKED);
> +	ctx->limit_mem = limit_mem;
> +
>  	ret = io_allocate_scq_urings(ctx, p);
>  	if (ret)
>  		goto err;
> @@ -8377,14 +8385,6 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
>  		goto err;
>  	}
>  
> -	/*
> -	 * Account memory _before_ installing the file descriptor. Once
> -	 * the descriptor is installed, it can get closed at any time.
> -	 */
> -	io_account_mem(ctx, ring_pages(p->sq_entries, p->cq_entries),
> -		       ACCT_LOCKED);
> -	ctx->limit_mem = limit_mem;
> -
>  	/*
>  	 * Install ring fd as the very last thing, so we don't risk someone
>  	 * having closed it before we finish setup
> -- 
> 2.28.0
> 

Thanks,
Stefano


  reply	other threads:[~2020-08-06 11:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 19:02 [PATCH 0/2] io_uring memory accounting fixes Jens Axboe
2020-08-05 19:02 ` [PATCH 1/2] io_uring: set ctx sq/cq entry count earlier Jens Axboe
2020-08-06  7:39   ` Stefano Garzarella
2020-08-06 13:20     ` Jens Axboe
2020-08-05 19:02 ` [PATCH 2/2] io_uring: account locked memory before potential error case Jens Axboe
2020-08-06  7:42   ` Stefano Garzarella [this message]
2020-08-06 13:21     ` Jens Axboe
2020-08-06 13:38       ` Stefano Garzarella
2020-08-06 13:46         ` 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=20200806074231.mlmfbsl4shvvzodm@steredhat \
    [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