linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/swap: cleanup *lru_cache_add* functions
@ 2014-04-18 13:09 Jianyu Zhan
  2014-04-18 13:51 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Jianyu Zhan @ 2014-04-18 13:09 UTC (permalink / raw)
  To: akpm, hannes, minchan, shli, riel, sjenning, iamjoonsoo.kim,
	mgorman, aquini, nasa4836, aarcange, khalid.aziz
  Cc: linux-kernel, linux-mm

In mm/swap.c, __lru_cache_add() is exported, but actually there are
no users outside this file. However, lru_cache_add() is supposed to
be used by vfs, or whatever others, but it is not exported.

This patch exports lru_cache_add(), and makes __lru_cache_add()
static. It also exports lru_cache_add_file() and
lru_cache_add_anon(), which both delegate to __lru_cache_add().

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
 include/linux/swap.h | 19 ++-----------------
 mm/swap.c            | 33 +++++++++++++++++++++++++--------
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 3507115..5a14b92 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -308,8 +308,9 @@ extern unsigned long nr_free_pagecache_pages(void);
 
 
 /* linux/mm/swap.c */
-extern void __lru_cache_add(struct page *);
 extern void lru_cache_add(struct page *);
+extern void lru_cache_add_anon(struct page *page);
+extern void lru_cache_add_file(struct page *page);
 extern void lru_add_page_tail(struct page *page, struct page *page_tail,
 			 struct lruvec *lruvec, struct list_head *head);
 extern void activate_page(struct page *);
@@ -323,22 +324,6 @@ extern void swap_setup(void);
 
 extern void add_page_to_unevictable_list(struct page *page);
 
-/**
- * lru_cache_add: add a page to the page lists
- * @page: the page to add
- */
-static inline void lru_cache_add_anon(struct page *page)
-{
-	ClearPageActive(page);
-	__lru_cache_add(page);
-}
-
-static inline void lru_cache_add_file(struct page *page)
-{
-	ClearPageActive(page);
-	__lru_cache_add(page);
-}
-
 /* linux/mm/vmscan.c */
 extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
 					gfp_t gfp_mask, nodemask_t *mask);
diff --git a/mm/swap.c b/mm/swap.c
index 9ce43ba..0c79363 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -582,13 +582,7 @@ void mark_page_accessed(struct page *page)
 }
 EXPORT_SYMBOL(mark_page_accessed);
 
-/*
- * Queue the page for addition to the LRU via pagevec. The decision on whether
- * to add the page to the [in]active [file|anon] list is deferred until the
- * pagevec is drained. This gives a chance for the caller of __lru_cache_add()
- * have the page added to the active list using mark_page_accessed().
- */
-void __lru_cache_add(struct page *page)
+static void __lru_cache_add(struct page *page)
 {
 	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
 
@@ -598,11 +592,33 @@ void __lru_cache_add(struct page *page)
 	pagevec_add(pvec, page);
 	put_cpu_var(lru_add_pvec);
 }
-EXPORT_SYMBOL(__lru_cache_add);
+
+/**
+ * lru_cache_add: add a page to the page lists
+ * @page: the page to add
+ */
+void lru_cache_add_anon(struct page *page)
+{
+	ClearPageActive(page);
+	__lru_cache_add(page);
+}
+EXPORT_SYMBOL(lru_cache_add_anon);
+
+void lru_cache_add_file(struct page *page)
+{
+	ClearPageActive(page);
+	__lru_cache_add(page);
+}
+EXPORT_SYMBOL(lru_cache_add_file);
 
 /**
  * lru_cache_add - add a page to a page list
  * @page: the page to be added to the LRU.
+ *
+ * Queue the page for addition to the LRU via pagevec. The decision on whether
+ * to add the page to the [in]active [file|anon] list is deferred until the
+ * pagevec is drained. This gives a chance for the caller of lru_cache_add()
+ * have the page added to the active list using mark_page_accessed().
  */
 void lru_cache_add(struct page *page)
 {
@@ -610,6 +626,7 @@ void lru_cache_add(struct page *page)
 	VM_BUG_ON_PAGE(PageLRU(page), page);
 	__lru_cache_add(page);
 }
