From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Geliang Tang <geliangtang@163.com>
Cc: Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH] zram: move init_done check to the beginning of disksize_store
Date: Tue, 3 Nov 2015 09:18:35 +0900 [thread overview]
Message-ID: <20151103001835.GA1693@swordfish> (raw)
In-Reply-To: <20151102135349.GA16606@bogon>
Hi,
[please don't trim the Cc list]
On (11/02/15 21:53), Geliang Tang wrote:
> > Those things are not connected, absolutely. zram_meta_alloc() can fail
> > even on un-initialized device. In any case disksize_store() does not end
> > up changing the state of the device and reports the error back, so I don't
> > see any real value in this change. Seems that we come across this change
> > something like once a year (this patch is not the first).
>
> Thanks for your reply.
>
> zram_meta_alloc() always fails on initialized device at debugfs_create_dir():
> debugfs dir <zram0> creation failed
Aha, so you are talking about calling disksize_store() on
- already initialized device that
- uses zsmalloc with
- CONFIG_ZSMALLOC_STAT as an alacator
(zbud is not affected). that should have been mentioned in the commit message.
hm, does the patch _actually_ make it better? splitting a ->init_lock regions
is *never* a good idea. consider an un-initialized device.
CPU0 CPU1
down_read(&zram->init_lock);
if (init_done(zram))
return -EBUSY;
up_read(&zram->init_lock);
down_read(&zram->init_lock);
if (init_done(zram))
return -EBUSY;
up_read(&zram->init_lock);
meta = zram_meta_alloc();
meta = zram_meta_alloc();
comp = zcomp_create();
comp = zcomp_create();
down_write(&zram->init_lock);
zram->meta = meta;
...
up_write(&zram->init_lock);
down_write(&zram->init_lock);
zram->meta = meta;
...
up_write(&zram->init_lock);
So the above code will return a "debugfs dir <zram0> creation failed"
IFF zsmalloc with CONFIG_ZSMALLOC_STAT enabled is being used (regardless the
effort). And it will totally succeed and lead to N (depending on the number of
concurrent disksize_store() calls) pool memory and zcomp_create memory leaks
otherwise. Because of this part:
---
down_write(&zram->init_lock);
- if (init_done(zram)) {
- pr_info("Cannot change disksize for initialized device\n");
- err = -EBUSY;
- goto out_destroy_comp;
- }
-
init_waitqueue_head(&zram->io_done);
atomic_set(&zram->refcount, 1);
zram->meta = meta;
---
> zram: Error creating memory pool
>
> I think we should deal with this error.
Is it so critical? I mean it does not break the existing device; we
print the error and keep the existing device fully functional. The
error line may be a bit misleading, which is another thing and can
be solved documenting the behavior, *for example*. (I just don't
really want to complicate the code for a corner case which doesn't
even break anything).
-ss
prev parent reply other threads:[~2015-11-03 0:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-31 14:50 [PATCH] zram: move init_done check to the beginning of disksize_store Geliang Tang
2015-11-01 23:43 ` Sergey Senozhatsky
2015-11-02 13:53 ` Geliang Tang
2015-11-03 0:18 ` Sergey Senozhatsky [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=20151103001835.GA1693@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=geliangtang@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--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