Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1345235 > unrolled thread

[RFC] staging: unisys: visorbus: visorchipset: Remove create_singlethread_workqueue()

Started byAmitoj Kaur Chawla <amitoj1606@gmail.com>
First post2016-02-28 13:50 +0100
Last post2016-02-28 23:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC] staging: unisys: visorbus: visorchipset: Remove  create_singlethread_workqueue() Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-02-28 13:50 +0100
    RE: [RFC] staging: unisys: visorbus: visorchipset: Remove  create_singlethread_workqueue() "Kershner, David A" <David.Kershner@unisys.com> - 2016-02-28 23:10 +0100

#1345235 — [RFC] staging: unisys: visorbus: visorchipset: Remove create_singlethread_workqueue()

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-02-28 13:50 +0100
Subject[RFC] staging: unisys: visorbus: visorchipset: Remove create_singlethread_workqueue()
Message-ID<r78Xo-2mr-27@gated-at.bofh.it>
With concurrency managed workqueues, use of dedicated workqueues
can be replaced by using system_wq. Drop periodic_controlvm_workqueue
by using system_wq.

Since there is only one work item periodic_controlvm_work and
different periodic_controlvm_works do not need to be ordered, increase 
of concurrency level by switching to system_wq should not break anything.

cancel_delayed_work_sync() is used to ensure that work is not pending 
or executing on any CPU.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
Only compile tested.

 drivers/staging/unisys/visorbus/visorchipset.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index b75b063..c4c71c6 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -102,7 +102,6 @@ struct parser_context {
 };
 
 static struct delayed_work periodic_controlvm_work;
-static struct workqueue_struct *periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(notifier_lock);
 
 static struct cdev file_cdev;
@@ -1913,8 +1912,7 @@ cleanup:
 			poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
 	}
 
-	queue_delayed_work(periodic_controlvm_workqueue,
-			   &periodic_controlvm_work, poll_jiffies);
+	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
 }
 
 static void
@@ -2011,8 +2009,7 @@ cleanup:
 
 	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
 
-	queue_delayed_work(periodic_controlvm_workqueue,
-			   &periodic_controlvm_work, poll_jiffies);
+	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
 }
 
 static void
@@ -2299,19 +2296,10 @@ visorchipset_init(struct acpi_device *acpi_device)
 	else
 		INIT_DELAYED_WORK(&periodic_controlvm_work,
 				  controlvm_periodic_work);
-	periodic_controlvm_workqueue =
-	    create_singlethread_workqueue("visorchipset_controlvm");
 
