lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110427091811.153ca78b@notabene.brown>
Date:	Wed, 27 Apr 2011 09:18:11 +1000
From:	NeilBrown <neilb@...e.de>
To:	Mel Gorman <mgorman@...e.de>
Cc:	Linux-MM <linux-mm@...ck.org>,
	Linux-Netdev <netdev@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	David Miller <davem@...emloft.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH 12/13] mm: Throttle direct reclaimers if PF_MEMALLOC
 reserves are low and swap is backed by network storage

On Tue, 26 Apr 2011 15:26:24 +0100 Mel Gorman <mgorman@...e.de> wrote:

> On Tue, Apr 26, 2011 at 10:30:59PM +1000, NeilBrown wrote:
> > On Tue, 26 Apr 2011 08:36:53 +0100 Mel Gorman <mgorman@...e.de> 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);
> > > +	prepare_to_wait(&zone->zone_pgdat->pfmemalloc_wait, &wait,
> > > +							TASK_INTERRUPTIBLE);
> > > +	if (pfmemalloc_watermark_ok(zone->zone_pgdat, high_zoneidx))
> > > +		goto out;
> > > +
> > > +	/* Throttle */
> > > +	do {
> > > +		schedule();
> > > +		finish_wait(&zone->zone_pgdat->pfmemalloc_wait, &wait);
> > > +		prepare_to_wait(&zone->zone_pgdat->pfmemalloc_wait, &wait,
> > > +							TASK_INTERRUPTIBLE);
> > > +	} while (!pfmemalloc_watermark_ok(zone->zone_pgdat, high_zoneidx) &&
> > > +			!fatal_signal_pending(current));
> > > +
> > > +out:
> > > +	finish_wait(&zone->zone_pgdat->pfmemalloc_wait, &wait);
> > > +}
> > 
> > You are doing an interruptible wait, but only checking for fatal signals.
> > So if a non-fatal signal arrives, you will busy-wait.
> > 
> > So I suspect you want TASK_KILLABLE, so just use:
> > 
> >     wait_event_killable(zone->zone_pgdat->pfmemalloc_wait,
> >                         pgmemalloc_watermark_ok(zone->zone_pgdata,
> >                                                 high_zoneidx));
> > 
> 
> Well, if a normal signal arrives, we do not necessarily want the
> process to enter reclaim. For fatal signals, I allow it to continue
> because it's not likely to be putting the system under more pressure
> if it's exiting.

Yep, I understand that and it doesn't seem unreasonable.

However I don't think the code implements that correctly.

If you get a non-fatal signal, schedule will exit immediately (because of the
TASK_INTERRUPTIBLE setting) and the 'while' clause will succeed because the
signal is not fatal, so it will loop around and try to schedule again, which
will again exit immediately - busy loop.

> 
> > (You also have an extraneous call to finish_wait)
> > 
> 
> Which one? I'm not seeing a flow where finish_wait gets called twice
> without a prepare_to_wait in between. 
> 

You don't need to call finish_wait immediately before prepare_to_wait.

It really is best to just use the appropriate 'wait_event*' macro....

NeilBrown

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