public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Wang Yugui <wangyugui@e16-tech.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: slience the sparse warn of rcu_string
Date: Mon, 5 Sep 2022 17:34:59 +0200	[thread overview]
Message-ID: <20220905153459.GI13489@twin.jikos.cz> (raw)
In-Reply-To: <20220905115726.6C63.409509F4@e16-tech.com>

On Mon, Sep 05, 2022 at 11:57:26AM +0800, Wang Yugui wrote:
> Hi,
> 
> > slience the sparse warn of rcu_string reported by 'make C=1'
> > 
> > warning example:
> > fs/btrfs/volumes.c:2300:41: warning: incorrect type in argument 3 (different address spaces)
> > fs/btrfs/volumes.c:2300:41:    expected char const *device_path
> > fs/btrfs/volumes.c:2300:41:    got char [noderef] __rcu *
> 
> I'm sorry that some new WARNING is triggered when 
> lockdep(CONFIG_PROVE_LOCKING/...) check is enabled.
> 
> [  112.742722] =============================
> [  112.746835] WARNING: suspicious RCU usage
> [  112.750917] 6.0.0-4.0.el7.x86_64 #1 Not tainted
> [  112.755540] -----------------------------
> [  112.759624] fs/btrfs/volumes.c:918 suspicious rcu_dereference_check() usage!
> [  112.766776] 
>                other info that might help us debug this:
> 
> [  112.774921] 
>                rcu_scheduler_active = 2, debug_locks = 1
> [  112.781566] 2 locks held by mount/1725:
> [  112.785471]  #0: ffffffffc50592a8 (uuid_mutex){+.+.}-{3:3}, at: btrfs_mount_root+0xfe/0x520 [btrfs]
> [  112.794763]  #1: ffffa1147bf068e0 (&fs_devs->device_list_mutex){+.+.}-{3:3}, at: device_list_add+0x28d/0x830 [btrfs]
> 
> 
> The fix is yet not clear,  we may need rcu_read_lock() just like
> 3181faa85bda3dc3f5e630a1846526c9caaa38e3 (cfq-iosched: fix a rcu warning)

There are probably more instances that would need the rcu lock/unlock,
eg. in btrfs_open_one_device, btrfs_dev_replace_finishing,
btrfs_destroy_dev_replace_tgtdev, btrfs_rm_device, clone_fs_devices,
device_list_add, btrfs_open_one_device where the dereference is done in
parameter list.

There's one dereference in the message helpers but not using the _in_rcu
variant:

zoned.c:
1403                 case BLK_ZONE_COND_READONLY:
1404                         btrfs_err(fs_info,
1405                 "zoned: offline/readonly zone %llu on device %s (devid %llu)",
1406                                   physical[i] >> device->zone_info->zone_size_shift,
1407                                   rcu_str_deref(device->name), device->devid);

We can keep the the patch in for-next and add the missing annotations as
they appear, updating the patch so it may take some time but we'll fix
all the warnings eventually.

      reply	other threads:[~2022-09-05 15:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24  5:12 [PATCH v2] btrfs: slience the sparse warn of rcu_string Wang Yugui
2022-08-24  7:25 ` Anand Jain
2022-09-02 13:55 ` David Sterba
2022-09-05  3:57 ` Wang Yugui
2022-09-05 15:34   ` David Sterba [this message]

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=20220905153459.GI13489@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangyugui@e16-tech.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