<html><body>
<p><tt>linuxppc-dev-bounces+lukebrowning=us.ibm.com@ozlabs.org wrote on 01/12/2006 06:01:15 PM:<br>
<br>
> <br>
> Subject: Enable SPU switch notification to detect currently active SPU tasks.<br>
> <br>
> From: Maynard Johnson <maynardj@us.ibm.com><br>
> <br>
> This patch adds to the capability of spu_switch_event_register to notify the<br>
> caller of currently active SPU tasks. It also exports <br>
> spu_switch_event_register<br>
> and spu_switch_event_unregister.<br>
> <br>
> Signed-off-by: Maynard Johnson <mpjohn@us.ibm.com><br>
> <br>
> <br>
> Index: linux-2.6.19-rc6-<br>
> arnd1+patches/arch/powerpc/platforms/cell/spufs/sched.c<br>
> ===================================================================<br>
> --- linux-2.6.19-rc6-arnd1+patches.<br>
> orig/arch/powerpc/platforms/cell/spufs/sched.c 2006-11-24 11:34:<br>
> 44.884455680 -0600<br>
> +++ linux-2.6.19-rc6-<br>
> arnd1+patches/arch/powerpc/platforms/cell/spufs/sched.c 2006-12-01<br>
> 13:57:21.864583264 -0600<br>
> @@ -84,15 +84,37 @@<br>
> ctx ? ctx->object_id : 0, spu);<br>
> }<br>
> <br>
> +static void notify_spus_active(void)<br>
> +{<br>
> + int node;<br>
> + for (node = 0; node < MAX_NUMNODES; node++) {<br>
> + struct spu *spu;<br>
> + mutex_lock(&spu_prio->active_mutex[node]);<br>
> + list_for_each_entry(spu, &spu_prio->active_list[node], list) {<br>
> + struct spu_context *ctx = spu->ctx;<br>
> + blocking_notifier_call_chain(&spu_switch_notifier,<br>
> + ctx ? ctx->object_id : 0, spu);<br>
> + }<br>
> + mutex_unlock(&spu_prio->active_mutex[node]);<br>
> + }<br>
> +<br>
> +}<br>
> +<br>
> int spu_switch_event_register(struct notifier_block * n)<br>
> {<br>
> - return blocking_notifier_chain_register(&spu_switch_notifier, n);<br>
> + int ret;<br>
> + ret = blocking_notifier_chain_register(&spu_switch_notifier, n);<br>
> + if (!ret)<br>
> + notify_spus_active();<br>
> + return ret;<br>
> }<br>
> +EXPORT_SYMBOL_GPL(spu_switch_event_register);<br>
> <br>
> int spu_switch_event_unregister(struct notifier_block * n)<br>
> {<br>
> return blocking_notifier_chain_unregister(&spu_switch_notifier, n);<br>
> }<br>
> +EXPORT_SYMBOL_GPL(spu_switch_event_unregister);<br>
> <br>
> <br>
> static inline void bind_context(struct spu *spu, struct spu_context *ctx)<br>
</tt><br>
<tt>Is this really the right strategy? First, it serializes all spu context </tt><br>
<tt>switching at the node level. Second, it performs 17 callouts for every context</tt><br>
<tt>switch. Can't oprofile internally derive the list of active spus from the </tt><br>
<tt>context switch callout. </tt><br>
<br>
<tt>Also, the notify_spus_active() callout is dependent on the return code of </tt><br>
<tt>spu_switch_notify(). Should notification be hierarchical? If I only register </tt><br>
<tt>for the second one, should my notification be dependent on the return code</tt><br>
<tt>of some non-related subsystem's handler. </tt><br>
<br>
<tt>Does blocking_callchain_notifier internally check for the presence of registered</tt><br>
<tt>handlers before it takes locks ...? We should ensure that there is minimal overhead</tt><br>
<tt>when there are no registered handlers.</tt><br>
<br>
<tt>Regards,</tt><br>
<tt>Luke</tt><br>
</body></html>