Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp39329pxf; Tue, 30 Mar 2021 18:33:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTzEXb4Yme0/svNzy7dSUQehDHJyUUMeFOlnGsqTnQAzmAEYzBj6CWTlYkOcxZE5tV9dew X-Received: by 2002:a05:6402:35cd:: with SMTP id z13mr745022edc.21.1617154383380; Tue, 30 Mar 2021 18:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617154383; cv=none; d=google.com; s=arc-20160816; b=GVh3zXDoyXSBCPHbHPj1TbIbyYjKY940zsiKtJGRkcHYKUxA/jxpvkT1GPldhVj7km pMJZA7UI498h9EfWkfvVRzWJHoN0OUhI8d0KkVotzfSNPP/h5OviNfU536gmw8E36zg3 zruLGreYOuwt8XQzRoCi0RMHyNnvezPL0nZkVSAbKMZ7Ex/WfQnw015IZLi+8wH3qER4 LRgrh+XAkozOd7z/WHrIOozvls4lxH9g5Bbt4TpQ8e7isKI1l2cwfmPbf5ykMRFWij87 hf1aVH2y+PrPG9Tid6N6O4BPlXanvKXsHDIbXmEbCsbO3gPk/6MTkuT7Uihuy38Hs8YV 6cxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:subject:cc:to :from:date:dkim-signature; bh=KQ4UhoRuOYIePIQ52r8+aVrhFWUe79SfbbimcSIL+Nc=; b=m8xEWdN2ZE6yS/pd8XeeK1vejuRifz7GfLBnVIWDco3/pMaqsdUhVBuWCqzNnYAJl8 K6M94/EHNKQJpFeJUo/Q9ed4GU+XNguktLCVFgP8SDh+iIHFTAMGUUwdlOwXp3BczOsN vp/Ws9+sJL6mBc9obRbw+wsqrDaDavAOIGgZnDB6kVJcbyJZyU7lh9T7ANXvMg50rE6F YD7IIq1b3ftCuuiUzkvCJNDtpa7zF6/m0V6a4tO6j43wcahXNZxAISlKsxqL47CGKsmB xLRS62ZP/ZtwIoxw1wbHGLTB/Vv6VFMKrubZZ2IamY2pIcFjzzxkhChjb6Vn4kN82/0c 6ZoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lQx2TYvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si513684edn.433.2021.03.30.18.32.14; Tue, 30 Mar 2021 18:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lQx2TYvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232859AbhCaBbK (ORCPT + 99 others); Tue, 30 Mar 2021 21:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhCaBaw (ORCPT ); Tue, 30 Mar 2021 21:30:52 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A831C061574 for ; Tue, 30 Mar 2021 18:30:52 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id a8so18429038oic.11 for ; Tue, 30 Mar 2021 18:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=KQ4UhoRuOYIePIQ52r8+aVrhFWUe79SfbbimcSIL+Nc=; b=lQx2TYvo3z4/Y4K/aqMjcHcRs6Wma0Bb6oKkFH9AIxVw34/QBkIzCjYOs0bfDw9izS j1yelFrahfno18c3R6rrJk6pF/aghxdTt32ikGRWmoIeGuL1FnH3bw88C0HBHj3J2wvI TgIVA8/qZhNr9ivGIfA0FP4+jByBTuc+2bJFmHQXY3YO5ZJ3u4Lcob2X4H0T/y+BqOgg F7pFfydHBC4to4A5RcWZYzWCIelEUmAD45atU/J84syxq3vRvFaUZ4ydNwKEJMWxYA8M T9fIxBg84kK59o8yCDeArwA9HIijk+I9//OcqphHVpWlrHFh4StWLqFZScfmE86NpUVB +rgQ== 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:user-agent :mime-version; bh=KQ4UhoRuOYIePIQ52r8+aVrhFWUe79SfbbimcSIL+Nc=; b=SgUEV8rhMwwic55LK0D4bdj6dLJXD3aSORAMVzu2/gY0tTbVWhebsnkxlkDfcVTglk EDxYzNCJ2HUY/vRbnfVcBhTVQ2Db7L6al5xb5Fb5dT2lPk4o/q6Y1/0sdM4RG8PzsbKw WyTJZbABBqaBVJ9mv3CI7W3k0GRhBSXWCp1m6tv2ZmabUsZr/OFE7I/gwKfKVse/bQHF SbKedRRfcqr6gyQ+NSxEuZOab9kvf4VJj+HPTG4wSw/gOoGLykeoHFxFuLTbRvAKuWzs NZ9mu5WBt25ECZEo6y2dWhtahHAAeWeyHpQ712jyJF6Y6QasPmFObwydpJGyCUybOrSY P7pQ== X-Gm-Message-State: AOAM532CodITQ7V03RltGx2YIUWT3SfRzmF4P+KEWeltWj01PdqgAQgw e9sSjNRJc7nkjFHOuwWzGF7J5w== X-Received: by 2002:a05:6808:5cb:: with SMTP id d11mr502740oij.169.1617154251409; Tue, 30 Mar 2021 18:30:51 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id g11sm141653ots.34.2021.03.30.18.30.50 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 30 Mar 2021 18:30:51 -0700 (PDT) Date: Tue, 30 Mar 2021 18:30:22 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Matthew Wilcox cc: Andrew Morton , Hugh Dickins , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: BUG_ON(!mapping_empty(&inode->i_data)) Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running my usual tmpfs kernel builds swapping load, on Sunday's rc4-mm1 mmotm (I never got to try rc3-mm1 but presume it behaved the same way), I hit clear_inode()'s BUG_ON(!mapping_empty(&inode->i_data)); on two machines, within an hour or few, repeatably though not to order. The stack backtrace has always been clear_inode < ext4_clear_inode < ext4_evict_inode < evict < dispose_list < prune_icache_sb < super_cache_scan < do_shrink_slab < shrink_slab_memcg < shrink_slab < shrink_node_memgs < shrink_node < balance_pgdat < kswapd. ext4 is the disk filesystem I read the source to build from, and also the filesystem I use on a loop device on a tmpfs file: I have not tried with other filesystems, nor checked whether perhaps it happens always on the loop one or always on the disk one. I have not seen it happen with tmpfs - probably because its inodes cannot be evicted by the shrinker anyway; I have not seen it happen when "rm -rf" evicts ext4 or tmpfs inodes (but suspect that may be down to timing, or less pressure). I doubt it's a matter of filesystem: think it's an XArray thing. Whenever I've looked at the XArray nodes involved, the root node (shift 6) contained one or three (adjacent) pointers to empty shift 0 nodes, which each had offset and parent and array correctly set. Is there some way in which empty nodes can get left behind, and so fail eviction's mapping_empty() check? I did wonder whether some might get left behind if xas_alloc() fails (though probably the tree here is too shallow to show that). Printks showed that occasionally xas_alloc() did fail while testing (maybe at memcg limit), but there was no correlation with the BUG_ONs. I did wonder whether this is a long-standing issue, which your new BUG_ON is the first to detect: so tried 5.12-rc5 clear_inode() with a BUG_ON(!xa_empty(&inode->i_data.i_pages)) after its nrpages and nrexceptional BUG_ONs. The result there surprised me: I expected it to behave the same way, but it hits that BUG_ON in a minute or so, instead of an hour or so. Was there a fix you made somewhere, to avoid the BUG_ON(!mapping_empty) most of the time? but needs more work. I looked around a little, but didn't find any. I had hoped to work this out myself, and save us both some writing: but better hand over to you, in the hope that you'll quickly guess what's up, then I can try patches. I do like the no-nrexceptionals series, but there's something still to be fixed. Hugh