linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	max.byungchul.park@sk.com, byungchul@sk.com,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Subject: Re: Possible circular dependency between i_data_sem and folio lock in ext4 filesystem
Date: Thu, 11 Jul 2024 11:38:46 -0400	[thread overview]
Message-ID: <20240711153846.GG10452@mit.edu> (raw)
In-Reply-To: <CAB=+i9SmrqEEqQp+AQvv+O=toO9x0mPam+b1KuNT+CgK0J1JDQ@mail.gmail.com>

On Thu, Jul 11, 2024 at 09:07:53PM +0900, Hyeonggon Yoo wrote:
> Hi folks,
> 
> Byungchul, Gwan-gyeong and I are investigating possible circular
> dependency reported by a dependency tracker named DEPT [1], which is
> able to report possible circular dependencies involving folio locks
> and other forms of dependencies that are not locks (i.e., wait for
> completion).
> 
> Below are two similar reports from DEPT where one context takes
> i_data_sem and then folio lock in ext4_map_blocks(), while the other
> context takes folio lock and then i_data_sem during processing of
> pwrite64() system calls. We're reaching out due to a lack of
> understanding of ext4 and file system internals.
> 
> The points in question are:
> 
> - Can the two contexts actually create a dependency between each other
> in ext4? In other words, do their uses of folio lock make them belong
> to the same lock classes?

No.

> - Are there any locking rules in ext4 that ensure these two contexts
> will never be considered as the same lock class?

It's inherent is the code path.  In one of the stack traces, we are
using the page cache for the bitmap allocation block (in other words, a metadata
block).  In the other stack trace, the page cache belongs to a regular
file (in other words, a data block).

So this is a false positive with DEPT, which has always been one of
the reasons why I've been dubious about the value of DEPT in terms of
potential for make-work for mantainer once automated systems like
syzbot try to blindly use and it results in huge numbers of false
positive reports that we then have to work through as an unfunded
mandate.

If you want to add lock annotations into the struct page or even
struct folio, I cordially invite you to try running that by the mm
developers, who will probably tell you why that is a terrible idea
since it bloats a critical data structure.

Cheers,

					- Ted

  reply	other threads:[~2024-07-11 15:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-11 12:07 Possible circular dependency between i_data_sem and folio lock in ext4 filesystem Hyeonggon Yoo
2024-07-11 15:38 ` Theodore Ts'o [this message]
2024-07-12  4:44   ` Byungchul Park
2024-07-12  5:31     ` Byungchul Park
2024-07-12 21:23       ` Vlastimil Babka (SUSE)
2024-07-15 10:32         ` Byungchul Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240711153846.GG10452@mit.edu \
    --to=tytso@mit.edu \
    --cc=42.hyeyoo@gmail.com \
    --cc=byungchul@sk.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=max.byungchul.park@sk.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).