Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp272076img; Mon, 18 Mar 2019 02:48:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZck/SeAkK24/t+/W9pakUOM1l3DCPB+hE2ZiKvQnp+sZp2CiwPMAb/FXVDGHbJPJwrmET X-Received: by 2002:a65:50c8:: with SMTP id s8mr16742436pgp.308.1552902495160; Mon, 18 Mar 2019 02:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552902495; cv=none; d=google.com; s=arc-20160816; b=YXryTrPwyT67U0ND9h69Kio6eNlrEUItutY9B3uU43+T+OjYdrQbPsjkGGhaYE1BFP d2tnsnpwQ4c90ipNK/jSn9MN4gedzt4L9cxjld2+ulYX2QNr3OAYabb0YB/ANHWhVps6 xTlSJxx34eiyprFj8+6eRiGzhzYgB3KdcvIUnKAves7MJISn9zFzf9MFO8LKds3aCKEd YS+xRsBltb4fPUtDxsKIAf5kGJuvKlMmis+zngJH23fYRRD5z5sEsviDGXaQrlJG1gl0 mfyeVwlMP/En/aRzsr7RlNHeJILO0RizQWP7GibCFHiMlVrFLaJVQIDmdXt047g2VRS7 57jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=mxNbg2U9QVpDsyt9B3ggL6erGUHadMnByeZtoBypyi4=; b=JE5ERe+Yj/hiH6WylzN/Tv84NWlIuyLN6lr9h1gGjr+5jK37VrxLZ0Rrh4l/RKa4/2 3iqMj1Pl6XtjxzM045jqCIgmzNBxrT0WgmpVDfZsZhW003qy/yLgONOusASQTRjZnnvV IiNgVbJr+6G0DzZ/VrU0e8sqzh2s8e4ofnZIuGmr8GUYp6cn2+vNzn8PdjJbsE8os+At YSyaMtP81fCGe35jnfNRY7cbO6eIt6VngftpncFpYd3a/ImkN1mbJsv+cnjglZcn2smt FlS4zp7Zq3/6EawYQzLY36zqwVmIP5XGuF4WIGfIlCPjMdKmG5iBphzavILmQhuTX8zY 2iWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k124si7471661pgc.184.2019.03.18.02.48.00; Mon, 18 Mar 2019 02:48:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728026AbfCRJrC (ORCPT + 99 others); Mon, 18 Mar 2019 05:47:02 -0400 Received: from relay.sw.ru ([185.231.240.75]:41486 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726835AbfCRJ2N (ORCPT ); Mon, 18 Mar 2019 05:28:13 -0400 Received: from [172.16.25.169] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h5oZ1-00055N-4M; Mon, 18 Mar 2019 12:28:11 +0300 Subject: [PATCH REBASED 3/4] mm: Remove pages_to_free argument of move_active_pages_to_lru() From: Kirill Tkhai To: akpm@linux-foundation.org, daniel.m.jordan@oracle.com, mhocko@suse.com, ktkhai@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Mon, 18 Mar 2019 12:28:10 +0300 Message-ID: <155290129079.31489.16180612694090502942.stgit@localhost.localdomain> In-Reply-To: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> References: <155290113594.31489.16711525148390601318.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We may use input argument list as output argument too. This makes the function more similar to putback_inactive_pages(). Signed-off-by: Kirill Tkhai Reviewed-by: Daniel Jordan v2: Fix comment spelling. --- mm/vmscan.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index d2adabe4457d..1794ec7b21d8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2004,10 +2004,10 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, static unsigned move_active_pages_to_lru(struct lruvec *lruvec, struct list_head *list, - struct list_head *pages_to_free, enum lru_list lru) { struct pglist_data *pgdat = lruvec_pgdat(lruvec); + LIST_HEAD(pages_to_free); struct page *page; int nr_pages; int nr_moved = 0; @@ -2034,12 +2034,17 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec, (*get_compound_page_dtor(page))(page); spin_lock_irq(&pgdat->lru_lock); } else - list_add(&page->lru, pages_to_free); + list_add(&page->lru, &pages_to_free); } else { nr_moved += nr_pages; } } + /* + * To save our caller's stack, now use input list for pages to free. + */ + list_splice(&pages_to_free, list); + return nr_moved; } @@ -2129,8 +2134,10 @@ static void shrink_active_list(unsigned long nr_to_scan, */ reclaim_stat->recent_rotated[file] += nr_rotated; - nr_activate = move_active_pages_to_lru(lruvec, &l_active, &l_hold, lru); - nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, &l_hold, lru - LRU_ACTIVE); + nr_activate = move_active_pages_to_lru(lruvec, &l_active, lru); + nr_deactivate = move_active_pages_to_lru(lruvec, &l_inactive, lru - LRU_ACTIVE); + /* Keep all free pages in l_active list */ + list_splice(&l_inactive, &l_active); __count_vm_events(PGDEACTIVATE, nr_deactivate); __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, nr_deactivate); @@ -2138,8 +2145,8 @@ static void shrink_active_list(unsigned long nr_to_scan, __mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken); spin_unlock_irq(&pgdat->lru_lock); - mem_cgroup_uncharge_list(&l_hold); - free_unref_page_list(&l_hold); + mem_cgroup_uncharge_list(&l_active); + free_unref_page_list(&l_active); trace_mm_vmscan_lru_shrink_active(pgdat->node_id, nr_taken, nr_activate, nr_deactivate, nr_rotated, sc->priority, file); }