Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1651034imu; Wed, 12 Dec 2018 01:45:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZzhl/ds5DUxyP6ZA8uv/LY0Hk7/o0SnBfLWK1ivZYenZhXWe7/mJZRJD7w0+obWLVM2tf X-Received: by 2002:a17:902:9b93:: with SMTP id y19mr19439083plp.336.1544607943765; Wed, 12 Dec 2018 01:45:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544607943; cv=none; d=google.com; s=arc-20160816; b=JdZDNhR0MgkCwQXZfDFk/8faFCJHCzm8ARzx42Et1goY114iScxxdvtS8YOEnjm5Jt EvvuUT4Vitk9ma4nsM7mpSowrg0nGHy29/rYmYl8vC81pwQ0psGIzthvnR6IOLNdmiSY 8cP2R526olBBMmeK/EjhhMQvDqOpurBvFMgHu8dT5AxpzF+zjgtyFwUG8LFSfFvmS70O b6Ab2e4E63cu6alSG0IhITNZ71hWmEXAliI5EBrSIjg17wPQK0Cof2b61NcrYaZN342G lUkj0i3tjuTDKNc3w4oKDky7GJqbpzv0GoPPHqfWxooZETgFaf9ZJdJgHBpO6yuldju1 +9cQ== 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=Qa3ZXcGyRZ87CWcpLbXBvVxbs96EU+L0eUhnAJPXg34=; b=ZEGrgMtfzHmDt3TBUy5YyjsFThE9/KlR6DWYTgbepjkTFzdhS/wvgRgwlCEy/pgmVI BV4yzdy0kAUOTB/Wjj/XNsfJjl3KlaLc/PerUapLu0PICr5s3d4xqFwf9PCPrb/4omuW d3PgaSiogIGYrDbWQWoPjyFqYyLR1Xw4saWO6AtSsS3qyhhIFL9v36IoeOTffBGgS6aP lL7JbSkJlxk26AoD5v/hXBBMZty/oeF0RsaCthoLAZkoVXRG3u8InwKxfOedZDn0W0Dw 2j8fiQY5IQxTmkdvmWTBBdkgUr6mxp/JKVWVW1PeQUFeBPZO1iqOjBz+QJgV4pPHomh3 rKlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=AGYFzHBY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si14405160pgd.189.2018.12.12.01.45.28; Wed, 12 Dec 2018 01:45:43 -0800 (PST) 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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=AGYFzHBY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbeLLJm5 (ORCPT + 99 others); Wed, 12 Dec 2018 04:42:57 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39909 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeLLJm5 (ORCPT ); Wed, 12 Dec 2018 04:42:57 -0500 Received: by mail-pl1-f193.google.com with SMTP id 101so8355347pld.6 for ; Wed, 12 Dec 2018 01:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Qa3ZXcGyRZ87CWcpLbXBvVxbs96EU+L0eUhnAJPXg34=; b=AGYFzHBY3gjjefzh5O/zFswIbw9uknMd9piiWU1Y1QtZGQzwMgsdUTtRO8Or/shp5v i2+9CzSha0CnM5g9mbK1wGiyzyYgv2papylOLpK58miaZQ4ltscOXVVT/hxXeyO3lsBh DEwFBUjmn1UzMkFUlvD9njYFteh/Qi/7Ge2J0Vw3fWs208yN8Ko/nFs497S34OyZIHvS VzifQ4j82GDa7xPO3jIwV8Elqu7Vsp9CCE0NxTq+ByaIALbyJnIEztnMGhk37xYCmeT7 OJexFcG45bZhQQPLMd91HEnl/2iMgzG/fudJz31k6TVS0S4bQAcusJ8tNRmdjN+VcN4I EJfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Qa3ZXcGyRZ87CWcpLbXBvVxbs96EU+L0eUhnAJPXg34=; b=mV0gmBDZ+9+/jIQhomMYm4ZEhS8L8yQhnE3s/FWtq2yar/WjhfXeKt0bh27CiVpKRa g4IpbhH9xjjEFo5+12VHK65sczCvovQ0kBpvsAs/DxVtnHJYcTI9MAGDusOPHZu1xo1K UC1KA0nXLD2xydieyt7MxSuaizCWl829CUrD/Pv+8a8a83DLkN0LyYkdl77HRVWJNTC4 +9ppMV+fqi65uTLmB2H32mxmBbenyyWciIc48E6UOQ4RNHHj3I77Lqh24v4ghtgUbmoe l44JVi2+VAwK5rT7g8Qqecv2k9qHtWyVEAJOgxVrNv6/Crx+/bdRsPlhIxzJkEcfnCb4 ZlKQ== X-Gm-Message-State: AA+aEWaJEjfm8MxpjyUSE0escGFuetnvX27HEvoC+DiiwLe7AbhG3UMx zPKi6RSws1+z6luaBwflYLdMrw== X-Received: by 2002:a17:902:a70b:: with SMTP id w11mr19104349plq.84.1544607775316; Wed, 12 Dec 2018 01:42:55 -0800 (PST) Received: from kshutemo-mobl1.localdomain ([134.134.139.82]) by smtp.gmail.com with ESMTPSA id t87sm59106208pfk.122.2018.12.12.01.42.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 01:42:54 -0800 (PST) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id B50E4300256; Wed, 12 Dec 2018 12:42:49 +0300 (+03) Date: Wed, 12 Dec 2018 12:42:49 +0300 From: "Kirill A. Shutemov" To: Michal Hocko Cc: Andrew Morton , Liu Bo , Jan Kara , Dave Chinner , Theodore Ts'o , Johannes Weiner , Vladimir Davydov , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, LKML , Michal Hocko , Hugh Dickins Subject: Re: [PATCH] mm, memcg: fix reclaim deadlock with writeback Message-ID: <20181212094249.cw4xjrdchqsp2tkt@kshutemo-mobl1> References: <20181211132645.31053-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181211132645.31053-1-mhocko@kernel.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 11, 2018 at 02:26:45PM +0100, Michal Hocko wrote: > From: Michal Hocko > > Liu Bo has experienced a deadlock between memcg (legacy) reclaim and the > ext4 writeback > task1: > [] wait_on_page_bit+0x82/0xa0 > [] shrink_page_list+0x907/0x960 > [] shrink_inactive_list+0x2c7/0x680 > [] shrink_node_memcg+0x404/0x830 > [] shrink_node+0xd8/0x300 > [] do_try_to_free_pages+0x10d/0x330 > [] try_to_free_mem_cgroup_pages+0xd5/0x1b0 > [] try_charge+0x14d/0x720 > [] memcg_kmem_charge_memcg+0x3c/0xa0 > [] memcg_kmem_charge+0x7e/0xd0 > [] __alloc_pages_nodemask+0x178/0x260 > [] alloc_pages_current+0x95/0x140 > [] pte_alloc_one+0x17/0x40 > [] __pte_alloc+0x1e/0x110 > [] alloc_set_pte+0x5fe/0xc20 > [] do_fault+0x103/0x970 > [] handle_mm_fault+0x61e/0xd10 > [] __do_page_fault+0x252/0x4d0 > [] do_page_fault+0x30/0x80 > [] page_fault+0x28/0x30 > [] 0xffffffffffffffff > > task2: > [] __lock_page+0x86/0xa0 > [] mpage_prepare_extent_to_map+0x2e7/0x310 [ext4] > [] ext4_writepages+0x479/0xd60 > [] do_writepages+0x1e/0x30 > [] __writeback_single_inode+0x45/0x320 > [] writeback_sb_inodes+0x272/0x600 > [] __writeback_inodes_wb+0x92/0xc0 > [] wb_writeback+0x268/0x300 > [] wb_workfn+0xb4/0x390 > [] process_one_work+0x189/0x420 > [] worker_thread+0x4e/0x4b0 > [] kthread+0xe6/0x100 > [] ret_from_fork+0x41/0x50 > [] 0xffffffffffffffff > > He adds > : task1 is waiting for the PageWriteback bit of the page that task2 has > : collected in mpd->io_submit->io_bio, and tasks2 is waiting for the LOCKED > : bit the page which tasks1 has locked. > > More precisely task1 is handling a page fault and it has a page locked > while it charges a new page table to a memcg. That in turn hits a memory > limit reclaim and the memcg reclaim for legacy controller is waiting on > the writeback but that is never going to finish because the writeback > itself is waiting for the page locked in the #PF path. So this is > essentially ABBA deadlock. Side node: Do we have PG_writeback vs. PG_locked ordering documentated somewhere? IIUC, the trace from task2 suggests that we must not wait for writeback on the locked page. But that not what I see for many wait_on_page_writeback() users: it usally called with the page locked. I see it for truncate, shmem, swapfile, splice... Maybe the problem is within task2 codepath after all? -- Kirill A. Shutemov