[Cbe-oss-dev] Lifetime of SPE contexts & gangs
Gerhard Stenzel
gerhard.stenzel at de.ibm.com
Wed May 9 18:18:43 EST 2007
> Hi all,
>
> I'm in the process of sorting out the issues we have with SPE gangs and
> contexts in spufs at the moment. For those that haven't come across
> this, if a process destroy a gang (ie, close its file descriptor)
> before destroying the gang's contexts, we hit a bug, mostly because we
> haven't set any explicit behaviour for this condition.
>
> So, there are a couple of possible approaches to correct this:
>
> * Each context within a gang holds a reference to the gang via the
> gang's refcount, and closing the gang fd decreases it. So, if you close
> the gang fd, the gang dir only gets removed when the last context is
> destroyed.
>
> * Closing a gang causes the gang's contexts to be destroyed at the same
> time, regardless of whether the process holds an open file descriptor
> to any of the contexts.
>
> * Destroying the gang causes its contexts to be reparented to the root
> of the spu filesystem. Libspe might get a little confused by this
> though..
>
> I think the first may be the correct way to go, but it may be a little
> strange for users to see contexts that they have 'destroyed'. Anyone
> have particular opinions on this?
>
This is what the libspe2 spec has to say about this:
When an application no longer needs a specific SPE gang context, it should
release all associated resources and free the memory used by the SPE
context data structure. It does this by first calling spe_context_destroy
to destroy all SPE contexts associated with the gang by on each of them and
then calling the function spe_gang_context_destroy.
>From that perspective, another option could be that spe_context_destroy()
fails, if it still has associated contexts. This would require a
specification change.
So far, we mainly see this problem, if an application exits without
cleaning up properly. So, my preference would be the second option.
Best regards,
Gerhard Stenzel, Linux on Cell Development, LTC
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Johann Weihen | Geschäftsführung: Herbert
Kircher
Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht Stuttgart,
HRB 243294
More information about the cbe-oss-dev
mailing list