From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 056A537B03E for ; Mon, 8 Jun 2026 13:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780925393; cv=none; b=DPzIvNzAQyZvcmXPfZDlmS7h6zXuofMI6+YFzDfW9OAv3A9ZfUWK7tFXcERdaSJ1J+83SMp7pVSXaZYG8F109W5A0h3mrFwUqN72icSv4Bdt3FgITGhgOPyMb8UVEkdsgMZbXgFXeIMIyzphal6czFBnxezKbt3GaM63jovBf7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780925393; c=relaxed/simple; bh=c7M+hivlyg+F6v5Mi/L9hmuj5dSm1f0V79z/a0ReWCE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qTFZActNa1xdw+SLUCtUqg2Wk0cvgpv8a8O/8ABxvVEQ/2Xu9epJtuIkN+fbVBRaf8UgPgXBefTiUorESXUJMf66B17YWD1tYg9n0sp3u92ET5l5ZTRCRt9+75niVMASC96KOyYMEIH+qv7Tm8VnxvQyfk+gDmOmB238dq6as4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=NJc/kQxI; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="NJc/kQxI" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 974DF2403; Mon, 8 Jun 2026 06:29:46 -0700 (PDT) Received: from [10.164.19.15] (unknown [10.164.19.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8FE823F86F; Mon, 8 Jun 2026 06:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780925391; bh=c7M+hivlyg+F6v5Mi/L9hmuj5dSm1f0V79z/a0ReWCE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NJc/kQxIs4jkLrn/5fXdA0MXYh+Ww/rixpyzsiBMMa86Syzya8YxfMjSldU128au/ rPV8JVR17KkDyhaNCNLOr6QR2f5dQnk3QgZpeqawEIYja/rq0RzIpVyMeXgtY/6+Hi O5uv9VzrLBv8lkr6GQTQu3MFpS4JatWZkhqPOSeM= Message-ID: <903740a1-d48d-458e-8fa3-c129c68b5390@arm.com> Date: Mon, 8 Jun 2026 18:59:46 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [BUG?] invalidate_lock not held in read_cache_folio() To: Matthew Wilcox Cc: Jan Kara , "linux-mm@kvack.org" , David Hildenbrand , Ryan Roberts , LKML References: <5ca6512c-bdc1-4620-9c99-c7525e059099@arm.com> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 08/06/26 5:49 pm, Matthew Wilcox wrote: > On Mon, Jun 08, 2026 at 04:54:51PM +0530, Dev Jain wrote: >> Hi, >> >> My understanding is that there are two ways we are serializing against concurrent >> addition of a folio into the pagecache (see 730633f0b7f9). >> >> The kerneldoc of read_cache_folio() says: >> >> "Context: May sleep. Expects mapping->invalidate_lock to be held." >> >> I put the following in __filemap_add_folio(): >> >> + BUG_ON(!inode_is_locked(mapping->host) && >> + !rwsem_is_locked(&mapping->invalidate_lock)); >> >> >> And got the following trace: >> >> >> [ 0.115587] Call trace: >> [ 0.115686] __filemap_add_folio+0x5dc/0x680 (P) >> [ 0.115871] filemap_add_folio+0xec/0x2d0 >> [ 0.116031] do_read_cache_folio+0x144/0x2d8 >> [ 0.116194] read_cache_folio+0x1c/0x30 >> [ 0.116344] read_part_sector+0x4c/0xf0 >> [ 0.116499] read_lba+0xb0/0x1a0 >> [ 0.116627] efi_partition+0xa8/0x740 >> [ 0.116769] bdev_disk_changed+0x238/0x620 >> [ 0.116939] blkdev_get_whole+0xac/0x100 >> [ 0.117090] bdev_open+0x280/0x3c0 > > You can't truncate or holepunch a bdev Yep, I realized that later, thanks : ) Just that the kerneldoc says "Expects mapping->invalidate_lock to be held" so was wondering whether this comment is appropriate. Difficult for me to reason about that since this goes into fs/block code.