linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/zbud: init user ops only when it is needed
@ 2014-10-15 10:00 Heesub Shin
  2014-10-15 20:17 ` Andrew Morton
  2014-10-18 13:57 ` Dan Streetman
  0 siblings, 2 replies; 4+ messages in thread
From: Heesub Shin @ 2014-10-15 10:00 UTC (permalink / raw)
  To: Dan Streetman, Seth Jennings, Andrew Morton
  Cc: linux-mm, linux-kernel, Sunae Seo, Heesub Shin

When zbud is initialized through the zpool wrapper, pool->ops which
points to user-defined operations is always set regardless of whether it
is specified from the upper layer. This causes zbud_reclaim_page() to
iterate its loop for evicting pool pages out without any gain.

This patch sets the user-defined ops only when it is needed, so that
zbud_reclaim_page() can bail out the reclamation loop earlier if there
is no user-defined operations specified.

Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
---
 mm/zbud.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/zbud.c b/mm/zbud.c
index ecf1dbe..db8de74 100644
--- a/mm/zbud.c
+++ b/mm/zbud.c
@@ -132,7 +132,7 @@ static struct zbud_ops zbud_zpool_ops = {
 
 static void *zbud_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops)
 {
-	return zbud_create_pool(gfp, &zbud_zpool_ops);
+	return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
 }
 
 static void zbud_zpool_destroy(void *pool)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/zbud: init user ops only when it is needed
  2014-10-15 10:00 [PATCH] mm/zbud: init user ops only when it is needed Heesub Shin
@ 2014-10-15 20:17 ` Andrew Morton
  2014-10-16  5:48   ` Heesub Shin
  2014-10-18 13:57 ` Dan Streetman
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2014-10-15 20:17 UTC (permalink / raw)
  To: Heesub Shin
  Cc: Dan Streetman, Seth Jennings, linux-mm, linux-kernel, Sunae Seo

On Wed, 15 Oct 2014 19:00:43 +0900 Heesub Shin <heesub.shin@samsung.com> wrote:

> When zbud is initialized through the zpool wrapper, pool->ops which
> points to user-defined operations is always set regardless of whether it
> is specified from the upper layer. This causes zbud_reclaim_page() to
> iterate its loop for evicting pool pages out without any gain.
> 
> This patch sets the user-defined ops only when it is needed, so that
> zbud_reclaim_page() can bail out the reclamation loop earlier if there
> is no user-defined operations specified.

Which callsite is calling zbud_zpool_create(..., NULL)?

> ...
> --- a/mm/zbud.c
> +++ b/mm/zbud.c
> @@ -132,7 +132,7 @@ static struct zbud_ops zbud_zpool_ops = {
>  
>  static void *zbud_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops)
>  {
> -	return zbud_create_pool(gfp, &zbud_zpool_ops);
> +	return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
>  }
>  
>  static void zbud_zpool_destroy(void *pool)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/zbud: init user ops only when it is needed
  2014-10-15 20:17 ` Andrew Morton
@ 2014-10-16  5:48   ` Heesub Shin
  0 siblings, 0 replies; 4+ messages in thread
From: Heesub Shin @ 2014-10-16  5:48 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Dan Streetman, Seth Jennings, linux-mm, linux-kernel, Sunae Seo

Hello,

On 10/16/2014 05:17 AM, Andrew Morton wrote:
> On Wed, 15 Oct 2014 19:00:43 +0900 Heesub Shin <heesub.shin@samsung.com> wrote:
>
>> When zbud is initialized through the zpool wrapper, pool->ops which
>> points to user-defined operations is always set regardless of whether it
>> is specified from the upper layer. This causes zbud_reclaim_page() to
>> iterate its loop for evicting pool pages out without any gain.
>>
>> This patch sets the user-defined ops only when it is needed, so that
>> zbud_reclaim_page() can bail out the reclamation loop earlier if there
>> is no user-defined operations specified.
>
> Which callsite is calling zbud_zpool_create(..., NULL)?

Currently nowhere. zswap is the only user of zbud and always passes a 
pointer to user-defined operation on pool creation. In addition, there 
may be less possibility that pool shrinking is requested by users who 
did not provide the user-defined ops. So, we may not need to worry much 
about what I wrote in the changelog. However, it is definitely weird to 
pass an argument, zpool_ops, which even will not be referenced by 
zbud_zpool_create(). Above all, it would be more useful to avoid the 
possibility in the future rather than just ignoring it.

regards,
heesub

>
>> ...
>> --- a/mm/zbud.c
>> +++ b/mm/zbud.c
>> @@ -132,7 +132,7 @@ static struct zbud_ops zbud_zpool_ops = {
>>
>>   static void *zbud_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops)
>>   {
>> -	return zbud_create_pool(gfp, &zbud_zpool_ops);
>> +	return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
>>   }
>>
>>   static void zbud_zpool_destroy(void *pool)
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/zbud: init user ops only when it is needed
  2014-10-15 10:00 [PATCH] mm/zbud: init user ops only when it is needed Heesub Shin
  2014-10-15 20:17 ` Andrew Morton
@ 2014-10-18 13:57 ` Dan Streetman
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Streetman @ 2014-10-18 13:57 UTC (permalink / raw)
  To: Heesub Shin
  Cc: Seth Jennings, Andrew Morton, Linux-MM, linux-kernel, Sunae Seo

On Wed, Oct 15, 2014 at 6:00 AM, Heesub Shin <heesub.shin@samsung.com> wrote:
> When zbud is initialized through the zpool wrapper, pool->ops which
> points to user-defined operations is always set regardless of whether it
> is specified from the upper layer. This causes zbud_reclaim_page() to
> iterate its loop for evicting pool pages out without any gain.
>
> This patch sets the user-defined ops only when it is needed, so that
> zbud_reclaim_page() can bail out the reclamation loop earlier if there
> is no user-defined operations specified.

Though the only current user (zswap) always passes an ops param, other
future users may not and this is the right way to handle it.  thanks!

>
> Signed-off-by: Heesub Shin <heesub.shin@samsung.com>

Acked-by: Dan Streetman <ddstreet@ieee.org>

> ---
>  mm/zbud.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/zbud.c b/mm/zbud.c
> index ecf1dbe..db8de74 100644
> --- a/mm/zbud.c
> +++ b/mm/zbud.c
> @@ -132,7 +132,7 @@ static struct zbud_ops zbud_zpool_ops = {
>
>  static void *zbud_zpool_create(gfp_t gfp, struct zpool_ops *zpool_ops)
>  {
> -       return zbud_create_pool(gfp, &zbud_zpool_ops);
> +       return zbud_create_pool(gfp, zpool_ops ? &zbud_zpool_ops : NULL);
>  }
>
>  static void zbud_zpool_destroy(void *pool)
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-18 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-15 10:00 [PATCH] mm/zbud: init user ops only when it is needed Heesub Shin
2014-10-15 20:17 ` Andrew Morton
2014-10-16  5:48   ` Heesub Shin
2014-10-18 13:57 ` Dan Streetman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).