[PATCH] taskset: support more than 64 cores

Laszlo Papp lpapp at kde.org
Mon Aug 11 13:25:04 UTC 2014


I wonder about the use case for this feature? I mean busybox is meant for
small systems in general, and >=64 cores are not that small embedded
systems, at least not yet, yeah?


On Mon, Aug 11, 2014 at 1:58 PM, Matthieu Ternisien d'Ouville <
matthieu.tdo at 6wind.com> wrote:

> This patch adds support of more than 64 cores for taskset.
>
> Signed-off-by: Matthieu Ternisien d'Ouville <matthieu.tdo at 6wind.com>
> ---
>  miscutils/taskset.c |   39 +++++++++++++++++++++++++++++++--------
>  1 file changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/miscutils/taskset.c b/miscutils/taskset.c
> index 4a9e323..2695e20 100644
> --- a/miscutils/taskset.c
> +++ b/miscutils/taskset.c
> @@ -129,16 +129,39 @@ int taskset_main(int argc UNUSED_PARAM, char **argv)
>         }
>
>         { /* Affinity was specified, translate it into cpu_set_t */
> -               unsigned i;
> -               /* Do not allow zero mask: */
> -               unsigned long long m = xstrtoull_range(aff, 0, 1,
> ULLONG_MAX);
> -               enum { CNT_BIT = CPU_SETSIZE < sizeof(m)*8 ? CPU_SETSIZE :
> sizeof(m)*8 };
> +               long cpu;
> +               int len = strlen(aff);
> +               const char *ptr = aff + len - 1;
> +               const char *prefix = "";
> +
> +               if (len > 1 && !memcmp(aff, "0x", 2)) {
> +                       aff += 2;
> +                       prefix = "0x";
> +               }
>
>                 CPU_ZERO(&mask);
> -               for (i = 0; i < CNT_BIT; i++) {
> -                       unsigned long long bit = (1ULL << i);
> -                       if (bit & m)
> -                               CPU_SET(i, &mask);
> +               cpu = 0;
> +
> +               for (; ptr >= aff; ptr--) {
> +                       int val;
> +
> +                       if (*ptr <= '9' && *ptr >= '0')
> +                               val = *ptr - '0';
> +                       else if (*ptr <= 'f' && *ptr >= 'a')
> +                               val = *ptr + (10 - 'a');
> +                       else
> +                               bb_perror_msg_and_die("invalid mask %s%s",
> prefix, aff);
> +
> +                       if (val & 1)
> +                               CPU_SET(cpu, &mask);
> +                       if (val & 2)
> +                               CPU_SET(cpu+1, &mask);
> +                       if (val & 4)
> +                               CPU_SET(cpu+2, &mask);
> +                       if (val & 8)
> +                               CPU_SET(cpu+3, &mask);
> +
> +                       cpu += 4;
>                 }
>         }
>
> --
> 1.7.10.4
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20140811/798da07f/attachment.html>


More information about the busybox mailing list