From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753005Ab1D1AW6 (ORCPT ); Wed, 27 Apr 2011 20:22:58 -0400 Received: from cantor.suse.de ([195.135.220.2]:60559 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150Ab1D1AWz (ORCPT ); Wed, 27 Apr 2011 20:22:55 -0400 Date: Thu, 28 Apr 2011 10:22:44 +1000 From: NeilBrown To: Mel Gorman Cc: Linux-MM , Linux-Netdev , LKML , David Miller , Peter Zijlstra Subject: Re: [PATCH 12/13] mm: Throttle direct reclaimers if PF_MEMALLOC reserves are low and swap is backed by network storage Message-ID: <20110428102244.6e1113e9@notabene.brown> In-Reply-To: <1303920491-25302-13-git-send-email-mgorman@suse.de> References: <1303920491-25302-1-git-send-email-mgorman@suse.de> <1303920491-25302-13-git-send-email-mgorman@suse.de> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.1; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Apr 2011 17:08:10 +0100 Mel Gorman wrote: > +/* > + * Throttle direct reclaimers if backing storage is backed by the network > + * and the PFMEMALLOC reserve for the preferred node is getting dangerously > + * depleted. kswapd will continue to make progress and wake the processes > + * when the low watermark is reached > + */ > +static void throttle_direct_reclaim(gfp_t gfp_mask, struct zonelist *zonelist, > + nodemask_t *nodemask) > +{ > + struct zone *zone; > + int high_zoneidx = gfp_zone(gfp_mask); > + DEFINE_WAIT(wait); > + > + /* Check if the pfmemalloc reserves are ok */ > + first_zones_zonelist(zonelist, high_zoneidx, NULL, &zone); > + if (pfmemalloc_watermark_ok(zone->zone_pgdat, high_zoneidx)) > + return; As the first thing that 'wait_event_interruptible" does is test the condition and return if it is true, this "if () return;" is pointless. > + > + /* Throttle */ > + wait_event_interruptible(zone->zone_pgdat->pfmemalloc_wait, > + pfmemalloc_watermark_ok(zone->zone_pgdat, high_zoneidx)); > +} I was surprised that you chose wait_event_interruptible as your previous code was almost exactly "wait_event_killable". Is there some justification for not throttling processes which happen to have a (non-fatal) signal pending? Thanks, NeilBrown > + > unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > gfp_t gfp_mask, nodemask_t *nodemask) > { > @@ -2133,6 +2172,15 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order, > .nodemask = nodemask, > }; > > + throttle_direct_reclaim(gfp_mask, zonelist, nodemask); > + > + /* > + * Do not enter reclaim if fatal signal is pending. 1 is returned so > + * that the page allocator does not consider triggering OOM > + */ > + if (fatal_signal_pending(current)) > + return 1; > + > trace_mm_vmscan_direct_reclaim_begin(order, > sc.may_writepage, > gfp_mask); > @@ -2488,6 +2536,12 @@ loop_again: > } > > } > + > + /* Wake throttled direct reclaimers if low watermark is met */ > + if (waitqueue_active(&pgdat->pfmemalloc_wait) && > + pfmemalloc_watermark_ok(pgdat, MAX_NR_ZONES - 1)) > + wake_up_interruptible(&pgdat->pfmemalloc_wait); > + > if (all_zones_ok || (order && pgdat_balanced(pgdat, balanced, *classzone_idx))) > break; /* kswapd: all done */ > /*