From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbbHMKAJ (ORCPT ); Thu, 13 Aug 2015 06:00:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:42897 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbbHMKAH (ORCPT ); Thu, 13 Aug 2015 06:00:07 -0400 Date: Thu, 13 Aug 2015 11:00:02 +0100 From: Mel Gorman To: mhocko@kernel.org Cc: linux-mm@kvack.org, Vlastimil Babka , Jiri Bohac , Andrew Morton , "David S. Miller" , Eric Dumazet , LKML , netdev@vger.kernel.org, Michal Hocko Subject: Re: [PATCH] mm: make page pfmemalloc check more robust Message-ID: <20150813100002.GA9854@suse.de> References: <1439456364-4530-1-git-send-email-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1439456364-4530-1-git-send-email-mhocko@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 13, 2015 at 10:58:54AM +0200, mhocko@kernel.org wrote: > From: Michal Hocko > > The patch c48a11c7ad26 ("netvm: propagate page->pfmemalloc to skb") > added the checks for page->pfmemalloc to __skb_fill_page_desc(): > > if (page->pfmemalloc && !page->mapping) > skb->pfmemalloc = true; > > It assumes page->mapping == NULL implies that page->pfmemalloc can be > trusted. However, __delete_from_page_cache() can set set page->mapping > to NULL and leave page->index value alone. Due to being in union, a > non-zero page->index will be interpreted as true page->pfmemalloc. > > So the assumption is invalid if the networking code can see such a > page. And it seems it can. We have encountered this with a NFS over > loopback setup when such a page is attached to a new skbuf. There is no > copying going on in this case so the page confuses __skb_fill_page_desc > which interprets the index as pfmemalloc flag and the network stack > drops packets that have been allocated using the reserves unless they > are to be queued on sockets handling the swapping which is the case here > and that leads to hangs when the nfs client waits for a response from > the server which has been dropped and thus never arrive. > > The struct page is already heavily packed so rather than finding > another hole to put it in, let's do a trick instead. We can reuse the > index again but define it to an impossible value (-1UL). This is the > page index so it should never see the value that large. Replace all > direct users of page->pfmemalloc by page_is_pfmemalloc which will > hide this nastiness from unspoiled eyes. > > The information will get lost if somebody wants to use page->index > obviously but that was the case before and the original code expected > that the information should be persisted somewhere else if that is > really needed (e.g. what SLAB and SLUB do). > > Fixes: c48a11c7ad26 ("netvm: propagate page->pfmemalloc to skb") > Cc: stable # 3.6+ > Debugged-by: Vlastimil Babka > Debugged-by: Jiri Bohac > Signed-off-by: Michal Hocko Acked-by: Mel Gorman -- Mel Gorman SUSE Labs