[Devel,RHEL7,COMMIT] tcache: Fix __tcache_reclaim_page() wrong return value conversion

Submitted by Konstantin Khorenko on Aug. 11, 2017, 1:42 p.m.

Details

Message ID 201708111342.v7BDgoR8004906@finist_cl7.x64_64.work.ct
State New
Series "tcache: Fix __tcache_reclaim_page() wrong return value conversion"
Headers show

Commit Message

Konstantin Khorenko Aug. 11, 2017, 1:42 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.3
------>
commit 1258681447209dc4ec4ecdcc01eba25fef4ddb78
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Fri Aug 11 17:42:50 2017 +0400

    tcache: Fix __tcache_reclaim_page() wrong return value conversion
    
    Function tcache_page_tree_delete() returns pointer to struct page.
    We can't convert it to variable of bool type "as is", because they
    have different sizes. As all of struct pages are in kernel memory,
    their addresses are above PAGE_OFFSET, i.e. 0xffff880000000000.
    When such number is converted to bool, it becomes always 0. So,
    the algorhythm does not work as expected. Fix that.
    
    Fixes: ba2ea161f25b "mm/tcache: use lockless lookups in tcache's page tree"
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 mm/tcache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/tcache.c b/mm/tcache.c
index 458d3c4..0835e29 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1059,12 +1059,11 @@  tcache_lru_isolate(int nid, struct page **pages, int nr_to_isolate)
 static bool __tcache_reclaim_page(struct page *page)
 {
 	struct tcache_node *node;
-	bool ret;
 
 	node = tcache_page_node(page);
-	ret = tcache_page_tree_delete(node, page->index, page);
+	page = tcache_page_tree_delete(node, page->index, page);
 	tcache_put_node_and_pool(node);
-	return ret;
+	return (page != NULL);
 }
 
 static int tcache_reclaim_pages(struct page **pages, int nr)

Comments

Konstantin Khorenko Aug. 11, 2017, 1:43 p.m.
Please consider to prepare a ReadyKernel patch for it.

https://readykernel.com/

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 08/11/2017 04:42 PM, Konstantin Khorenko wrote:
> The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
> after rh7-3.10.0-514.26.1.vz7.35.3
> ------>
> commit 1258681447209dc4ec4ecdcc01eba25fef4ddb78
> Author: Kirill Tkhai <ktkhai@virtuozzo.com>
> Date:   Fri Aug 11 17:42:50 2017 +0400
>
>     tcache: Fix __tcache_reclaim_page() wrong return value conversion
>
>     Function tcache_page_tree_delete() returns pointer to struct page.
>     We can't convert it to variable of bool type "as is", because they
>     have different sizes. As all of struct pages are in kernel memory,
>     their addresses are above PAGE_OFFSET, i.e. 0xffff880000000000.
>     When such number is converted to bool, it becomes always 0. So,
>     the algorhythm does not work as expected. Fix that.
>
>     Fixes: ba2ea161f25b "mm/tcache: use lockless lookups in tcache's page tree"
>     Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  mm/tcache.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/tcache.c b/mm/tcache.c
> index 458d3c4..0835e29 100644
> --- a/mm/tcache.c
> +++ b/mm/tcache.c
> @@ -1059,12 +1059,11 @@ tcache_lru_isolate(int nid, struct page **pages, int nr_to_isolate)
>  static bool __tcache_reclaim_page(struct page *page)
>  {
>  	struct tcache_node *node;
> -	bool ret;
>
>  	node = tcache_page_node(page);
> -	ret = tcache_page_tree_delete(node, page->index, page);
> +	page = tcache_page_tree_delete(node, page->index, page);
>  	tcache_put_node_and_pool(node);
> -	return ret;
> +	return (page != NULL);
>  }
>
>  static int tcache_reclaim_pages(struct page **pages, int nr)
> .
>