linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Cesar Eduardo Barros <cesarb@cesarb.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	Mel Gorman <mgorman@suse.de>, Rik van Riel <riel@redhat.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH RFC] mm: simplify frontswap_init()
Date: Wed, 31 Oct 2012 09:42:46 -0400	[thread overview]
Message-ID: <20121031134246.GF27288@phenom.dumpdata.com> (raw)
In-Reply-To: <1351638773-3986-1-git-send-email-cesarb@cesarb.net>

On Tue, Oct 30, 2012 at 09:12:53PM -0200, Cesar Eduardo Barros wrote:
> The function frontswap_init() uses the passed parameter only to check
> for the presence of the frontswap_map. It is also passed down to
> frontswap_ops.init(), but all implementations of it in the kernel ignore
> the parameter.
> 
> Do the check for frontswap_map in the caller instead and remove the
> parameter from frontswap_init() and frontswap_ops.init().
> 
> Also, __frontswap_init() was exported, but its only caller (via an
> inline function) is mm/swapfile.c, which cannot be built as a module.
> Remove the unnecessary export.
> 
> Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
> ---
> 
> Not even compile tested, just a quick patch to show what I was thinking
> of, but feel free to apply if you think it is good.

That looks good.
> 
> I might write another patch to move it outside the lock later, but I
> would have to read the frontswap code more carefully first.
> 
>  drivers/staging/ramster/zcache-main.c |  2 +-
>  drivers/staging/zcache/zcache-main.c  |  2 +-
>  drivers/xen/tmem.c                    |  2 +-
>  include/linux/frontswap.h             |  8 ++++----
>  mm/frontswap.c                        | 10 ++--------
>  mm/swapfile.c                         |  3 ++-
>  6 files changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
> index a09dd5c..b3f01c9 100644
> --- a/drivers/staging/ramster/zcache-main.c
> +++ b/drivers/staging/ramster/zcache-main.c
> @@ -1610,7 +1610,7 @@ static void zcache_frontswap_flush_area(unsigned type)
>  	}
>  }
>  
> -static void zcache_frontswap_init(unsigned ignored)
> +static void zcache_frontswap_init(void)
>  {
>  	/* a single tmem poolid is used for all frontswap "types" (swapfiles) */
>  	if (zcache_frontswap_poolid < 0)
> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
> index 52b43b7..cb67635 100644
> --- a/drivers/staging/zcache/zcache-main.c
> +++ b/drivers/staging/zcache/zcache-main.c
> @@ -1903,7 +1903,7 @@ static void zcache_frontswap_flush_area(unsigned type)
>  	}
>  }
>  
> -static void zcache_frontswap_init(unsigned ignored)
> +static void zcache_frontswap_init(void)
>  {
>  	/* a single tmem poolid is used for all frontswap "types" (swapfiles) */
>  	if (zcache_frontswap_poolid < 0)
> diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c
> index 144564e..7156ff0 100644
> --- a/drivers/xen/tmem.c
> +++ b/drivers/xen/tmem.c
> @@ -343,7 +343,7 @@ static void tmem_frontswap_flush_area(unsigned type)
>  		(void)xen_tmem_flush_object(pool, oswiz(type, ind));
>  }
>  
> -static void tmem_frontswap_init(unsigned ignored)
> +static void tmem_frontswap_init(void)
>  {
>  	struct tmem_pool_uuid private = TMEM_POOL_PRIVATE_UUID;
>  
> diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
> index 3044254..6374c80 100644
> --- a/include/linux/frontswap.h
> +++ b/include/linux/frontswap.h
> @@ -6,7 +6,7 @@
>  #include <linux/bitops.h>
>  
>  struct frontswap_ops {
> -	void (*init)(unsigned);
> +	void (*init)(void);
>  	int (*store)(unsigned, pgoff_t, struct page *);
>  	int (*load)(unsigned, pgoff_t, struct page *);
>  	void (*invalidate_page)(unsigned, pgoff_t);
> @@ -22,7 +22,7 @@ extern void frontswap_writethrough(bool);
>  #define FRONTSWAP_HAS_EXCLUSIVE_GETS
>  extern void frontswap_tmem_exclusive_gets(bool);
>  
> -extern void __frontswap_init(unsigned type);
> +extern void __frontswap_init(void);
>  extern int __frontswap_store(struct page *page);
>  extern int __frontswap_load(struct page *page);
>  extern void __frontswap_invalidate_page(unsigned, pgoff_t);
> @@ -120,10 +120,10 @@ static inline void frontswap_invalidate_area(unsigned type)
>  		__frontswap_invalidate_area(type);
>  }
>  
> -static inline void frontswap_init(unsigned type)
> +static inline void frontswap_init(void)
>  {
>  	if (frontswap_enabled)
> -		__frontswap_init(type);
> +		__frontswap_init();
>  }
>  
>  #endif /* _LINUX_FRONTSWAP_H */
> diff --git a/mm/frontswap.c b/mm/frontswap.c
> index 2890e67..d13661b 100644
> --- a/mm/frontswap.c
> +++ b/mm/frontswap.c
> @@ -115,16 +115,10 @@ EXPORT_SYMBOL(frontswap_tmem_exclusive_gets);
>  /*
>   * Called when a swap device is swapon'd.
>   */
> -void __frontswap_init(unsigned type)
> +void __frontswap_init(void)
>  {
> -	struct swap_info_struct *sis = swap_info[type];
> -
> -	BUG_ON(sis == NULL);
> -	if (sis->frontswap_map == NULL)
> -		return;
> -	frontswap_ops.init(type);
> +	frontswap_ops.init();
>  }
> -EXPORT_SYMBOL(__frontswap_init);
>  
>  static inline void __frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
>  {
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 088daf4..28c26bd 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -1479,7 +1479,8 @@ static void enable_swap_info(struct swap_info_struct *p, int prio,
>  {
>  	spin_lock(&swap_lock);
>  	_enable_swap_info(p, prio, swap_map, frontswap_map);
> -	frontswap_init(p->type);
> +	if (frontswap_map)
> +		frontswap_init();
>  	spin_unlock(&swap_lock);
>  }
>  
> -- 
> 1.7.11.7

--
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>

  reply	other threads:[~2012-10-31 13:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-27 21:20 [PATCH 0/2] mm: do not call frontswap_init() during swapoff Cesar Eduardo Barros
2012-10-27 21:20 ` [PATCH 1/2] mm: refactor reinsert of swap_info in sys_swapoff Cesar Eduardo Barros
2012-10-30 21:04   ` Andrew Morton
2012-10-30 22:48     ` Cesar Eduardo Barros
2012-10-30 23:12       ` [PATCH RFC] mm: simplify frontswap_init() Cesar Eduardo Barros
2012-10-31 13:42         ` Konrad Rzeszutek Wilk [this message]
2012-10-31 13:45     ` [PATCH 1/2] mm: refactor reinsert of swap_info in sys_swapoff Konrad Rzeszutek Wilk
2012-10-27 21:20 ` [PATCH 2/2] mm: do not call frontswap_init() during swapoff Cesar Eduardo Barros

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=20121031134246.GF27288@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cesarb@cesarb.net \
    --cc=dan.magenheimer@oracle.com \
    --cc=hannes@cmpxchg.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).