+EXPORT_SYMBOL(lru_cache_add);
 
 /**
  * add_page_to_unevictable_list - add a page to the unevictable list
-- 
1.9.0.GIT

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
  2014-04-18 13:09 [PATCH] mm/swap: cleanup *lru_cache_add* functions Jianyu Zhan
@ 2014-04-18 13:51 ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2014-04-18 13:51 UTC (permalink / raw)
  To: Jianyu Zhan
  Cc: akpm, hannes, minchan, shli, riel, sjenning, iamjoonsoo.kim,
	mgorman, aquini, aarcange, khalid.aziz, linux-kernel, linux-mm

On Fri, Apr 18, 2014 at 09:09:51PM +0800, Jianyu Zhan wrote:
> In mm/swap.c, __lru_cache_add() is exported, but actually there are
> no users outside this file. However, lru_cache_add() is supposed to
> be used by vfs, or whatever others, but it is not exported.

There are no modular users of lru_cache_add, so please don't needlessly
export it.

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
@ 2014-04-18 15:39 Jianyu Zhan
  2014-04-18 21:14 ` Rik van Riel
  2014-04-21  1:00 ` Zhang Yanfei
  0 siblings, 2 replies; 7+ messages in thread
From: Jianyu Zhan @ 2014-04-18 15:39 UTC (permalink / raw)
  To: akpm, minchan, hannes, shli, bob.liu, sjenning, nasa4836,
	iamjoonsoo.kim, aquini, mgorman, riel, aarcange, khalid.aziz
  Cc: linux-kernel, linux-mm

Hi, Christoph Hellwig,

>There are no modular users of lru_cache_add, so please don't needlessly
>export it.

yep, I re-checked and found there is no module user of neither 
lru_cache_add() nor lru_cache_add_anon(), so don't export it.

Here is the renewed patch:
---

In mm/swap.c, __lru_cache_add() is exported, but actually there are
no users outside this file. However, lru_cache_add() is supposed to
be used by vfs, or whatever others, but it is not exported.

This patch unexports __lru_cache_add(), and makes it static.
It also exports lru_cache_add_file(), as it is use by cifs, which
be loaded as module.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
 include/linux/swap.h | 19 ++-----------------
 mm/swap.c            | 31 +++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index 3507115..5a14b92 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -308,8 +308,9 @@ extern unsigned long nr_free_pagecache_pages(void);
 
 
 /* linux/mm/swap.c */
-extern void __lru_cache_add(struct page *);
 extern void lru_cache_add(struct page *);
+extern void lru_cache_add_anon(struct page *page);
+extern void lru_cache_add_file(struct page *page);
 extern void lru_add_page_tail(struct page *page, struct page *page_tail,
 			 struct lruvec *lruvec, struct list_head *head);
 extern void activate_page(struct page *);
@@ -323,22 +324,6 @@ extern void swap_setup(void);
 
 extern void add_page_to_unevictable_list(struct page *page);
 
-/**
- * lru_cache_add: add a page to the page lists
- * @page: the page to add
- */
-static inline void lru_cache_add_anon(struct page *page)
-{
-	ClearPageActive(page);
-	__lru_cache_add(page);
-}
-
-static inline void lru_cache_add_file(struct page *page)
-{
-	ClearPageActive(page);
-	__lru_cache_add(page);
-}
-
 /* linux/mm/vmscan.c */
 extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
 					gfp_t gfp_mask, nodemask_t *mask);
diff --git a/mm/swap.c b/mm/swap.c
index ab3f508..c0cd7d0 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -582,13 +582,7 @@ void mark_page_accessed(struct page *page)
 }
 EXPORT_SYMBOL(mark_page_accessed);
 
