From: mark gross <markgross@thegnar.org>
To: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rjw@sisk.pl>, Kevin Hilman <khilman@ti.com>,
Jean Pihet <j-pihet@ti.com>, markgross <markgross@thegnar.org>,
kyungmin.park@samsung.com, myungjoo.ham@gmail.com
Subject: Re: [RFC PATCH] PM / QoS: add pm_qos_update_request_timeout API
Date: Sun, 19 Feb 2012 13:14:51 -0800 [thread overview]
Message-ID: <20120219211451.GA26578@envy17> (raw)
In-Reply-To: <1329196614-6218-1-git-send-email-myungjoo.ham@samsung.com>
On Tue, Feb 14, 2012 at 02:16:54PM +0900, MyungJoo Ham wrote:
> The new API, pm_qos_update_request_timeout() is to provide a timeout
> with pm_qos_update_request.
>
> For example, pm_qos_update_request_timeout(req, 100, 1000), means that
> QoS request on req with value 100 will be active for 1000 jiffies.
> After 1000 jiffies, the QoS request thru req is rolled back to the
> request status when pm_qos_update_request_timeout() was called. If there
> were another pm_qos_update_request(req, x) during the 1000 jiffies, this
> new request with value x will override as this is another request on the
> same req handle. A new request on the same req handle will always
> override the previous request whether it is the conventional request or
> it is the new timeout request.
>
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> ---
> include/linux/pm_qos.h | 5 ++++
> kernel/power/qos.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 58 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h
> index f8ccb7b..1c29f52 100644
> --- a/include/linux/pm_qos.h
> +++ b/include/linux/pm_qos.h
> @@ -8,6 +8,7 @@
> #include <linux/notifier.h>
> #include <linux/miscdevice.h>
> #include <linux/device.h>
> +#include <linux/workqueue.h>
>
> #define PM_QOS_RESERVED 0
> #define PM_QOS_CPU_DMA_LATENCY 1
> @@ -29,6 +30,8 @@
> struct pm_qos_request {
> struct plist_node node;
> int pm_qos_class;
> + s32 value; /* the back-up value for pm_qos_update_request_timeout */
Why can't we just drop back to the qos_class default? or auto remove
the time out request from the list?
> + struct delayed_work work; /* for pm_qos_update_request_timeout */
> };
>
> struct dev_pm_qos_request {
> @@ -74,6 +77,8 @@ void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
> s32 value);
> void pm_qos_update_request(struct pm_qos_request *req,
> s32 new_value);
> +void pm_qos_update_request_timeout(struct pm_qos_request *req,
> + s32 new_value, unsigned long timeout);
Don't you need 2 values? one for the request and one for the time out
request target?
I tend to not like time out api's. They are race conditions waiting to
happen.
The caller could have its own timer that can simply go off and update the
requested qos.
I understand that you need to bump performance up for a short time to get good
interactivity but I don't know if it should be generalized or if this is
a good enough of a generalization.
--mark
> void pm_qos_remove_request(struct pm_qos_request *req);
>
> int pm_qos_request(int pm_qos_class);
> diff --git a/kernel/power/qos.c b/kernel/power/qos.c
> index b15e0b7..acfa433 100644
> --- a/kernel/power/qos.c
> +++ b/kernel/power/qos.c
> @@ -259,6 +259,21 @@ int pm_qos_request_active(struct pm_qos_request *req)
> EXPORT_SYMBOL_GPL(pm_qos_request_active);
>
> /**
> + * pm_qos_timeout - the timeout handler of pm_qos_update_request_timeout
> + * @work: work struct for the delayed work (timeout)
> + *
> + * This cancels the timeout request and rolls the request value back.
> + */
> +static void pm_qos_timeout(struct work_struct *work)
> +{
> + struct pm_qos_request *req = container_of(to_delayed_work(work),
> + struct pm_qos_request,
> + work);
> +
> + pm_qos_update_request(req, req->value);
> +}
> +
> +/**
> * pm_qos_add_request - inserts new qos request into the list
> * @req: pointer to a preallocated handle
> * @pm_qos_class: identifies which list of qos request to use
> @@ -282,6 +297,8 @@ void pm_qos_add_request(struct pm_qos_request *req,
> return;
> }
> req->pm_qos_class = pm_qos_class;
> + req->value = value;
> + INIT_DELAYED_WORK(&req->work, pm_qos_timeout);
> pm_qos_update_target(pm_qos_array[pm_qos_class]->constraints,
> &req->node, PM_QOS_ADD_REQ, value);
> }
> @@ -308,14 +325,46 @@ void pm_qos_update_request(struct pm_qos_request *req,
> return;
> }
>
> - if (new_value != req->node.prio)
> + if (delayed_work_pending(&req->work))
> + cancel_delayed_work_sync(&req->work);
> +
> + req->value = new_value;
> + if (new_value != req->node.prio) {
> pm_qos_update_target(
> pm_qos_array[req->pm_qos_class]->constraints,
> &req->node, PM_QOS_UPDATE_REQ, new_value);
> + }
> }
> EXPORT_SYMBOL_GPL(pm_qos_update_request);
>
> /**
> + * pm_qos_update_request_timeout - modifies an existing qos request temporarily.
> + * @req : handle to list element holding a pm_qos request to use
> + * @new_value: defines the temporal qos request
> + * @timeout: the effective duration of this qos request in jiffies
> + *
> + * After timeout, this qos request is cancelled automatically.
> + */
> +void pm_qos_update_request_timeout(struct pm_qos_request *req, s32 new_value,
> + unsigned long timeout)
> +{
> + if (!req)
> + return;
> + if (WARN(!pm_qos_request_active(req),
> + "pm_qos_update_request_timeout() called for unknown object."))
> + return;
> +
> + if (new_value != req->node.prio) {
> + pm_qos_update_target(
> + pm_qos_array[req->pm_qos_class]->constraints,
> + &req->node, PM_QOS_UPDATE_REQ, new_value);
> + if (delayed_work_pending(&req->work))
> + cancel_delayed_work_sync(&req->work);
> + schedule_delayed_work(&req->work, timeout);
> + }
> +}
> +
> +/**
> * pm_qos_remove_request - modifies an existing qos request
> * @req: handle to request list element
> *
> @@ -334,6 +383,9 @@ void pm_qos_remove_request(struct pm_qos_request *req)
> return;
> }
>
> + if (delayed_work_pending(&req->work))
> + cancel_delayed_work_sync(&req->work);
> +
> pm_qos_update_target(pm_qos_array[req->pm_qos_class]->constraints,
> &req->node, PM_QOS_REMOVE_REQ,
> PM_QOS_DEFAULT_VALUE);
> --
> 1.7.4.1
>
next prev parent reply other threads:[~2012-02-19 21:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 5:16 [RFC PATCH] PM / QoS: add pm_qos_update_request_timeout API MyungJoo Ham
2012-02-14 22:08 ` Rafael J. Wysocki
2012-02-15 6:44 ` MyungJoo Ham
2012-02-19 21:14 ` mark gross [this message]
2012-02-22 8:43 ` MyungJoo Ham
2012-02-29 4:56 ` [PATCH v2] " MyungJoo Ham
2012-03-07 5:06 ` [PATCH v3] " MyungJoo Ham
2012-03-24 16:35 ` mark gross
2012-03-26 1:41 ` MyungJoo Ham
2012-03-26 3:02 ` mark gross
2012-03-26 11:57 ` MyungJoo Ham
2012-03-26 20:42 ` Rafael J. Wysocki
2012-03-27 6:31 ` [PATCH v4] " MyungJoo Ham
2012-03-27 22:03 ` Rafael J. Wysocki
2012-03-28 1:47 ` [PATCH v4 resend] " MyungJoo Ham
2012-03-28 21:55 ` Rafael J. Wysocki
2012-03-28 1:53 ` [PATCH v4] " MyungJoo Ham
2012-03-28 10:25 ` Rafael J. Wysocki
2012-03-24 16:41 ` [PATCH v3] " mark gross
2012-03-24 18:37 ` mark gross
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=20120219211451.GA26578@envy17 \
--to=markgross@thegnar.org \
--cc=j-pihet@ti.com \
--cc=khilman@ti.com \
--cc=kyungmin.park@samsung.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@gmail.com \
--cc=myungjoo.ham@samsung.com \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/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