* [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code
@ 2012-10-26 14:57 Wei Yongjun
2012-10-27 0:14 ` Nishanth Menon
2012-10-31 0:43 ` Rafael J. Wysocki
0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2012-10-26 14:57 UTC (permalink / raw)
To: len.brown, pavel, rjw, gregkh; +Cc: yongjun_wei, linux-pm
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.
dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/base/power/opp.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index c8a908b..50b2831 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -461,17 +461,6 @@ int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
}
/**
- * opp_free_rcu() - helper to clear the struct opp when grace period has
- * elapsed without blocking the the caller of opp_set_availability
- */
-static void opp_free_rcu(struct rcu_head *head)
-{
- struct opp *opp = container_of(head, struct opp, head);
-
- kfree(opp);
-}
-
-/**
* opp_set_availability() - helper to set the availability of an opp
* @dev: device for which we do this operation
* @freq: OPP frequency to modify availability
@@ -542,7 +531,7 @@ static int opp_set_availability(struct device *dev, unsigned long freq,
list_replace_rcu(&opp->node, &new_opp->node);
mutex_unlock(&dev_opp_list_lock);
- call_rcu(&opp->head, opp_free_rcu);
+ kfree_rcu(opp, head);
/* Notify the change of the OPP availability */
if (availability_req)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code
2012-10-26 14:57 [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code Wei Yongjun
@ 2012-10-27 0:14 ` Nishanth Menon
2012-10-31 0:43 ` Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Nishanth Menon @ 2012-10-27 0:14 UTC (permalink / raw)
To: Wei Yongjun, Vincent Guittot
Cc: len.brown, pavel, rjw, gregkh, yongjun_wei, linux-pm
On 22:57-20121026, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> The callback function of call_rcu() just calls a kfree(), so we
> can use kfree_rcu() instead of call_rcu() + callback function.
>
> dpatch engine is used to auto generate this patch.
> (https://github.com/weiyj/dpatch)
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
> drivers/base/power/opp.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index c8a908b..50b2831 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -461,17 +461,6 @@ int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
> }
>
> /**
> - * opp_free_rcu() - helper to clear the struct opp when grace period has
> - * elapsed without blocking the the caller of opp_set_availability
> - */
> -static void opp_free_rcu(struct rcu_head *head)
> -{
> - struct opp *opp = container_of(head, struct opp, head);
> -
> - kfree(opp);
> -}
> -
> -/**
> * opp_set_availability() - helper to set the availability of an opp
> * @dev: device for which we do this operation
> * @freq: OPP frequency to modify availability
> @@ -542,7 +531,7 @@ static int opp_set_availability(struct device *dev, unsigned long freq,
>
> list_replace_rcu(&opp->node, &new_opp->node);
> mutex_unlock(&dev_opp_list_lock);
> - call_rcu(&opp->head, opp_free_rcu);
> + kfree_rcu(opp, head);
>
> /* Notify the change of the OPP availability */
> if (availability_req)
A good idea. thanks.
I wonder if we might squash this with
https://patchwork.kernel.org/patch/1504361/
on a side note:
struct opp {
struct list_head node;
bool available;
unsigned long rate;
unsigned long u_volt;
struct device_opp *dev_opp;
struct rcu_head;
};
we could move rcu_head to the top of the struct .. just to avoid
revisiting this at a later point in time *if* struct opp expands..
If we are squashing it, we might consider fixing the kern-doc for
"head"..
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code
2012-10-26 14:57 [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code Wei Yongjun
2012-10-27 0:14 ` Nishanth Menon
@ 2012-10-31 0:43 ` Rafael J. Wysocki
1 sibling, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2012-10-31 0:43 UTC (permalink / raw)
To: Wei Yongjun; +Cc: len.brown, pavel, gregkh, yongjun_wei, linux-pm
On Friday, October 26, 2012 10:57:41 PM Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> The callback function of call_rcu() just calls a kfree(), so we
> can use kfree_rcu() instead of call_rcu() + callback function.
>
> dpatch engine is used to auto generate this patch.
> (https://github.com/weiyj/dpatch)
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Applied to the linux-next branch of linux-pm.git as v3.8 material.
Thanks,
Rafael
> ---
> drivers/base/power/opp.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index c8a908b..50b2831 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -461,17 +461,6 @@ int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
> }
>
> /**
> - * opp_free_rcu() - helper to clear the struct opp when grace period has
> - * elapsed without blocking the the caller of opp_set_availability
> - */
> -static void opp_free_rcu(struct rcu_head *head)
> -{
> - struct opp *opp = container_of(head, struct opp, head);
> -
> - kfree(opp);
> -}
> -
> -/**
> * opp_set_availability() - helper to set the availability of an opp
> * @dev: device for which we do this operation
> * @freq: OPP frequency to modify availability
> @@ -542,7 +531,7 @@ static int opp_set_availability(struct device *dev, unsigned long freq,
>
> list_replace_rcu(&opp->node, &new_opp->node);
> mutex_unlock(&dev_opp_list_lock);
> - call_rcu(&opp->head, opp_free_rcu);
> + kfree_rcu(opp, head);
>
> /* Notify the change of the OPP availability */
> if (availability_req)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-31 0:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-26 14:57 [PATCH -next] PM / OPP: using kfree_rcu() to simplify the code Wei Yongjun
2012-10-27 0:14 ` Nishanth Menon
2012-10-31 0:43 ` Rafael J. Wysocki
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).