lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 02 Jun 2015 12:30:49 +0900
From:	Krzysztof Kozlowski <k.kozlowski@...sung.com>
To:	Stephen Boyd <sboyd@...eaurora.org>, linux-arm-msm@...r.kernel.org
Cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Nishanth Menon <nm@...com>,
	Viresh Kumar <viresh.kumar@...aro.org>,
	Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
	Andy Gross <agross@...eaurora.org>, linux-pm@...r.kernel.org,
	Mark Brown <broonie@...nel.org>,
	David Collins <collinsd@...eaurora.org>
Subject: Re: [RFC/PATCH 4/6] OPP: Allow notifiers to call
 dev_pm_opp_get_{voltage,freq} RCU-free

On 02.06.2015 10:47, Stephen Boyd wrote:
> We pass the dev_pm_opp structure to OPP notifiers but the users
> of the notifier need to surround calls to dev_pm_opp_get_*() with
> RCU read locks to avoid lockdep warnings. The notifier is already
> called with the dev_opp's srcu lock held, so it should be safe to
> assume the devm_pm_opp structure is already protected inside the
> notifier. Update the lockdep check for this.
> 
> Cc: Krzysztof Kozlowski <k.kozlowski@...sung.com>
> Signed-off-by: Stephen Boyd <sboyd@...eaurora.org>
> ---
> 
> This is probably wrong, but it's what I had to hack up
> to be able to use the OPP functions from within the notifier
> to figure out the new values of the OPP without having to take
> an RCU read lock.
> 
>  drivers/base/power/opp.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index b997a7eabcd4..6d75022c6a0e 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -108,9 +108,10 @@ static LIST_HEAD(dev_opp_list);
>  /* Lock to allow exclusive modification to the device and opp lists */
>  static DEFINE_MUTEX(dev_opp_list_lock);
>  
> -#define opp_rcu_lockdep_assert()					\
> +#define opp_rcu_lockdep_assert(s)					\
>  do {									\
>  	rcu_lockdep_assert(rcu_read_lock_held() ||			\
> +				(s && srcu_read_lock_held(s)) || 	\
>  				lockdep_is_held(&dev_opp_list_lock),	\
>  			   "Missing rcu_read_lock() or "		\
>  			   "dev_opp_list_lock protection");		\
> @@ -169,9 +170,10 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
>  	struct dev_pm_opp *tmp_opp;
>  	unsigned long v = 0;
>  
> -	opp_rcu_lockdep_assert();
> +	opp_rcu_lockdep_assert(&opp->dev_opp->srcu_head.srcu);
>  
> -	tmp_opp = rcu_dereference(opp);
> +	tmp_opp = srcu_dereference_check(opp, &opp->dev_opp->srcu_head.srcu,
> +					 rcu_read_lock_held());

It looks strange. The notifier's SRCU is part of device_opp but here we
want to protect the dev_pm_opp.

Because of this difference I am not sure that it is safe having around
this a srcu_read_lock() from notifiers instead of rcu_read_lock().

Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