[Cbe-oss-dev] [PATCH] libspe2: Fix _base_spe_count_physical_cpus

Kazunori Asayama asayama at sm.sony.co.jp
Tue Jun 3 17:05:22 EST 2008


Patch applied.
Thank you!

malc wrote:
> This patch fixes the counting of physical cpus, and thus the counting
> of spus per cpu.
> 
> Currently - we count the number of dirent entries in
> /sys/devices/system/cpu/ starting at -2 (to ignore . and ..)
> At some point additional entries were added to this chunk of sysfs -
> 
> ps3-64ul ~ # ls /sys/devices/system/cpu/
> cpu0  cpu1  online  possible  present
> 
> And so the number of CPUs in the system is reported incorrectly - it
> then follows that the number of spus is also reported incorrectly.
> 
> The following patch makes the counting of cpu's somewhat more bullet proof.
> 
> Signed off by Malcolm Lashley <malc at sucks-ass.com>
> 
> diff  -urp /var/tmp/portage/sys-libs/libspe2-2.2.80_p121/work/libspe2-2.2.80/spebase/info.c
> /tmp/libspe2-2.2.80/spebase/info.c
> --- /var/tmp/portage/sys-libs/libspe2-2.2.80_p121/work/libspe2-2.2.80/spebase/info.c
>    2007-05-31 10:15:33.000000000 +0000
> +++ /tmp/libspe2-2.2.80/spebase/info.c  2008-05-23 03:00:19.000000000 +0000
> @@ -31,7 +31,7 @@ int _base_spe_count_physical_cpus(int cp
>  {
>         const char    *buff = "/sys/devices/system/cpu";
>         DIR     *dirp;
> -       int ret = -2;
> +       int ret = 0;
>         struct  dirent  *dptr;
> 
>         DEBUG_PRINTF ("spe_count_physical_cpus()\n");
> @@ -50,6 +50,7 @@ int _base_spe_count_physical_cpus(int cp
>                 return -1;
>         }
>      while((dptr=readdir(dirp))) {
> +       if(strncmp("cpu",dptr->d_name,3) == 0)
>                 ret++;
>         }
>         closedir(dirp);

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



More information about the cbe-oss-dev mailing list