From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66CDDC433DB for ; Wed, 31 Mar 2021 01:30:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C6594619D3 for ; Wed, 31 Mar 2021 01:30:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6594619D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 24CCB6B007E; Tue, 30 Mar 2021 21:30:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D73F6B0081; Tue, 30 Mar 2021 21:30:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 029356B0082; Tue, 30 Mar 2021 21:30:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id D9D916B007E for ; Tue, 30 Mar 2021 21:30:52 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9FB1952B7 for ; Wed, 31 Mar 2021 01:30:52 +0000 (UTC) X-FDA: 77978440344.25.0C70ED8 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) by imf24.hostedemail.com (Postfix) with ESMTP id 40320A0000FA for ; Wed, 31 Mar 2021 01:30:51 +0000 (UTC) Received: by mail-oi1-f182.google.com with SMTP id n8so18430976oie.10 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=GkxfnwYy7ZZAONt4BDo5FgsGypkctjeWA7vPXXx+GgaMpgLOF7M/iQj2rbWZmVmP2g NHAzbNYRTT2KMSM1GaprAfEtdy6rh4PYWNiOUdb72amFe3LUIpQtZYluE9WjWNdUjz0B DaGPozc9JMoFJMoTUJS3hdfkcXUFZHHFrGh7aA1k6PeNe4/oQkTQWIrWtV7Sw8hYg4/U RTyzUdW5Vz9byjbN9EXPKsKLWpjAg6INv3RNwBvzC8NeXve8QC4jsm/tcPxT/3RUe2Hd VTUW8EVjF/tR/UeMZYKKoo4TX2PCS+u4iCRgGYvu9A+k4AwzCPs5Vx3iBfeMWFeV+Exb IjGw== X-Gm-Message-State: AOAM533/Rhprv3RgUJ5qot62GH6P19Gr9XPI6ndCer9HrhMeE1a3A3+f 75Vl4kJ6G6amsVyiCcFfG4GqKw== X-Google-Smtp-Source: ABdhPJzgATn5d/xGPP8lN0hUfrUaP2MzX9O5uWPP80RgZEGYBVqB4ER4X7Jo2RE+R3sVH8Ekz00hSQ== 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 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 40320A0000FA X-Stat-Signature: jp1y7fbg5owpxjckefhcc5o9oa7aoqz4 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail-oi1-f182.google.com; client-ip=209.85.167.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617154251-61122 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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