From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonsoo Kim <js1304@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>,
linux-kernel@vger.kernel.org,
Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH] zram: fix possible race when checking idle_strm
Date: Fri, 7 Aug 2015 19:16:10 +0900 [thread overview]
Message-ID: <20150807101610.GA26678@swordfish> (raw)
In-Reply-To: <20150807093720.GN1891@swordfish>
On (08/07/15 18:37), Sergey Senozhatsky wrote:
[..]
> > Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>
> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Andrew, my apologies, can we hold on a bit with my Acked-by. I
need more time to think about the issue -- do we actually have
one or we don't.
It seems that to be on a safe side this check is better be done
under the lock, but at the same time I sort of fail to convenience
myself that doing this check outside the lock introduces any danger.
Need some rest. May be Joonsoo and Minchan can add some bits
(that I currently miss) or thoughts.
-ss
> > ---
> > drivers/block/zram/zcomp.c | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
> > index 80a62e7..837e9c3 100644
> > --- a/drivers/block/zram/zcomp.c
> > +++ b/drivers/block/zram/zcomp.c
> > @@ -76,6 +76,17 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
> > return zstrm;
> > }
> >
> > +static bool avail_idle_strm(struct zcomp_strm_multi *zs)
> > +{
> > + int avail;
> > +
> > + spin_lock(&zs->strm_lock);
> > + avail = !list_empty(&zs->idle_strm);
> > + spin_unlock(&zs->strm_lock);
> > +
> > + return avail;
> > +}
> > +
> > /*
> > * get idle zcomp_strm or wait until other process release
> > * (zcomp_strm_release()) one for us
> > @@ -97,7 +108,7 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp)
> > /* zstrm streams limit reached, wait for idle stream */
> > if (zs->avail_strm >= zs->max_strm) {
> > spin_unlock(&zs->strm_lock);
> > - wait_event(zs->strm_wait, !list_empty(&zs->idle_strm));
> > + wait_event(zs->strm_wait, avail_idle_strm(zs));
> > continue;
> > }
> > /* allocate new zstrm stream */
> > @@ -109,7 +120,7 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp)
> > spin_lock(&zs->strm_lock);
> > zs->avail_strm--;
> > spin_unlock(&zs->strm_lock);
> > - wait_event(zs->strm_wait, !list_empty(&zs->idle_strm));
> > + wait_event(zs->strm_wait, avail_idle_strm(zs));
> > continue;
> > }
> > break;
> > --
>
next prev parent reply other threads:[~2015-08-07 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-07 8:03 [PATCH] zram: fix possible race when checking idle_strm Joonsoo Kim
2015-08-07 9:14 ` Sergey Senozhatsky
2015-08-07 9:19 ` Sergey Senozhatsky
2015-08-07 9:38 ` Sergey Senozhatsky
2015-08-07 9:58 ` Sergey Senozhatsky
2015-08-10 0:32 ` Joonsoo Kim
2015-08-10 2:16 ` Sergey Senozhatsky
2015-08-11 8:26 ` Joonsoo Kim
2015-08-10 23:26 ` Minchan Kim
2015-08-11 8:25 ` Joonsoo Kim
2015-08-11 8:25 ` Sergey Senozhatsky
2015-08-07 9:37 ` Sergey Senozhatsky
2015-08-07 10:16 ` Sergey Senozhatsky [this message]
2015-08-07 14:49 ` Minchan Kim
2015-08-10 0:35 ` Joonsoo Kim
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=20150807101610.GA26678@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=js1304@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
/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