-	if (!periodic_controlvm_workqueue) {
-		POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
-				 DIAG_SEVERITY_ERR);
-		rc = -ENOMEM;
-		goto cleanup;
-	}
 	most_recent_message_jiffies = jiffies;
 	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-	queue_delayed_work(periodic_controlvm_workqueue,
-			   &periodic_controlvm_work, poll_jiffies);
+	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
 
 	visorchipset_platform_device.dev.devt = major_dev;
 	if (platform_device_register(&visorchipset_platform_device) < 0) {
@@ -2346,10 +2334,7 @@ visorchipset_exit(struct acpi_device *acpi_device)
 
 	visorbus_exit();
 
-	cancel_delayed_work(&periodic_controlvm_work);
-	flush_workqueue(periodic_controlvm_workqueue);
-	destroy_workqueue(periodic_controlvm_workqueue);
-	periodic_controlvm_workqueue = NULL;
+	cancel_delayed_work_sync(&periodic_controlvm_work);
 	destroy_controlvm_payload_info(&controlvm_payload_info);
 
 	memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
-- 
1.9.1

[toc] | [next] | [standalone]


#1345410

From"Kershner, David A" <David.Kershner@unisys.com>
Date2016-02-28 23:10 +0100
Message-ID<r7hHk-HU-25@gated-at.bofh.it>
In reply to#1345235
> -----Original Message-----
> From: Amitoj Kaur Chawla [mailto:amitoj1606@gmail.com]
> Sent: Sunday, February 28, 2016 7:44 AM
> To: Romer, Benjamin M <Benjamin.Romer@unisys.com>;
> Jes.Sorensen@redhat.com; Arfvidson, Erik <Erik.Arfvidson@unisys.com>;
> Kershner, David A <David.Kershner@unisys.com>; jkc@redhat.com; Sell,
> Timothy C <Timothy.Sell@unisys.com>; Thompson, Bryan E.
> <bryan.thompson@unisys.com>; dzickus@redhat.com;
> kenneth.depro@unisys.com; gregkh@linuxfoundation.org; *S-Par-
> Maintainer <SParMaintainer@unisys.com>; devel@driverdev.osuosl.org;
> linux-kernel@vger.kernel.org
> Cc: tj@kernel.org; outreachy-kernel@googlegroups.com
> Subject: [RFC] staging: unisys: visorbus: visorchipset: Remove
> create_singlethread_workqueue()
> 
> With concurrency managed workqueues, use of dedicated workqueues
> can be replaced by using system_wq. Drop periodic_controlvm_workqueue
> by using system_wq.
> 
> Since there is only one work item periodic_controlvm_work and
> different periodic_controlvm_works do not need to be ordered, increase
> of concurrency level by switching to system_wq should not break anything.
> 
> cancel_delayed_work_sync() is used to ensure that work is not pending
> or executing on any CPU.
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> Acked-by: Tejun Heo <tj@kernel.org>

Tested on s-Par system, no issues found. 

Tested-by: David Kershner <david.kershner@unisys.com>

> ---
> Only compile tested.
> 
>  drivers/staging/unisys/visorbus/visorchipset.c | 23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorchipset.c
> b/drivers/staging/unisys/visorbus/visorchipset.c
> index b75b063..c4c71c6 100644
> --- a/drivers/staging/unisys/visorbus/visorchipset.c
> +++ b/drivers/staging/unisys/visorbus/visorchipset.c
> @@ -102,7 +102,6 @@ struct parser_context {
>  };
> 
>  static struct delayed_work periodic_controlvm_work;
> -static struct workqueue_struct *periodic_controlvm_workqueue;
>  static DEFINE_SEMAPHORE(notifier_lock);
> 
>  static struct cdev file_cdev;
> @@ -1913,8 +1912,7 @@ cleanup:
>  			poll_jiffies =
> POLLJIFFIES_CONTROLVMCHANNEL_FAST;
>  	}
> 
> -	queue_delayed_work(periodic_controlvm_workqueue,
> -			   &periodic_controlvm_work, poll_jiffies);
> +	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
>  }
> 
>  static void
> @@ -2011,8 +2009,7 @@ cleanup:
> 
>  	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
> 
> -	queue_delayed_work(periodic_controlvm_workqueue,
> -			   &periodic_controlvm_work, poll_jiffies);
> +	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
>  }
> 
>  static void
> @@ -2299,19 +2296,10 @@ visorchipset_init(struct acpi_device
> *acpi_device)
>  	else
>  		INIT_DELAYED_WORK(&periodic_controlvm_work,
>  				  controlvm_periodic_work);
> -	periodic_controlvm_workqueue =
> -	    create_singlethread_workqueue("visorchipset_controlvm");
> 
> -	if (!periodic_controlvm_workqueue) {
> -		POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
> -				 DIAG_SEVERITY_ERR);
> -		rc = -ENOMEM;
> -		goto cleanup;
> -	}
>  	most_recent_message_jiffies = jiffies;
>  	poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
> -	queue_delayed_work(periodic_controlvm_workqueue,
> -			   &periodic_controlvm_work, poll_jiffies);
> +	schedule_delayed_work(&periodic_controlvm_work, poll_jiffies);
> 
>  	visorchipset_platform_device.dev.devt = major_dev;
>  	if (platform_device_register(&visorchipset_platform_device) < 0) {
> @@ -2346,10 +2334,7 @@ visorchipset_exit(struct acpi_device *acpi_device)
> 
>  	visorbus_exit();
> 
> -	cancel_delayed_work(&periodic_controlvm_work);
> -	flush_workqueue(periodic_controlvm_workqueue);
> -	destroy_workqueue(periodic_controlvm_workqueue);
> -	periodic_controlvm_workqueue = NULL;
> +	cancel_delayed_work_sync(&periodic_controlvm_work);
>  	destroy_controlvm_payload_info(&controlvm_payload_info);
> 
>  	memset(&g_chipset_msg_hdr, 0, sizeof(struct
> controlvm_message_header));
> --
> 1.9.1

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web