All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-crypt: make workqueue names device-specific
@ 2018-10-09 19:27 Michał Mirosław
  2018-10-09 19:36 ` [PATCH 1/2] dm: add dm_table_device_name() Michał Mirosław
  0 siblings, 1 reply; 7+ messages in thread
From: Michał Mirosław @ 2018-10-09 19:27 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer; +Cc: dm-devel

Make cpu-usage debugging easier by naming workqueues per device.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---

 * Against v4.19-rc4

---
 drivers/md/dm-crypt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0481223b1deb..b5eda64d3840 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2661,6 +2661,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
 static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
 	struct crypt_config *cc;
+	const char *devname = dm_table_device_name(ti->table);
 	int key_size;
 	unsigned int align_mask;
 	unsigned long long tmpll;
@@ -2806,18 +2807,22 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	}
 
 	ret = -ENOMEM;
-	cc->io_queue = alloc_workqueue("kcryptd_io", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+	cc->io_queue = alloc_workqueue("kcryptd_io/%s",
+				       WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+				       1, devname);
 	if (!cc->io_queue) {
 		ti->error = "Couldn't create kcryptd io queue";
 		goto bad;
 	}
 
 	if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags))
-		cc->crypt_queue = alloc_workqueue("kcryptd", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
+						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+						  1, devname);
 	else
-		cc->crypt_queue = alloc_workqueue("kcryptd",
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
 						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM | WQ_UNBOUND,
-						  num_online_cpus());
+						  num_online_cpus(), devname);
 	if (!cc->crypt_queue) {
 		ti->error = "Couldn't create kcryptd queue";
 		goto bad;
@@ -2826,7 +2831,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	spin_lock_init(&cc->write_thread_lock);
 	cc->write_tree = RB_ROOT;
 
-	cc->write_thread = kthread_create(dmcrypt_write, cc, "dmcrypt_write");
+	cc->write_thread = kthread_create(dmcrypt_write, cc,
+					  "dmcrypt_write/%s", devname);
 	if (IS_ERR(cc->write_thread)) {
 		ret = PTR_ERR(cc->write_thread);
 		cc->write_thread = NULL;
-- 
2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 1/2] dm: add dm_table_device_name()
  2018-10-09 19:27 [PATCH] dm-crypt: make workqueue names device-specific Michał Mirosław
@ 2018-10-09 19:36 ` Michał Mirosław
  2018-10-09 19:36   ` [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific Michał Mirosław
  2018-10-09 19:39   ` [PATCH 1/2] dm: add dm_table_device_name() Mike Snitzer
  0 siblings, 2 replies; 7+ messages in thread
From: Michał Mirosław @ 2018-10-09 19:36 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer; +Cc: dm-devel

Add a shortcut for dm_device_name(dm_table_get_md(t)).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/md/dm-table.c         | 6 ++++++
 include/linux/device-mapper.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 3d0e2c198f06..1f4ab9c8b9a8 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -2079,6 +2079,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
 }
 EXPORT_SYMBOL(dm_table_get_md);
 
