From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH] zram: keep the exact overcommited value in mem_used_max
Date: Wed, 30 Sep 2015 10:28:03 +0900 [thread overview]
Message-ID: <20150930012803.GB12727@bbox> (raw)
In-Reply-To: <1443088312-12175-1-git-send-email-sergey.senozhatsky@gmail.com>
On Thu, Sep 24, 2015 at 06:51:52PM +0900, Sergey Senozhatsky wrote:
> From: Sergey SENOZHATSKY <sergey.senozhatsky@gmail.com>
>
> `mem_used_max' is designed to store the max amount of memory zram
> consumed to store the data. However, it does not represent the actual
> 'overcommited' (max) value. The existing code goes to -ENOMEM
> overcommited case before it updates `->stats.max_used_pages', which
> hides the reason we went to -ENOMEM in the first place -- we actually
> used more memory than `->limit_pages':
>
> alloced_pages = zs_get_total_pages(meta->mem_pool);
> if (zram->limit_pages && alloced_pages > zram->limit_pages) {
> zs_free(meta->mem_pool, handle);
> ret = -ENOMEM;
> goto out;
> }
>
> update_used_max(zram, alloced_pages);
>
> Which is misleading. User will see -ENOMEM, check `->limit_pages',
> check `->stats.max_used_pages', which will keep the value BEFORE zram
> passed `->limit_pages', and see:
> `->stats.max_used_pages' < `->limit_pages'
>
> Move update_used_max() before we do `->limit_pages' check, so that
> user will see:
> `->stats.max_used_pages' > `->limit_pages'
> should the overcommit and -ENOMEM happen.
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
It was intent.
IOW, I want that max_mem_used is never higher than mem_limit but
I realized you are right because user doesn't have way to detect
where -ENOMEM is coming from.
For example, it could come from mem_limit or real memory alloc fail.
Thanks, Sergey.
Acked-by: Minchan Kim <minchan@kernel.org>
prev parent reply other threads:[~2015-09-30 1:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 9:51 Sergey Senozhatsky
2015-09-30 1:28 ` Minchan Kim [this message]
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=20150930012803.GB12727@bbox \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
/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
all inboxes | Powered by JetHome®