diff options
| author | Song Liu <song@kernel.org> | 2023-11-28 02:49:57 +0300 | 
|---|---|---|
| committer | Song Liu <song@kernel.org> | 2023-11-28 06:45:33 +0300 | 
| commit | 726a9b67e9fb9a8e5c955b3d7d591becb23c47ee (patch) | |
| tree | 188da79cbd2529f2ca80abd84c5c5dfdc13d1fb2 /tools/perf/scripts/python/syscall-counts-by-pid.py | |
| parent | bed9e27baf52a09b7ba2a3714f1e24e17ced386d (diff) | |
| parent | 7ecab28c3b2c26c1a51154d997433e8432eb49ba (diff) | |
| download | linux-726a9b67e9fb9a8e5c955b3d7d591becb23c47ee.tar.xz | |
Merge branch 'md-next-rcu-cleanup' into md-next
From Yu Kuai:
md: remove rcu protection to access rdev from conf
The lifetime of rdev:
1. md_import_device() generate a rdev based on underlying disk;
   mddev_lock()
   rdev = kzalloc();
   rdev->bdev = blkdev_get_by_dev();
   mddev_unlock()
2. bind_rdev_to_array() add this rdev to mddev->disks;
   mddev_lock()
   kobject_add(&rdev->kobj, &mddev->kobj, ...);
   list_add_rcu(&rdev->same_set, &mddev->disks);
   mddev_unlock()
3. remove_and_add_spares() add this rdev to conf;
   mddev_lock()
   rdev_addable();
   pers->hot_add_disk();
   rcu_assign_pointer(conf->rdev, rdev);
   mddev_unlock()
4. Use this array with rdev;
5. remove_and_add_spares() remove rdev from conf;
   // triggered by sysfs/ioctl
   mddev_lock()
   rdev_removeable();
   pers->hot_remove_disk();
    rcu_assign_pointer(conf->rdev, NULL);
    synchronize_rcu();
   mddev_unlock()
   // triggered by daemon
   mddev_lock()
   rdev_removeable();
   synchronize_rcu(); -> this can't protect accessing rdev from conf
   pers->hot_remove_disk();
    rcu_assign_pointer(conf->rdev, NULL);
   mddev_unlock()
6. md_kick_rdev_from_array() remove rdev from mddev->disks;
   mddev_lock()
   list_del_rcu(&rdev->same_set);
   synchronize_rcu();
   list_add(&rdev->same_set, &mddev->deleting)
   mddev_unlock()
    export_rdev
There are two separate rcu protection for rdev, and this pathset remove
the protection of conf(step 3 and 5), because it's safe to access rdev
from conf in following cases:
 - If 'reconfig_mutex' is held, because rdev can't be added or rmoved to
 conf;
 - If there is normal IO inflight, because mddev_suspend() will wait for
 IO to be done and prevent rdev to be added or removed to conf;
 - If sync thread is running, because remove_and_add_spares() can only be
 called from daemon thread when sync thread is done, and
 'MD_RECOVERY_RUNNING' is also checked for ioctl/sysfs;
 - if any spinlock or rcu_read_lock() is held, because synchronize_rcu()
 from step 6 prevent rdev to be freed until spinlock is released or
 rcu_read_unlock();
Diffstat (limited to 'tools/perf/scripts/python/syscall-counts-by-pid.py')
0 files changed, 0 insertions, 0 deletions