+const char *dm_table_device_name(struct dm_table *t)
+{
+	return dm_device_name(t->md);
+}
+EXPORT_SYMBOL(dm_table_device_name);
+
 void dm_table_run_md_queue_async(struct dm_table *t)
 {
 	struct mapped_device *md;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 6fb0808e87c8..0d63f7e5261c 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -490,6 +490,7 @@ sector_t dm_table_get_size(struct dm_table *t);
 unsigned int dm_table_get_num_targets(struct dm_table *t);
 fmode_t dm_table_get_mode(struct dm_table *t);
 struct mapped_device *dm_table_get_md(struct dm_table *t);
+const char *dm_table_device_name(struct dm_table *t);
 
 /*
  * Trigger an event.
-- 
2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific
  2018-10-09 19:36 ` [PATCH 1/2] dm: add dm_table_device_name() Michał Mirosław
@ 2018-10-09 19:36   ` Michał Mirosław
  2018-10-09 19:42     ` Mike Snitzer
  2018-10-09 19:39   ` [PATCH 1/2] dm: add dm_table_device_name() Mike Snitzer
  1 sibling, 1 reply; 7+ messages in thread
From: Michał Mirosław @ 2018-10-09 19:36 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer; +Cc: dm-devel

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---

v2:
  - include dependency: dm_table_device_name() patch

---
 drivers/md/dm-crypt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0481223b1deb..b5eda64d3840 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2661,6 +2661,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
 static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
 	struct crypt_config *cc;
+	const char *devname = dm_table_device_name(ti->table);
 	int key_size;
 	unsigned int align_mask;
 	unsigned long long tmpll;
@@ -2806,18 +2807,22 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	}
 
 	ret = -ENOMEM;
-	cc->io_queue = alloc_workqueue("kcryptd_io", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+	cc->io_queue = alloc_workqueue("kcryptd_io/%s",
+				       WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+				       1, devname);
 	if (!cc->io_queue) {
 		ti->error = "Couldn't create kcryptd io queue";
 		goto bad;
 	}
 
 	if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags))
-		cc->crypt_queue = alloc_workqueue("kcryptd", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
+						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+						  1, devname);
 	else
-		cc->crypt_queue = alloc_workqueue("kcryptd",
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
 						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM | WQ_UNBOUND,
-						  num_online_cpus());
+						  num_online_cpus(), devname);
 	if (!cc->crypt_queue) {
 		ti->error = "Couldn't create kcryptd queue";
 		goto bad;
@@ -2826,7 +2831,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	spin_lock_init(&cc->write_thread_lock);
 	cc->write_tree = RB_ROOT;
 
-	cc->write_thread = kthread_create(dmcrypt_write, cc, "dmcrypt_write");
+	cc->write_thread = kthread_create(dmcrypt_write, cc,
+					  "dmcrypt_write/%s", devname);
 	if (IS_ERR(cc->write_thread)) {
 		ret = PTR_ERR(cc->write_thread);
 		cc->write_thread = NULL;
-- 
2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] dm: add dm_table_device_name()
  2018-10-09 19:36 ` [PATCH 1/2] dm: add dm_table_device_name() Michał Mirosław
  2018-10-09 19:36   ` [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific Michał Mirosław
@ 2018-10-09 19:39   ` Mike Snitzer
  1 sibling, 0 replies; 7+ messages in thread
From: Mike Snitzer @ 2018-10-09 19:39 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: dm-devel, Alasdair Kergon

On Tue, Oct 09 2018 at  3:36pm -0400,
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:

> Add a shortcut for dm_device_name(dm_table_get_md(t)).
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/md/dm-table.c         | 6 ++++++
>  include/linux/device-mapper.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 3d0e2c198f06..1f4ab9c8b9a8 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -2079,6 +2079,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
>  }
>  EXPORT_SYMBOL(dm_table_get_md);
>  
> +const char *dm_table_device_name(struct dm_table *t)
> +{
> +	return dm_device_name(t->md);
> +}
> +EXPORT_SYMBOL(dm_table_device_name);
> +
>  void dm_table_run_md_queue_async(struct dm_table *t)
>  {
>  	struct mapped_device *md;

This needs to be EXPORT_SYMBOL_GPL

> diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
> index 6fb0808e87c8..0d63f7e5261c 100644
> --- a/include/linux/device-mapper.h
> +++ b/include/linux/device-mapper.h
> @@ -490,6 +490,7 @@ sector_t dm_table_get_size(struct dm_table *t);
>  unsigned int dm_table_get_num_targets(struct dm_table *t);
>  fmode_t dm_table_get_mode(struct dm_table *t);
>  struct mapped_device *dm_table_get_md(struct dm_table *t);
> +const char *dm_table_device_name(struct dm_table *t);
>  
>  /*
>   * Trigger an event.
> -- 
> 2.19.1
> 

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific
  2018-10-09 19:36   ` [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific Michał Mirosław
@ 2018-10-09 19:42     ` Mike Snitzer
  2018-10-09 20:13       ` [PATCH v2 1/2] dm: add dm_table_device_name() Michał Mirosław
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Snitzer @ 2018-10-09 19:42 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: dm-devel, Alasdair Kergon

On Tue, Oct 09 2018 at  3:36pm -0400,
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:

> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> 
> v2:
>   - include dependency: dm_table_device_name() patch
> 
> ---
>  drivers/md/dm-crypt.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)

Please provide a proper patch header that actually delves into _why_
this change is occurring.

Thanks,
Mike

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] dm: add dm_table_device_name()
  2018-10-09 19:42     ` Mike Snitzer
@ 2018-10-09 20:13       ` Michał Mirosław
  2018-10-09 20:13         ` [PATCH v3 2/2] dm-crypt: make workqueue names device-specific Michał Mirosław
  0 siblings, 1 reply; 7+ messages in thread
From: Michał Mirosław @ 2018-10-09 20:13 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer; +Cc: dm-devel

Add a shortcut for dm_device_name(dm_table_get_md(t)).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
v2: use EXPORT_SYMBOL_GPL like dm_device_name()
---
 drivers/md/dm-table.c         | 6 ++++++
 include/linux/device-mapper.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 3d0e2c198f06..792de0a44cd8 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -2079,6 +2079,12 @@ struct mapped_device *dm_table_get_md(struct dm_table *t)
 }
 EXPORT_SYMBOL(dm_table_get_md);
 
+const char *dm_table_device_name(struct dm_table *t)
+{
+	return dm_device_name(t->md);
+}
+EXPORT_SYMBOL_GPL(dm_table_device_name);
+
 void dm_table_run_md_queue_async(struct dm_table *t)
 {
 	struct mapped_device *md;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 6fb0808e87c8..0d63f7e5261c 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -490,6 +490,7 @@ sector_t dm_table_get_size(struct dm_table *t);
 unsigned int dm_table_get_num_targets(struct dm_table *t);
 fmode_t dm_table_get_mode(struct dm_table *t);
 struct mapped_device *dm_table_get_md(struct dm_table *t);
+const char *dm_table_device_name(struct dm_table *t);
 
 /*
  * Trigger an event.
-- 
2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/2] dm-crypt: make workqueue names device-specific
  2018-10-09 20:13       ` [PATCH v2 1/2] dm: add dm_table_device_name() Michał Mirosław
@ 2018-10-09 20:13         ` Michał Mirosław
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Mirosław @ 2018-10-09 20:13 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer; +Cc: dm-devel

Make cpu-usage debugging easier by naming workqueues per device.

Example ps output:

root       413  0.0  0.0      0     0 ?        I<   paź02   0:00  [kcryptd_io/253:0]
root       414  0.0  0.0      0     0 ?        I<   paź02   0:00  [kcryptd/253:0]
root       415  0.0  0.0      0     0 ?        S    paź02   1:10  [dmcrypt_write/253:0]
root       465  0.0  0.0      0     0 ?        I<   paź02   0:00  [kcryptd_io/253:2]
root       466  0.0  0.0      0     0 ?        I<   paź02   0:00  [kcryptd/253:2]
root       467  0.0  0.0      0     0 ?        S    paź02   2:06  [dmcrypt_write/253:2]
root     15359  0.2  0.0      0     0 ?        I<   19:43   0:25  [kworker/u17:8-kcryptd/253:0]
root     16563  0.2  0.0      0     0 ?        I<   20:10   0:18  [kworker/u17:0-kcryptd/253:2]
root     23205  0.1  0.0      0     0 ?        I<   21:21   0:04  [kworker/u17:4-kcryptd/253:0]
root     13383  0.1  0.0      0     0 ?        I<   21:32   0:02  [kworker/u17:2-kcryptd/253:2]
root      2610  0.1  0.0      0     0 ?        I<   21:42   0:01  [kworker/u17:12-kcryptd/253:2]
root     20124  0.1  0.0      0     0 ?        I<   21:56   0:01  [kworker/u17:1-kcryptd/253:2]

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 v2:
  - include dependency: dm_table_device_name() patch
 v3:
  - revive commit message
  - add ps example
---
 drivers/md/dm-crypt.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0481223b1deb..b5eda64d3840 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2661,6 +2661,7 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar
 static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
 	struct crypt_config *cc;
+	const char *devname = dm_table_device_name(ti->table);
 	int key_size;
 	unsigned int align_mask;
 	unsigned long long tmpll;
@@ -2806,18 +2807,22 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	}
 
 	ret = -ENOMEM;
-	cc->io_queue = alloc_workqueue("kcryptd_io", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+	cc->io_queue = alloc_workqueue("kcryptd_io/%s",
+				       WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+				       1, devname);
 	if (!cc->io_queue) {
 		ti->error = "Couldn't create kcryptd io queue";
 		goto bad;
 	}
 
 	if (test_bit(DM_CRYPT_SAME_CPU, &cc->flags))
-		cc->crypt_queue = alloc_workqueue("kcryptd", WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM, 1);
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
+						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM,
+						  1, devname);
 	else
-		cc->crypt_queue = alloc_workqueue("kcryptd",
+		cc->crypt_queue = alloc_workqueue("kcryptd/%s",
 						  WQ_HIGHPRI | WQ_CPU_INTENSIVE | WQ_MEM_RECLAIM | WQ_UNBOUND,
-						  num_online_cpus());
+						  num_online_cpus(), devname);
 	if (!cc->crypt_queue) {
 		ti->error = "Couldn't create kcryptd queue";
 		goto bad;
@@ -2826,7 +2831,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	spin_lock_init(&cc->write_thread_lock);
 	cc->write_tree = RB_ROOT;
 
-	cc->write_thread = kthread_create(dmcrypt_write, cc, "dmcrypt_write");
+	cc->write_thread = kthread_create(dmcrypt_write, cc,
+					  "dmcrypt_write/%s", devname);
 	if (IS_ERR(cc->write_thread)) {
 		ret = PTR_ERR(cc->write_thread);
 		cc->write_thread = NULL;
-- 
2.19.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-09 20:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-09 19:27 [PATCH] dm-crypt: make workqueue names device-specific Michał Mirosław
2018-10-09 19:36 ` [PATCH 1/2] dm: add dm_table_device_name() Michał Mirosław
2018-10-09 19:36   ` [PATCH 2/2 v2] dm-crypt: make workqueue names device-specific Michał Mirosław
2018-10-09 19:42     ` Mike Snitzer
2018-10-09 20:13       ` [PATCH v2 1/2] dm: add dm_table_device_name() Michał Mirosław
2018-10-09 20:13         ` [PATCH v3 2/2] dm-crypt: make workqueue names device-specific Michał Mirosław
2018-10-09 19:39   ` [PATCH 1/2] dm: add dm_table_device_name() Mike Snitzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.