import math


def cpumask2coreids(mask):
    """
    Convert CPU mask in hex-string to list of core-IDs
    """
    intmask = int(mask, 16)
    i = 1
    coreids = []
    while i <= intmask:
        if i & intmask:
            coreids.append(str(math.frexp(i)[1] - 1))
        i = i << 1
    return coreids