[Cbe-oss-dev] [PATCH] libspe2: add SPE_NOSCHED to spe_context_create()

Kazunori Asayama asayama at sm.sony.co.jp
Fri Aug 1 19:34:32 EST 2008


Gerhard Stenzel wrote:
> This patch adds a new flag for spe_context_create() that ensures that a
> program can "keep" an SPE until it runs to completion. In other words,
> the physical SPE resource that runs this context becomes "invisible" to
> the SPE scheduler and can't be used to run other context, even if they
> have higher priority. Because of this behaviour, this function is
> considered a privileged operation. The process needs "CAP_SYS_NICE"
> capability in Linux (see capabilities(7)) - which usually only root has.
> 
> Please note also, that this requires the following patches
> 
>  powerpc/spufs: allow spu_acquire_saved to correctly handle NOSCHED contexts
>  powerpc/spufs: consolidate contexts of normal and NOSCHED context directories
> 
> sent by Jeremy Kerr to cbe-oss-dev August, the 1st, 2008 
> to be applied to the kernel, otherwise SPE_NOSCHED will fail.
> 
> Signed-off-by: Gerhard Stenzel <stenzel at de.ibm.com>

Looks good.

BTW, spe_spu_info_get(SPE_COUNT_USABLE_SPES, ...) should be fixed so 
that it returns a correct value. However, to enable that, it will be 
needed to know how many nosched contexts (and kspu) exist in the system, 
maybe via sysfs or something. Do you have any plan to fix this problem?

> 
> ===================================================================
> Index: libspe2/spebase/create.c
> ===================================================================
> --- libspe2/spebase/create.c	(revision 129)
> +++ libspe2/spebase/create.c	(working copy)
> @@ -231,6 +231,9 @@ spe_context_ptr_t _base_spe_context_crea
>  	}
>  
>  	/* initialise spu_createflags */
> +	if (flags & SPE_NOSCHED)
> +		spu_createflags |=  SPU_CREATE_NOSCHED;
> +
>  	if (flags & SPE_ISOLATE) {
>  		flags |= SPE_MAP_PS;
>  		spu_createflags |= SPU_CREATE_ISOLATE | SPU_CREATE_NOSCHED;
> Index: libspe2/libspe2-types.h
> ===================================================================
> --- libspe2/libspe2-types.h	(revision 129)
> +++ libspe2/libspe2-types.h	(working copy)
> @@ -180,6 +180,7 @@ enum ps_area { SPE_MSSYNC_AREA, SPE_MFC_
>  #define SPE_ISOLATE_EMULATE			0x00000100
>  #define SPE_EVENTS_ENABLE			0x00001000
>  #define SPE_AFFINITY_MEMORY			0x00002000
> +#define SPE_NOSCHED				0x00004000
>  
>  
>  /**
> 
> ===================================================================
> 
> Best regards, 
> 
> Gerhard Stenzel, Linux on Cell Development, LTC
> -------------------------------------------------------------------------------------
> IBM Deutschland Research & Development GmbH
> Vorsitzender des Aufsichtsrats: Martin Jetter | Geschaeftsfuehrung: Herbert Kircher
> Sitz der Gesellschaft: Boeblingen | Registergericht: Amtsgericht Stuttgart, HRB 243294
> _______________________________________________
> cbe-oss-dev mailing list
> cbe-oss-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/cbe-oss-dev
> 
> 
> 

-- 
(ASAYAMA Kazunori
   (asayama at sm.sony.co.jp))
t



More information about the cbe-oss-dev mailing list