* [PATCH 1/5] mm: export bdi_unregister
2021-10-21 12:44 simplify bdi unregistation Christoph Hellwig
@ 2021-10-21 12:44 ` Christoph Hellwig
2021-10-22 8:41 ` Jan Kara
2021-10-21 12:44 ` [PATCH 2/5] mtd: call bdi_unregister explicitly Christoph Hellwig
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-21 12:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Jan Kara,
linux-mtd, linux-fsdevel, linux-mm
To wind down the magic auto-unregister semantics we'll need to push this
into modular code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/backing-dev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 4a9d4e27d0d9b..8a46a0a4b72fa 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -958,6 +958,7 @@ void bdi_unregister(struct backing_dev_info *bdi)
bdi->owner = NULL;
}
}
+EXPORT_SYMBOL(bdi_unregister);
static void release_bdi(struct kref *ref)
{
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/5] mm: export bdi_unregister
2021-10-21 12:44 ` [PATCH 1/5] mm: export bdi_unregister Christoph Hellwig
@ 2021-10-22 8:41 ` Jan Kara
0 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2021-10-22 8:41 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Jan Kara, linux-mtd, linux-fsdevel,
linux-mm
On Thu 21-10-21 14:44:37, Christoph Hellwig wrote:
> To wind down the magic auto-unregister semantics we'll need to push this
> into modular code.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> mm/backing-dev.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index 4a9d4e27d0d9b..8a46a0a4b72fa 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -958,6 +958,7 @@ void bdi_unregister(struct backing_dev_info *bdi)
> bdi->owner = NULL;
> }
> }
> +EXPORT_SYMBOL(bdi_unregister);
>
> static void release_bdi(struct kref *ref)
> {
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/5] mtd: call bdi_unregister explicitly
2021-10-21 12:44 simplify bdi unregistation Christoph Hellwig
2021-10-21 12:44 ` [PATCH 1/5] mm: export bdi_unregister Christoph Hellwig
@ 2021-10-21 12:44 ` Christoph Hellwig
2021-10-22 8:43 ` Jan Kara
2021-10-21 12:44 ` [PATCH 3/5] fs: explicitly unregister per-superblock BDIs Christoph Hellwig
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-21 12:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Jan Kara,
linux-mtd, linux-fsdevel, linux-mm
Call bdi_unregister explicitly instead of relying on the automatic
unregistration.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/mtd/mtdcore.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c8fd7f758938b..c904e23c82379 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -2409,6 +2409,7 @@ static void __exit cleanup_mtd(void)
if (proc_mtd)
remove_proc_entry("mtd", NULL);
class_unregister(&mtd_class);
+ bdi_unregister(mtd_bdi);
bdi_put(mtd_bdi);
idr_destroy(&mtd_idr);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/5] mtd: call bdi_unregister explicitly
2021-10-21 12:44 ` [PATCH 2/5] mtd: call bdi_unregister explicitly Christoph Hellwig
@ 2021-10-22 8:43 ` Jan Kara
0 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2021-10-22 8:43 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Jan Kara, linux-mtd, linux-fsdevel,
linux-mm
On Thu 21-10-21 14:44:38, Christoph Hellwig wrote:
> Call bdi_unregister explicitly instead of relying on the automatic
> unregistration.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> drivers/mtd/mtdcore.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index c8fd7f758938b..c904e23c82379 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -2409,6 +2409,7 @@ static void __exit cleanup_mtd(void)
> if (proc_mtd)
> remove_proc_entry("mtd", NULL);
> class_unregister(&mtd_class);
> + bdi_unregister(mtd_bdi);
> bdi_put(mtd_bdi);
> idr_destroy(&mtd_idr);
> }
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/5] fs: explicitly unregister per-superblock BDIs
2021-10-21 12:44 simplify bdi unregistation Christoph Hellwig
2021-10-21 12:44 ` [PATCH 1/5] mm: export bdi_unregister Christoph Hellwig
2021-10-21 12:44 ` [PATCH 2/5] mtd: call bdi_unregister explicitly Christoph Hellwig
@ 2021-10-21 12:44 ` Christoph Hellwig
2021-10-22 8:48 ` Jan Kara
2021-10-21 12:44 ` [PATCH 4/5] mm: don't automatically unregister bdis Christoph Hellwig
2021-10-21 12:44 ` [PATCH 5/5] mm: simplify bdi refcounting Christoph Hellwig
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-21 12:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Jan Kara,
linux-mtd, linux-fsdevel, linux-mm
Add a new SB_I_ flag to mark superblocks that have an ephemeral bdi
associated with them, an unregister it when the superblock is shut down.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/super.c | 3 +++
include/linux/fs.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/fs/super.c b/fs/super.c
index bcef3a6f4c4b5..3bfc0f8fbd5bc 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -476,6 +476,8 @@ void generic_shutdown_super(struct super_block *sb)
spin_unlock(&sb_lock);
up_write(&sb->s_umount);
if (sb->s_bdi != &noop_backing_dev_info) {
+ if (sb->s_iflags & SB_I_PERSB_BDI)
+ bdi_unregister(sb->s_bdi);
bdi_put(sb->s_bdi);
sb->s_bdi = &noop_backing_dev_info;
}
@@ -1562,6 +1564,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
}
WARN_ON(sb->s_bdi != &noop_backing_dev_info);
sb->s_bdi = bdi;
+ sb->s_iflags |= SB_I_PERSB_BDI;
return 0;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e7a633353fd20..226de651f52e6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1443,6 +1443,7 @@ extern int send_sigurg(struct fown_struct *fown);
#define SB_I_UNTRUSTED_MOUNTER 0x00000040
#define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */
+#define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */
/* Possible states of 'frozen' field */
enum {
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/5] fs: explicitly unregister per-superblock BDIs
2021-10-21 12:44 ` [PATCH 3/5] fs: explicitly unregister per-superblock BDIs Christoph Hellwig
@ 2021-10-22 8:48 ` Jan Kara
0 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2021-10-22 8:48 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Jan Kara, linux-mtd, linux-fsdevel,
linux-mm
On Thu 21-10-21 14:44:39, Christoph Hellwig wrote:
> Add a new SB_I_ flag to mark superblocks that have an ephemeral bdi
> associated with them, an unregister it when the superblock is shut down.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/super.c | 3 +++
> include/linux/fs.h | 1 +
> 2 files changed, 4 insertions(+)
>
> diff --git a/fs/super.c b/fs/super.c
> index bcef3a6f4c4b5..3bfc0f8fbd5bc 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -476,6 +476,8 @@ void generic_shutdown_super(struct super_block *sb)
> spin_unlock(&sb_lock);
> up_write(&sb->s_umount);
> if (sb->s_bdi != &noop_backing_dev_info) {
> + if (sb->s_iflags & SB_I_PERSB_BDI)
> + bdi_unregister(sb->s_bdi);
> bdi_put(sb->s_bdi);
> sb->s_bdi = &noop_backing_dev_info;
> }
> @@ -1562,6 +1564,7 @@ int super_setup_bdi_name(struct super_block *sb, char *fmt, ...)
> }
> WARN_ON(sb->s_bdi != &noop_backing_dev_info);
> sb->s_bdi = bdi;
> + sb->s_iflags |= SB_I_PERSB_BDI;
>
> return 0;
> }
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e7a633353fd20..226de651f52e6 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1443,6 +1443,7 @@ extern int send_sigurg(struct fown_struct *fown);
> #define SB_I_UNTRUSTED_MOUNTER 0x00000040
>
> #define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */
> +#define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */
>
> /* Possible states of 'frozen' field */
> enum {
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/5] mm: don't automatically unregister bdis
2021-10-21 12:44 simplify bdi unregistation Christoph Hellwig
` (2 preceding siblings ...)
2021-10-21 12:44 ` [PATCH 3/5] fs: explicitly unregister per-superblock BDIs Christoph Hellwig
@ 2021-10-21 12:44 ` Christoph Hellwig
2021-10-22 8:51 ` Jan Kara
2021-10-21 12:44 ` [PATCH 5/5] mm: simplify bdi refcounting Christoph Hellwig
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-21 12:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Jan Kara,
linux-mtd, linux-fsdevel, linux-mm
All BDI users now unregister explicitly.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/backing-dev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 8a46a0a4b72fa..768e9ae489f66 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -965,8 +965,7 @@ static void release_bdi(struct kref *ref)
struct backing_dev_info *bdi =
container_of(ref, struct backing_dev_info, refcnt);
- if (test_bit(WB_registered, &bdi->wb.state))
- bdi_unregister(bdi);
+ WARN_ON_ONCE(test_bit(WB_registered, &bdi->wb.state));
WARN_ON_ONCE(bdi->dev);
wb_exit(&bdi->wb);
kfree(bdi);
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/5] mm: don't automatically unregister bdis
2021-10-21 12:44 ` [PATCH 4/5] mm: don't automatically unregister bdis Christoph Hellwig
@ 2021-10-22 8:51 ` Jan Kara
0 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2021-10-22 8:51 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Jan Kara, linux-mtd, linux-fsdevel,
linux-mm
On Thu 21-10-21 14:44:40, Christoph Hellwig wrote:
> All BDI users now unregister explicitly.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> mm/backing-dev.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index 8a46a0a4b72fa..768e9ae489f66 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -965,8 +965,7 @@ static void release_bdi(struct kref *ref)
> struct backing_dev_info *bdi =
> container_of(ref, struct backing_dev_info, refcnt);
>
> - if (test_bit(WB_registered, &bdi->wb.state))
> - bdi_unregister(bdi);
> + WARN_ON_ONCE(test_bit(WB_registered, &bdi->wb.state));
> WARN_ON_ONCE(bdi->dev);
> wb_exit(&bdi->wb);
> kfree(bdi);
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 5/5] mm: simplify bdi refcounting
2021-10-21 12:44 simplify bdi unregistation Christoph Hellwig
` (3 preceding siblings ...)
2021-10-21 12:44 ` [PATCH 4/5] mm: don't automatically unregister bdis Christoph Hellwig
@ 2021-10-21 12:44 ` Christoph Hellwig
2021-10-22 9:02 ` Jan Kara
4 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-21 12:44 UTC (permalink / raw)
To: Andrew Morton
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Jan Kara,
linux-mtd, linux-fsdevel, linux-mm
Move grabbing and releasing the bdi refcount out of the common
wb_init/wb_exit helpers into code that is only used for the non-default
memcg driven bdi_writeback structures.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mm/backing-dev.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 768e9ae489f66..5ccb250898083 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -291,8 +291,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
memset(wb, 0, sizeof(*wb));
- if (wb != &bdi->wb)
- bdi_get(bdi);
wb->bdi = bdi;
wb->last_old_flush = jiffies;
INIT_LIST_HEAD(&wb->b_dirty);
@@ -316,7 +314,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
err = fprop_local_init_percpu(&wb->completions, gfp);
if (err)
- goto out_put_bdi;
+ return err;
for (i = 0; i < NR_WB_STAT_ITEMS; i++) {
err = percpu_counter_init(&wb->stat[i], 0, gfp);
@@ -330,9 +328,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
while (i--)
percpu_counter_destroy(&wb->stat[i]);
fprop_local_destroy_percpu(&wb->completions);
-out_put_bdi:
- if (wb != &bdi->wb)
- bdi_put(bdi);
return err;
}
@@ -373,8 +368,6 @@ static void wb_exit(struct bdi_writeback *wb)
percpu_counter_destroy(&wb->stat[i]);
fprop_local_destroy_percpu(&wb->completions);
- if (wb != &wb->bdi->wb)
- bdi_put(wb->bdi);
}
#ifdef CONFIG_CGROUP_WRITEBACK
@@ -397,6 +390,7 @@ static void cgwb_release_workfn(struct work_struct *work)
struct bdi_writeback *wb = container_of(work, struct bdi_writeback,
release_work);
struct blkcg *blkcg = css_to_blkcg(wb->blkcg_css);
+ struct backing_dev_info *bdi = wb->bdi;
mutex_lock(&wb->bdi->cgwb_release_mutex);
wb_shutdown(wb);
@@ -416,6 +410,7 @@ static void cgwb_release_workfn(struct work_struct *work)
percpu_ref_exit(&wb->refcnt);
wb_exit(wb);
+ bdi_put(bdi);
WARN_ON_ONCE(!list_empty(&wb->b_attached));
kfree_rcu(wb, rcu);
}
@@ -497,6 +492,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
INIT_LIST_HEAD(&wb->b_attached);
INIT_WORK(&wb->release_work, cgwb_release_workfn);
set_bit(WB_registered, &wb->state);
+ bdi_get(bdi);
/*
* The root wb determines the registered state of the whole bdi and
@@ -528,6 +524,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
goto out_put;
err_fprop_exit:
+ bdi_put(bdi);
fprop_local_destroy_percpu(&wb->memcg_completions);
err_ref_exit:
percpu_ref_exit(&wb->refcnt);
--
2.30.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 5/5] mm: simplify bdi refcounting
2021-10-21 12:44 ` [PATCH 5/5] mm: simplify bdi refcounting Christoph Hellwig
@ 2021-10-22 9:02 ` Jan Kara
2021-10-27 7:42 ` Christoph Hellwig
0 siblings, 1 reply; 13+ messages in thread
From: Jan Kara @ 2021-10-22 9:02 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Jan Kara, linux-mtd, linux-fsdevel,
linux-mm
On Thu 21-10-21 14:44:41, Christoph Hellwig wrote:
> Move grabbing and releasing the bdi refcount out of the common
> wb_init/wb_exit helpers into code that is only used for the non-default
> memcg driven bdi_writeback structures.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Can we perhaps add a comment to struct bdi_writeback definition (or maybe
wb_init()?) mentioning that it holds a reference to 'bdi' if it is
bdi_writeback struct for a cgroup? I don't see it mentioned anywhere and
now that you've changed the code, it isn't that obvious from the code
either... Otherwise the patch looks good so feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> mm/backing-dev.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index 768e9ae489f66..5ccb250898083 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -291,8 +291,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
>
> memset(wb, 0, sizeof(*wb));
>
> - if (wb != &bdi->wb)
> - bdi_get(bdi);
> wb->bdi = bdi;
> wb->last_old_flush = jiffies;
> INIT_LIST_HEAD(&wb->b_dirty);
> @@ -316,7 +314,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
>
> err = fprop_local_init_percpu(&wb->completions, gfp);
> if (err)
> - goto out_put_bdi;
> + return err;
>
> for (i = 0; i < NR_WB_STAT_ITEMS; i++) {
> err = percpu_counter_init(&wb->stat[i], 0, gfp);
> @@ -330,9 +328,6 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
> while (i--)
> percpu_counter_destroy(&wb->stat[i]);
> fprop_local_destroy_percpu(&wb->completions);
> -out_put_bdi:
> - if (wb != &bdi->wb)
> - bdi_put(bdi);
> return err;
> }
>
> @@ -373,8 +368,6 @@ static void wb_exit(struct bdi_writeback *wb)
> percpu_counter_destroy(&wb->stat[i]);
>
> fprop_local_destroy_percpu(&wb->completions);
> - if (wb != &wb->bdi->wb)
> - bdi_put(wb->bdi);
> }
>
> #ifdef CONFIG_CGROUP_WRITEBACK
> @@ -397,6 +390,7 @@ static void cgwb_release_workfn(struct work_struct *work)
> struct bdi_writeback *wb = container_of(work, struct bdi_writeback,
> release_work);
> struct blkcg *blkcg = css_to_blkcg(wb->blkcg_css);
> + struct backing_dev_info *bdi = wb->bdi;
>
> mutex_lock(&wb->bdi->cgwb_release_mutex);
> wb_shutdown(wb);
> @@ -416,6 +410,7 @@ static void cgwb_release_workfn(struct work_struct *work)
>
> percpu_ref_exit(&wb->refcnt);
> wb_exit(wb);
> + bdi_put(bdi);
> WARN_ON_ONCE(!list_empty(&wb->b_attached));
> kfree_rcu(wb, rcu);
> }
> @@ -497,6 +492,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
> INIT_LIST_HEAD(&wb->b_attached);
> INIT_WORK(&wb->release_work, cgwb_release_workfn);
> set_bit(WB_registered, &wb->state);
> + bdi_get(bdi);
>
> /*
> * The root wb determines the registered state of the whole bdi and
> @@ -528,6 +524,7 @@ static int cgwb_create(struct backing_dev_info *bdi,
> goto out_put;
>
> err_fprop_exit:
> + bdi_put(bdi);
> fprop_local_destroy_percpu(&wb->memcg_completions);
> err_ref_exit:
> percpu_ref_exit(&wb->refcnt);
> --
> 2.30.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 5/5] mm: simplify bdi refcounting
2021-10-22 9:02 ` Jan Kara
@ 2021-10-27 7:42 ` Christoph Hellwig
2021-10-27 9:47 ` Jan Kara
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-10-27 7:42 UTC (permalink / raw)
To: Jan Kara
Cc: Christoph Hellwig, Andrew Morton, Miquel Raynal,
Richard Weinberger, Vignesh Raghavendra, linux-mtd,
linux-fsdevel, linux-mm
On Fri, Oct 22, 2021 at 11:02:03AM +0200, Jan Kara wrote:
> On Thu 21-10-21 14:44:41, Christoph Hellwig wrote:
> > Move grabbing and releasing the bdi refcount out of the common
> > wb_init/wb_exit helpers into code that is only used for the non-default
> > memcg driven bdi_writeback structures.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Can we perhaps add a comment to struct bdi_writeback definition (or maybe
> wb_init()?) mentioning that it holds a reference to 'bdi' if it is
> bdi_writeback struct for a cgroup? I don't see it mentioned anywhere and
> now that you've changed the code, it isn't that obvious from the code
> either... Otherwise the patch looks good so feel free to add:
Like this?
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
index 33207004cfded..a3d7dd1cc30a1 100644
--- a/include/linux/backing-dev-defs.h
+++ b/include/linux/backing-dev-defs.h
@@ -103,6 +103,9 @@ struct wb_completion {
* change as blkcg is disabled and enabled higher up in the hierarchy, a wb
* is tested for blkcg after lookup and removed from index on mismatch so
* that a new wb for the combination can be created.
+ *
+ * Each bdi_writeback that is no embedded into the backing_dev_info must hold
+ * a reference to the parent backing_dev_info. See cgwb_create() for details.
*/
struct bdi_writeback {
struct backing_dev_info *bdi; /* our parent bdi */
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 5/5] mm: simplify bdi refcounting
2021-10-27 7:42 ` Christoph Hellwig
@ 2021-10-27 9:47 ` Jan Kara
0 siblings, 0 replies; 13+ messages in thread
From: Jan Kara @ 2021-10-27 9:47 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Jan Kara, Andrew Morton, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, linux-mtd, linux-fsdevel, linux-mm
On Wed 27-10-21 09:42:07, Christoph Hellwig wrote:
> On Fri, Oct 22, 2021 at 11:02:03AM +0200, Jan Kara wrote:
> > On Thu 21-10-21 14:44:41, Christoph Hellwig wrote:
> > > Move grabbing and releasing the bdi refcount out of the common
> > > wb_init/wb_exit helpers into code that is only used for the non-default
> > > memcg driven bdi_writeback structures.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > Can we perhaps add a comment to struct bdi_writeback definition (or maybe
> > wb_init()?) mentioning that it holds a reference to 'bdi' if it is
> > bdi_writeback struct for a cgroup? I don't see it mentioned anywhere and
> > now that you've changed the code, it isn't that obvious from the code
> > either... Otherwise the patch looks good so feel free to add:
>
> Like this?
>
> diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h
> index 33207004cfded..a3d7dd1cc30a1 100644
> --- a/include/linux/backing-dev-defs.h
> +++ b/include/linux/backing-dev-defs.h
> @@ -103,6 +103,9 @@ struct wb_completion {
> * change as blkcg is disabled and enabled higher up in the hierarchy, a wb
> * is tested for blkcg after lookup and removed from index on mismatch so
> * that a new wb for the combination can be created.
> + *
> + * Each bdi_writeback that is no embedded into the backing_dev_info must hold
^^^ not
> + * a reference to the parent backing_dev_info. See cgwb_create() for details.
> */
Otherwise looks nice. Thanks!
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 13+ messages in thread