Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6812959ybi; Wed, 31 Jul 2019 22:15:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeFCtTYRXbo9EWDDMUi1J1gM9vto6hPGqImW2l3ZTl4ciFR8O1yEaSLe6vvszOjUY1JoGQ X-Received: by 2002:a63:66c5:: with SMTP id a188mr116620516pgc.127.1564636518843; Wed, 31 Jul 2019 22:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564636518; cv=none; d=google.com; s=arc-20160816; b=MsFUcnUcZ1h8phgdscAbfshdZPlM653uAOS8otdpm1aPE9StD6ubKPVqOsXhVqw5/m pphILsXWI0VNUIq7eVW0KuwOAic6xnSxGp4q5Iyv4P+GsF3ixyYU4tL1y/Qn4iTzyyZd 3/8gsCYfz/dFuZ9fb109QYV25e2P+GiCLpnlBkORU8Rg+jOWjM925Msz5zwX+jWa8z5s pimeYQc9j3TGeTykOs+b/5g8kGVhFaumo/ciZshPX+9bPVRcwrpNTIUpA3gHWVbE59ji 2KP8hwu6q6fMtHR8TPwa5mj0Tc2MD1Tuhn3GH8kE3rrQkUiyyM2yJ9N4m8lrVGmW8A6J MqKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=47k2fT2zObdEX3+8eBHfRgG6WmFhK8JdHLmsggHYRw8=; b=IIl0WSpXAD/VhRsHNn3z/lazR9P1GM2+h+dhOXMPZzHqRhxEYHhqd7oXyhR7j21V1t v42TXDPXBr07Nmv4DwYI/dQYFcbTN3fnrvZO8LNxXUkkrC8EKgG53B+xDRv/cOHxJ3tm XGg9ltxKwdHyZTV0hdM93AXrGrG6mQuhIbJ2cw47+3hZNee4ibx3iBHV1v0M5TVUJTNg P6qZlugvioa8xeNkwXuCZq5fCsHUDJcJ1hGcyYiSoq5ESkO4556ZGi8Tzwp7pS8OvBj2 smZ2glwL3PztTq6UpLgjmTdVTtuqUZhUXH9avNCOLocrQQQxM18wyhW8fxDwgsrbdAoY L6dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EeUYGnHh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si30241890plz.129.2019.07.31.22.15.01; Wed, 31 Jul 2019 22:15:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EeUYGnHh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728095AbfHAE0x (ORCPT + 99 others); Thu, 1 Aug 2019 00:26:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbfHAE0w (ORCPT ); Thu, 1 Aug 2019 00:26:52 -0400 Received: from localhost (c-98-234-77-170.hsd1.ca.comcast.net [98.234.77.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F161206B8; Thu, 1 Aug 2019 04:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564633611; bh=x3oQphNi97BHKesFCyayCBd82tnHLFnRd4EkUkIb9LU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EeUYGnHhD5Uw+xaqPnD9h3Ef8nY+q7sUcL6J6hJyLV3MYcLgGWSTfw1nzGTVGjB2J cEufzu6izk8I2/CcmjO2ouN7kl1cf139fwicID4od8qakauIExNoVryLGopD611WrN GRVOTXQxhtbZb2ZrM0j5DbQR6ZmAUkggqwDMUjms= Date: Wed, 31 Jul 2019 21:26:50 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: fix livelock in swapfile writes Message-ID: <20190801042650.GD84433@jaegeuk-macbookpro.roam.corp.google.com> References: <20190731204353.62056-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01, Chao Yu wrote: > On 2019/8/1 4:43, Jaegeuk Kim wrote: > > This patch fixes livelock in the below call path when writing swap pages. > > > > [46374.617256] c2 701 __switch_to+0xe4/0x100 > > [46374.617265] c2 701 __schedule+0x80c/0xbc4 > > [46374.617273] c2 701 schedule+0x74/0x98 > > [46374.617281] c2 701 rwsem_down_read_failed+0x190/0x234 > > [46374.617291] c2 701 down_read+0x58/0x5c > > [46374.617300] c2 701 f2fs_map_blocks+0x138/0x9a8 > > [46374.617310] c2 701 get_data_block_dio_write+0x74/0x104 > > [46374.617320] c2 701 __blockdev_direct_IO+0x1350/0x3930 > > [46374.617331] c2 701 f2fs_direct_IO+0x55c/0x8bc > > [46374.617341] c2 701 __swap_writepage+0x1d0/0x3e8 > > [46374.617351] c2 701 swap_writepage+0x44/0x54 > > [46374.617360] c2 701 shrink_page_list+0x140/0xe80 > > [46374.617371] c2 701 shrink_inactive_list+0x510/0x918 > > [46374.617381] c2 701 shrink_node_memcg+0x2d4/0x804 > > [46374.617391] c2 701 shrink_node+0x10c/0x2f8 > > [46374.617400] c2 701 do_try_to_free_pages+0x178/0x38c > > [46374.617410] c2 701 try_to_free_pages+0x348/0x4b8 > > [46374.617419] c2 701 __alloc_pages_nodemask+0x7f8/0x1014 > > [46374.617429] c2 701 pagecache_get_page+0x184/0x2cc > > [46374.617438] c2 701 f2fs_new_node_page+0x60/0x41c > > [46374.617449] c2 701 f2fs_new_inode_page+0x50/0x7c > > [46374.617460] c2 701 f2fs_init_inode_metadata+0x128/0x530 > > [46374.617472] c2 701 f2fs_add_inline_entry+0x138/0xd64 > > [46374.617480] c2 701 f2fs_do_add_link+0xf4/0x178 > > [46374.617488] c2 701 f2fs_create+0x1e4/0x3ac > > [46374.617497] c2 701 path_openat+0xdc0/0x1308 > > [46374.617507] c2 701 do_filp_open+0x78/0x124 > > [46374.617516] c2 701 do_sys_open+0x134/0x248 > > [46374.617525] c2 701 SyS_openat+0x14/0x20 > > > > Signed-off-by: Jaegeuk Kim > > --- > > fs/f2fs/data.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > index abbf14e9bd72..f49f243fd54f 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -1372,7 +1372,7 @@ static int get_data_block_dio_write(struct inode *inode, sector_t iblock, > > return __get_data_block(inode, iblock, bh_result, create, > > F2FS_GET_BLOCK_DIO, NULL, > > f2fs_rw_hint_to_seg_type(inode->i_write_hint), > > - true); > > + IS_SWAPFILE(inode) ? false : true); > > I suspect that we should use node_change for swapfile rather than just changing > may_write field to skip lock. Swap write should not change the node page. > > __do_map_lock() > if (flag == F2FS_GET_BLOCK_PRE_AIO || IS_SWAPFILE(inode)) { > ... > } else { > ... > } > > Thanks, > > > > } > > > > static int get_data_block_dio(struct inode *inode, sector_t iblock, > >