[v3,1/2] tcache: Refactor tcache_shrink_scan()

Submitted by Kirill Tkhai on Jan. 23, 2018, 8:55 a.m.

Details

Message ID 151669774455.14360.16515573051232534181.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai Jan. 23, 2018, 8:55 a.m.
Make the function have the only return.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 mm/tcache.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/tcache.c b/mm/tcache.c
index a45af63fbd1b..b7756adda6d8 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1200,24 +1200,24 @@  static DEFINE_PER_CPU(struct page * [TCACHE_SCAN_BATCH], tcache_page_vec);
 static unsigned long tcache_shrink_scan(struct shrinker *shrink,
 					struct shrink_control *sc)
 {
-	struct page **pages = get_cpu_var(tcache_page_vec);
-	int nr_isolated, nr_reclaimed;
+	long nr_isolated, nr_reclaimed;
+	struct page **pages;
+
+	pages = get_cpu_var(tcache_page_vec);
 
 	if (WARN_ON(sc->nr_to_scan > TCACHE_SCAN_BATCH))
 		sc->nr_to_scan = TCACHE_SCAN_BATCH;
 
 	nr_isolated = tcache_lru_isolate(sc->nid, pages, sc->nr_to_scan);
 	if (!nr_isolated) {
-		put_cpu_var(tcache_page_vec);
-		return SHRINK_STOP;
+		nr_reclaimed = SHRINK_STOP;
+		goto out;
 	}
-
 	nr_reclaimed = tcache_reclaim_pages(pages, nr_isolated);
-	put_cpu_var(tcache_page_vec);
-
 	if (current->reclaim_state)
 		current->reclaim_state->reclaimed_slab += nr_reclaimed;
-
+out:
+	put_cpu_var(tcache_page_vec);
 	return nr_reclaimed;
 }
 

Comments

Andrey Ryabinin Jan. 23, 2018, 11:31 a.m.
On 01/23/2018 11:55 AM, Kirill Tkhai wrote:
> Make the function have the only return.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>