From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754504Ab1INIvo (ORCPT ); Wed, 14 Sep 2011 04:51:44 -0400 Received: from mga01.intel.com ([192.55.52.88]:35632 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754093Ab1INIvn (ORCPT ); Wed, 14 Sep 2011 04:51:43 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.68,379,1312182000"; d="scan'208";a="51126012" Subject: Re: [BUG] infinite loop in find_get_pages() From: Shaohua Li To: Eric Dumazet Cc: Linus Torvalds , Hugh Dickins , Andrew Morton , linux-kernel , Rik van Riel In-Reply-To: <1315989783.2361.7.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> References: <1315941801.2565.19.camel@edumazet-laptop> <1315983230.2565.28.camel@edumazet-laptop> <1315989783.2361.7.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> Content-Type: text/plain; charset="UTF-8" Date: Wed, 14 Sep 2011 16:55:19 +0800 Message-ID: <1315990519.29510.119.camel@sli10-conroe> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2011-09-14 at 16:43 +0800, Eric Dumazet wrote: > Le mercredi 14 septembre 2011 à 16:20 +0800, Shaohua Li a écrit : > > 2011/9/14 Shaohua Li : > > > it appears we didn't account skipped swap entry in find_get_pages(). > > > does the attached patch help? > > I can easily reproduce the issue. Just cp files in tmpfs, trigger swap and > > drop caches. The debug patch fixes it at my side. > > Eric, please try it. > > > > Hello Shaohua > > I tried it with added traces : > > > [ 277.077855] mv used greatest stack depth: 3336 bytes left > [ 310.558012] nr_found=2 nr_skip=2 > [ 310.558139] nr_found=14 nr_skip=14 > [ 332.195162] nr_found=2 nr_skip=2 > [ 332.195274] nr_found=14 nr_skip=14 > [ 352.315273] nr_found=14 nr_skip=14 > [ 372.673575] nr_found=14 nr_skip=14 > [ 397.115463] nr_found=14 nr_skip=14 > [ 403.391694] cc1 used greatest stack depth: 3184 bytes left > [ 404.761194] cc1 used greatest stack depth: 2640 bytes left > [ 417.306510] nr_found=14 nr_skip=14 > [ 440.198051] nr_found=14 nr_skip=14 > > I also used : > > - if (unlikely(!ret && nr_found)) > + if (unlikely(!ret && nr_found > nr_skip)) > goto restart; nr_found > nr_skip is better > It seems to fix the bug. I suspect it also aborts > invalidate_mapping_pages() if we skip 14 pages, but existing comment > states its OK : > > /* > * Note: this function may get called on a shmem/tmpfs mapping: > * pagevec_lookup() might then return 0 prematurely (because it > * got a gangful of swap entries); but it's hardly worth worrying > * about - it can rarely have anything to free from such a mapping > * (most pages are dirty), and already skips over any difficulties. > */ that might be a problem, let Hugh answer if it is. Thanks, Shaohua