From: Ian Kent <raven@themaw.net>
To: Arnd Bergmann <arnd@arndb.de>,
Anders Roxell <anders.roxell@linaro.org>,
Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Minchan Kim <minchan@kernel.org>,
Eric Sandeen <sandeen@sandeen.net>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Rick Lindsley <ricklind@linux.vnet.ibm.com>,
David Howells <dhowells@redhat.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Carlos Maiolino <cmaiolino@redhat.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
elver@google.com
Subject: Re: [PATCH 1/2] kernfs: dont take i_lock on inode attr read
Date: Thu, 29 Dec 2022 21:07:04 +0800 [thread overview]
Message-ID: <9e35cf66-79ef-1f13-dc6b-b013c73a9fc6@themaw.net> (raw)
In-Reply-To: <e25ee08c-7692-4042-9961-a499600f0a49@app.fastmail.com>
On 29/12/22 17:20, Arnd Bergmann wrote:
> On Fri, Dec 23, 2022, at 00:11, Ian Kent wrote:
>> On 21/12/22 21:34, Anders Roxell wrote:
>>> On 2022-10-31 12:30, Tejun Heo wrote:
>>>> On Tue, Oct 18, 2022 at 10:32:42AM +0800, Ian Kent wrote:
>>>>> The kernfs write lock is held when the kernfs node inode attributes
>>>>> are updated. Therefore, when either kernfs_iop_getattr() or
>>>>> kernfs_iop_permission() are called the kernfs node inode attributes
>>>>> won't change.
>>>>>
>>>>> Consequently concurrent kernfs_refresh_inode() calls always copy the
>>>>> same values from the kernfs node.
>>>>>
>>>>> So there's no need to take the inode i_lock to get consistent values
>>>>> for generic_fillattr() and generic_permission(), the kernfs read lock
>>>>> is sufficient.
>>>>>
>>>>> Signed-off-by: Ian Kent <raven@themaw.net>
>>>> Acked-by: Tejun Heo <tj@kernel.org>
>>> Hi,
>>>
>>> Building an allmodconfig arm64 kernel on yesterdays next-20221220 and
>>> booting that in qemu I see the following "BUG: KCSAN: data-race in
>>> set_nlink / set_nlink".
>>
>> I'll check if I missed any places where set_link() could be
>> called where the link count could be different.
>>
>>
>> If there aren't any the question will then be can writing the
>> same value to this location in multiple concurrent threads
>> corrupt it?
> I think the race that is getting reported for set_nlink()
> is about this bit getting called simulatenously on multiple
> CPUs with only the read lock held for the inode:
>
> /* Yes, some filesystems do change nlink from zero to one */
> if (inode->i_nlink == 0)
> atomic_long_dec(&inode->i_sb->s_remove_count);
> inode->__i_nlink = nlink;
>
> Since i_nlink and __i_nlink refer to the same memory location,
> the 'inode->i_nlink == 0' check can be true for all of them
> before the nonzero nlink value gets set, and this results in
> s_remove_count being decremented more than once.
Thanks for the comment Arnd.
I'll certainly have a close look at that.
It will be a little while though, given the season, ;).
Ian
next prev parent reply other threads:[~2022-12-29 13:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 2:32 [PATCH 0/2] kernfs: remove i_lock usage that isn't needed Ian Kent
2022-10-18 2:32 ` [PATCH 1/2] kernfs: dont take i_lock on inode attr read Ian Kent
2022-10-24 8:50 ` Miklos Szeredi
2022-10-31 22:30 ` Tejun Heo
2022-12-21 13:34 ` Anders Roxell
2022-12-22 23:11 ` Ian Kent
2022-12-29 9:20 ` Arnd Bergmann
2022-12-29 13:07 ` Ian Kent [this message]
2023-01-23 3:11 ` Ian Kent
2023-07-18 19:00 ` Anders Roxell
2023-07-19 4:23 ` Ian Kent
2023-07-20 2:03 ` Ian Kent
2023-07-26 13:49 ` Miklos Szeredi
2023-07-27 0:38 ` Ian Kent
2023-07-27 4:30 ` Imran Khan
2023-07-27 5:35 ` Imran Khan
2023-07-28 0:00 ` Ian Kent
2023-07-28 0:16 ` Ian Kent
2023-07-28 1:06 ` Imran Khan
2023-07-28 1:29 ` Ian Kent
2022-10-18 2:32 ` [PATCH 2/2] kernfs: dont take i_lock on revalidate Ian Kent
2022-10-24 8:38 ` Miklos Szeredi
2022-10-31 22:31 ` Tejun Heo
2022-11-01 7:46 ` Amir Goldstein
2022-11-01 8:09 ` Ian Kent
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=9e35cf66-79ef-1f13-dc6b-b013c73a9fc6@themaw.net \
--to=raven@themaw.net \
--cc=anders.roxell@linaro.org \
--cc=arnd@arndb.de \
--cc=cmaiolino@redhat.com \
--cc=dhowells@redhat.com \
--cc=elver@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=minchan@kernel.org \
--cc=ricklind@linux.vnet.ibm.com \
--cc=sandeen@sandeen.net \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®