-/*
- * Queue the page for addition to the LRU via pagevec. The decision on whether
- * to add the page to the [in]active [file|anon] list is deferred until the
- * pagevec is drained. This gives a chance for the caller of __lru_cache_add()
- * have the page added to the active list using mark_page_accessed().
- */
-void __lru_cache_add(struct page *page)
+static void __lru_cache_add(struct page *page)
 {
 	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
 
@@ -598,11 +592,32 @@ void __lru_cache_add(struct page *page)
 	pagevec_add(pvec, page);
 	put_cpu_var(lru_add_pvec);
 }
-EXPORT_SYMBOL(__lru_cache_add);
+
+/**
+ * lru_cache_add: add a page to the page lists
+ * @page: the page to add
+ */
+void lru_cache_add_anon(struct page *page)
+{
+	ClearPageActive(page);
+	__lru_cache_add(page);
+}
+
+void lru_cache_add_file(struct page *page)
+{
+	ClearPageActive(page);
+	__lru_cache_add(page);
+}
+EXPORT_SYMBOL(lru_cache_add_file);
 
 /**
  * lru_cache_add - add a page to a page list
  * @page: the page to be added to the LRU.
+ *
+ * Queue the page for addition to the LRU via pagevec. The decision on whether
+ * to add the page to the [in]active [file|anon] list is deferred until the
+ * pagevec is drained. This gives a chance for the caller of lru_cache_add()
+ * have the page added to the active list using mark_page_accessed().
  */
 void lru_cache_add(struct page *page)
 {
-- 
1.9.0.GIT

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
  2014-04-18 15:39 Jianyu Zhan
@ 2014-04-18 21:14 ` Rik van Riel
  2014-04-21  1:00 ` Zhang Yanfei
  1 sibling, 0 replies; 7+ messages in thread
From: Rik van Riel @ 2014-04-18 21:14 UTC (permalink / raw)
  To: Jianyu Zhan, akpm, minchan, hannes, shli, bob.liu, sjenning,
	iamjoonsoo.kim, aquini, mgorman, aarcange, khalid.aziz
  Cc: linux-kernel, linux-mm

On 04/18/2014 11:39 AM, Jianyu Zhan wrote:
> Hi, Christoph Hellwig,
> 
>> There are no modular users of lru_cache_add, so please don't needlessly
>> export it.
> 
> yep, I re-checked and found there is no module user of neither 
> lru_cache_add() nor lru_cache_add_anon(), so don't export it.
> 
> Here is the renewed patch:
> ---
> 
> In mm/swap.c, __lru_cache_add() is exported, but actually there are
> no users outside this file. However, lru_cache_add() is supposed to
> be used by vfs, or whatever others, but it is not exported.
> 
> This patch unexports __lru_cache_add(), and makes it static.
> It also exports lru_cache_add_file(), as it is use by cifs, which
> be loaded as module.
> 
> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>

Acked-by: Rik van Riel <riel@redhat.com>


-- 
All rights reversed

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
  2014-04-18 15:39 Jianyu Zhan
  2014-04-18 21:14 ` Rik van Riel
@ 2014-04-21  1:00 ` Zhang Yanfei
  2014-04-21  4:02   ` Jianyu Zhan
  1 sibling, 1 reply; 7+ messages in thread
From: Zhang Yanfei @ 2014-04-21  1:00 UTC (permalink / raw)
  To: Jianyu Zhan
  Cc: akpm, minchan, hannes, shli, bob.liu, sjenning, iamjoonsoo.kim,
	aquini, mgorman, riel, aarcange, khalid.aziz, linux-kernel,
	linux-mm

Hi Jianyu

On 04/18/2014 11:39 PM, Jianyu Zhan wrote:
> Hi, Christoph Hellwig,
> 
>> There are no modular users of lru_cache_add, so please don't needlessly
>> export it.
> 
> yep, I re-checked and found there is no module user of neither 
> lru_cache_add() nor lru_cache_add_anon(), so don't export it.
> 
> Here is the renewed patch:
> ---
> 
> In mm/swap.c, __lru_cache_add() is exported, but actually there are
> no users outside this file. However, lru_cache_add() is supposed to
> be used by vfs, or whatever others, but it is not exported.
> 
> This patch unexports __lru_cache_add(), and makes it static.
> It also exports lru_cache_add_file(), as it is use by cifs, which
> be loaded as module.

What should be exported?

lru_cache_add()
lru_cache_add_anon()
lru_cache_add_file()

It seems you only export lru_cache_add_file() in the patch.

Thanks

> 
> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> ---
>  include/linux/swap.h | 19 ++-----------------
>  mm/swap.c            | 31 +++++++++++++++++++++++--------
>  2 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 3507115..5a14b92 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -308,8 +308,9 @@ extern unsigned long nr_free_pagecache_pages(void);
>  
>  
>  /* linux/mm/swap.c */
> -extern void __lru_cache_add(struct page *);
>  extern void lru_cache_add(struct page *);
> +extern void lru_cache_add_anon(struct page *page);
> +extern void lru_cache_add_file(struct page *page);
>  extern void lru_add_page_tail(struct page *page, struct page *page_tail,
>  			 struct lruvec *lruvec, struct list_head *head);
>  extern void activate_page(struct page *);
> @@ -323,22 +324,6 @@ extern void swap_setup(void);
>  
>  extern void add_page_to_unevictable_list(struct page *page);
>  
> -/**
> - * lru_cache_add: add a page to the page lists
> - * @page: the page to add
> - */
> -static inline void lru_cache_add_anon(struct page *page)
> -{
> -	ClearPageActive(page);
> -	__lru_cache_add(page);
> -}
> -
> -static inline void lru_cache_add_file(struct page *page)
> -{
> -	ClearPageActive(page);
> -	__lru_cache_add(page);
> -}
> -
>  /* linux/mm/vmscan.c */
>  extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
>  					gfp_t gfp_mask, nodemask_t *mask);
> diff --git a/mm/swap.c b/mm/swap.c
> index ab3f508..c0cd7d0 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -582,13 +582,7 @@ void mark_page_accessed(struct page *page)
>  }
>  EXPORT_SYMBOL(mark_page_accessed);
>  
> -/*
> - * Queue the page for addition to the LRU via pagevec. The decision on whether
> - * to add the page to the [in]active [file|anon] list is deferred until the
> - * pagevec is drained. This gives a chance for the caller of __lru_cache_add()
> - * have the page added to the active list using mark_page_accessed().
> - */
> -void __lru_cache_add(struct page *page)
> +static void __lru_cache_add(struct page *page)
>  {
>  	struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
>  
> @@ -598,11 +592,32 @@ void __lru_cache_add(struct page *page)
>  	pagevec_add(pvec, page);
>  	put_cpu_var(lru_add_pvec);
>  }
> -EXPORT_SYMBOL(__lru_cache_add);
> +
> +/**
> + * lru_cache_add: add a page to the page lists
> + * @page: the page to add
> + */
> +void lru_cache_add_anon(struct page *page)
> +{
> +	ClearPageActive(page);
> +	__lru_cache_add(page);
> +}
> +
> +void lru_cache_add_file(struct page *page)
> +{
> +	ClearPageActive(page);
> +	__lru_cache_add(page);
> +}
> +EXPORT_SYMBOL(lru_cache_add_file);
>  
>  /**
>   * lru_cache_add - add a page to a page list
>   * @page: the page to be added to the LRU.
> + *
> + * Queue the page for addition to the LRU via pagevec. The decision on whether
> + * to add the page to the [in]active [file|anon] list is deferred until the
> + * pagevec is drained. This gives a chance for the caller of lru_cache_add()
> + * have the page added to the active list using mark_page_accessed().
>   */
>  void lru_cache_add(struct page *page)
>  {
> 


-- 
Thanks.
Zhang Yanfei

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
  2014-04-21  1:00 ` Zhang Yanfei
@ 2014-04-21  4:02   ` Jianyu Zhan
  2014-04-21  6:09     ` Zhang Yanfei
  0 siblings, 1 reply; 7+ messages in thread
From: Jianyu Zhan @ 2014-04-21  4:02 UTC (permalink / raw)
  To: Zhang Yanfei
  Cc: Andrew Morton, Minchan Kim, Johannes Weiner, shli, bob.liu,
	sjenning, iamjoonsoo.kim, aquini, Mel Gorman, Rik van Riel,
	Andrea Arcangeli, khalid.aziz, LKML, linux-mm@kvack.org

Hi,  Yanfei,

On Mon, Apr 21, 2014 at 9:00 AM, Zhang Yanfei
<zhangyanfei@cn.fujitsu.com> wrote:
> What should be exported?
>
> lru_cache_add()
> lru_cache_add_anon()
> lru_cache_add_file()
>
> It seems you only export lru_cache_add_file() in the patch.

Right, lru_cache_add_anon() is only used by VM code, so it should not
be exported.

lru_cache_add_file() and lru_cache_add() are supposed to be used by
vfs ans fs code.

But  now only lru_cache_add_file() is  used by CIFS and FUSE, which
both could be
built as module, so it must be exported;  and lru_cache_add() has now
no module users,
so as Rik suggests, it is unexported too.


Thanks,
Jianyu Zhan

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

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

* Re: [PATCH] mm/swap: cleanup *lru_cache_add* functions
  2014-04-21  4:02   ` Jianyu Zhan
@ 2014-04-21  6:09     ` Zhang Yanfei
  0 siblings, 0 replies; 7+ messages in thread
From: Zhang Yanfei @ 2014-04-21  6:09 UTC (permalink / raw)
  To: Jianyu Zhan
  Cc: Andrew Morton, Minchan Kim, Johannes Weiner, shli, bob.liu,
	sjenning, iamjoonsoo.kim, aquini, Mel Gorman, Rik van Riel,
	Andrea Arcangeli, khalid.aziz, LKML, linux-mm@kvack.org

On 04/21/2014 12:02 PM, Jianyu Zhan wrote:
> Hi,  Yanfei,
> 
> On Mon, Apr 21, 2014 at 9:00 AM, Zhang Yanfei
> <zhangyanfei@cn.fujitsu.com> wrote:
>> What should be exported?
>>
>> lru_cache_add()
>> lru_cache_add_anon()
>> lru_cache_add_file()
>>
>> It seems you only export lru_cache_add_file() in the patch.
> 
> Right, lru_cache_add_anon() is only used by VM code, so it should not
> be exported.
> 
> lru_cache_add_file() and lru_cache_add() are supposed to be used by
> vfs ans fs code.
> 
> But  now only lru_cache_add_file() is  used by CIFS and FUSE, which
> both could be
> built as module, so it must be exported;  and lru_cache_add() has now
> no module users,
> so as Rik suggests, it is unexported too.
> 

OK. So The sentence in the patch log confused me:

[ However, lru_cache_add() is supposed to
be used by vfs, or whatever others, but it is not exported.]

otherwise, 
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>

Thanks.

-- 
Thanks.
Zhang Yanfei

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

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

end of thread, other threads:[~2014-04-21  6:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-18 13:09 [PATCH] mm/swap: cleanup *lru_cache_add* functions Jianyu Zhan
2014-04-18 13:51 ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2014-04-18 15:39 Jianyu Zhan
2014-04-18 21:14 ` Rik van Riel
2014-04-21  1:00 ` Zhang Yanfei
2014-04-21  4:02   ` Jianyu Zhan
2014-04-21  6:09     ` Zhang Yanfei

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