From: Jean Delvare <jdelvare@suse.de>
To: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
Cc: Guenter Roeck <linux@roeck-us.net>,
linux-hwmon@vger.kernel.org,
Chris Packham <chris.packham@alliedtelesis.co.nz>
Subject: Re: [PATCH] hwmon: adt7470: Allow faster removal
Date: Thu, 1 Sep 2016 10:17:52 +0200 [thread overview]
Message-ID: <20160901101752.27d3d5f9@endymion> (raw)
In-Reply-To: <20160901051721.13806-1-joshua.scott@alliedtelesis.co.nz>
Hi Joshua,
On Thu, 1 Sep 2016 17:17:21 +1200, Joshua Scott wrote:
> adt7470_remove will wait for the update thread to complete before
> returning. This has a worst-case time of up to the user-configurable
> auto_update_interval.
>
> Break this delay into smaller slices to allow the thread to exit quickly
> when adt7470_remove is called.
>
> Signed-off-by: Joshua Scott <joshua.scott@alliedtelesis.co.nz>
> ---
> drivers/hwmon/adt7470.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
> index 7d185a9..ba97392 100644
> --- a/drivers/hwmon/adt7470.c
> +++ b/drivers/hwmon/adt7470.c
> @@ -268,14 +268,21 @@ static int adt7470_update_thread(void *p)
> {
> struct i2c_client *client = p;
> struct adt7470_data *data = i2c_get_clientdata(client);
> + unsigned long next_read = jiffies - 1;
>
> while (!kthread_should_stop()) {
> - mutex_lock(&data->lock);
> - adt7470_read_temperatures(client, data);
> - mutex_unlock(&data->lock);
> +
> + if (time_after_eq(jiffies, next_read)) {
> + next_read = jiffies + data->auto_update_interval * HZ / 1000;
> + mutex_lock(&data->lock);
> + adt7470_read_temperatures(client, data);
> + mutex_unlock(&data->lock);
> + }
> +
> + msleep_interruptible(1);
> +
> if (kthread_should_stop())
> break;
> - msleep_interruptible(data->auto_update_interval);
> }
>
> complete_all(&data->auto_update_stop);
This change looks terribly costly to me. In order to shorten the
duration of a rare event (you don't "rmmod adt7470" on a regular basis,
do you?) you increase the cost of a kernel thread which runs all the
time. I'm afraid this msleep_interruptible(1) is going to prevent the
CPU from entering low power states at all, leading to an increased
system temperature and power consumption. Have you compared the output
of "powertop" (specifically the "Idle stats" section) before and after
your patch?
Is there no way to voluntarily interrupt this long msleep_interruptible?
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2016-09-01 8:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 5:17 [PATCH] hwmon: adt7470: Allow faster removal Joshua Scott
2016-09-01 8:17 ` Jean Delvare [this message]
2016-09-01 12:10 ` Guenter Roeck
2016-09-01 21:08 ` Chris Packham
2016-09-02 14:55 ` Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2016-09-06 22:49 Joshua Scott
2016-09-09 4:17 ` Guenter Roeck
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=20160901101752.27d3d5f9@endymion \
--to=jdelvare@suse.de \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=joshua.scott@alliedtelesis.co.nz \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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;
as well as URLs for NNTP newsgroup(s).