From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753885Ab3LBLXB (ORCPT ); Mon, 2 Dec 2013 06:23:01 -0500 Received: from relay.parallels.com ([195.214.232.42]:47444 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753522Ab3LBLUB (ORCPT ); Mon, 2 Dec 2013 06:20:01 -0500 From: Vladimir Davydov To: , , , CC: , , , , , , Mel Gorman , Rik van Riel Subject: [PATCH v12 14/18] vmscan: take at least one pass with shrinkers Date: Mon, 2 Dec 2013 15:19:49 +0400 Message-ID: <61348e7309d946389b0996cec76c8113cc7a3dc0.1385974612.git.vdavydov@parallels.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.30.16.96] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In very low free kernel memory situations, it may be the case that we have less objects to free than our initial batch size. If this is the case, it is better to shrink those, and open space for the new workload then to keep them and fail the new allocations. In particular, we are concerned with the direct reclaim case for memcg. Although this same technique can be applied to other situations just as well, we will start conservative and apply it for that case, which is the one that matters the most. Signed-off-by: Vladimir Davydov Cc: Johannes Weiner Cc: Michal Hocko Cc: Andrew Morton Cc: Mel Gorman Cc: Rik van Riel --- mm/vmscan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 10e6b2f..749e492 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -287,17 +287,22 @@ shrink_slab_node(struct shrink_control *shrinkctl, struct shrinker *shrinker, fraction, denominator, max_pass, delta, total_scan); - while (total_scan >= batch_size) { + while (total_scan > 0) { unsigned long ret; + unsigned long nr_to_scan = min(batch_size, total_scan); - shrinkctl->nr_to_scan = batch_size; + if (!shrinkctl->target_mem_cgroup && + total_scan < batch_size) + break; + + shrinkctl->nr_to_scan = nr_to_scan; ret = shrinker->scan_objects(shrinker, shrinkctl); if (ret == SHRINK_STOP) break; freed += ret; - count_vm_events(SLABS_SCANNED, batch_size); - total_scan -= batch_size; + count_vm_events(SLABS_SCANNED, nr_to_scan); + total_scan -= nr_to_scan; cond_resched(); } -- 1.7.10.4