From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH 3/3] zsmalloc: do not take class lock in zs_pages_to_compact()
Date: Thu, 16 Jul 2015 08:38:34 +0900 [thread overview]
Message-ID: <20150715233834.GA988@bgram> (raw)
In-Reply-To: <20150715040703.GA545@swordfish>
Hi Sergey,
On Wed, Jul 15, 2015 at 01:07:03PM +0900, Sergey Senozhatsky wrote:
> On (07/11/15 18:45), Sergey Senozhatsky wrote:
> [..]
> > We re-do this calculations during compaction on a per class basis
> > anyway.
> >
> > zs_unregister_shrinker() will not return until we have an active
> > shrinker, so classes won't unexpectedly disappear while
> > zs_pages_to_compact(), invoked by zs_shrinker_count(), iterates
> > them.
> >
> > When called from zram, we are protected by zram's ->init_lock,
> > so, again, classes will be there until zs_pages_to_compact()
> > iterates them.
> >
> > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > ---
> > mm/zsmalloc.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index b10a228..824c182 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -1811,9 +1811,7 @@ unsigned long zs_pages_to_compact(struct zs_pool *pool)
> > if (class->index != i)
> > continue;
> >
> > - spin_lock(&class->lock);
> > pages_to_free += zs_can_compact(class);
> > - spin_unlock(&class->lock);
> > }
> >
> > return pages_to_free;
>
> This patch still makes sense. Agree?
There is already race window between shrink_count and shrink_slab so
it would be okay if we return stale stat with removing the lock if
the difference is not huge.
Even, now we don't obey nr_to_scan of shrinker in zs_shrinker_scan
so the such accuracy would be pointless.
Please resend the patch and correct zs_can_compact's comment.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH 3/3] zsmalloc: do not take class lock in zs_pages_to_compact()
Date: Thu, 16 Jul 2015 08:38:34 +0900 [thread overview]
Message-ID: <20150715233834.GA988@bgram> (raw)
In-Reply-To: <20150715040703.GA545@swordfish>
Hi Sergey,
On Wed, Jul 15, 2015 at 01:07:03PM +0900, Sergey Senozhatsky wrote:
> On (07/11/15 18:45), Sergey Senozhatsky wrote:
> [..]
> > We re-do this calculations during compaction on a per class basis
> > anyway.
> >
> > zs_unregister_shrinker() will not return until we have an active
> > shrinker, so classes won't unexpectedly disappear while
> > zs_pages_to_compact(), invoked by zs_shrinker_count(), iterates
> > them.
> >
> > When called from zram, we are protected by zram's ->init_lock,
> > so, again, classes will be there until zs_pages_to_compact()
> > iterates them.
> >
> > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > ---
> > mm/zsmalloc.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index b10a228..824c182 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -1811,9 +1811,7 @@ unsigned long zs_pages_to_compact(struct zs_pool *pool)
> > if (class->index != i)
> > continue;
> >
> > - spin_lock(&class->lock);
> > pages_to_free += zs_can_compact(class);
> > - spin_unlock(&class->lock);
> > }
> >
> > return pages_to_free;
>
> This patch still makes sense. Agree?
There is already race window between shrink_count and shrink_slab so
it would be okay if we return stale stat with removing the lock if
the difference is not huge.
Even, now we don't obey nr_to_scan of shrinker in zs_shrinker_scan
so the such accuracy would be pointless.
Please resend the patch and correct zs_can_compact's comment.
Thanks.
next prev parent reply other threads:[~2015-07-15 23:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-11 9:45 [PATCH 0/3] zsmalloc: small compaction improvements Sergey Senozhatsky
2015-07-11 9:45 ` Sergey Senozhatsky
2015-07-11 9:45 ` [PATCH 1/3] zsmalloc: factor out zs_pages_to_compact() Sergey Senozhatsky
2015-07-11 9:45 ` Sergey Senozhatsky
2015-07-11 9:45 ` [PATCH 2/3] zram: make compact a read-write sysfs node Sergey Senozhatsky
2015-07-11 9:45 ` Sergey Senozhatsky
2015-07-11 9:45 ` [PATCH 3/3] zsmalloc: do not take class lock in zs_pages_to_compact() Sergey Senozhatsky
2015-07-11 9:45 ` Sergey Senozhatsky
2015-07-15 4:07 ` Sergey Senozhatsky
2015-07-15 4:07 ` Sergey Senozhatsky
2015-07-15 23:38 ` Minchan Kim [this message]
2015-07-15 23:38 ` Minchan Kim
2015-07-15 23:59 ` Sergey Senozhatsky
2015-07-15 23:59 ` Sergey Senozhatsky
2015-07-13 23:36 ` [PATCH 0/3] zsmalloc: small compaction improvements Minchan Kim
2015-07-13 23:36 ` Minchan Kim
2015-07-14 0:31 ` Sergey Senozhatsky
2015-07-14 0:31 ` Sergey Senozhatsky
2015-07-14 0:55 ` Minchan Kim
2015-07-14 0:55 ` Minchan Kim
2015-07-14 12:29 ` Sergey Senozhatsky
2015-07-14 12:29 ` Sergey Senozhatsky
2015-07-14 16:52 ` Minchan Kim
2015-07-14 16:52 ` Minchan Kim
2015-07-15 0:21 ` Sergey Senozhatsky
2015-07-15 0:21 ` Sergey Senozhatsky
2015-07-15 0:24 ` Minchan Kim
2015-07-15 0:24 ` Minchan Kim
2015-07-15 11:16 ` Sergey Senozhatsky
2015-07-15 11:16 ` Sergey Senozhatsky
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=20150715233834.GA988@bgram \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.