示例#1
0
def make_shield(cpuspec, kthread):
    memspec = '0' # FIXME: for numa, we probably want a more intelligent scheme
    log.debug("entering make_shield, cpuspec=%s kthread=%s", cpuspec, kthread)
    # create base cpusets for shield
    cset.cpuspec_check(cpuspec)
    cpuspec_inv = cset.cpuspec_inverse(cpuspec)
    try:
        shield_exists()
    except:
        log.debug("shielding does not exist, creating")
        try:
            set.create(USR_SET, cpuspec, memspec, True, False)
            set.create(SYS_SET, cpuspec_inv, memspec, True, False)
        except Exception as instance:
            # unroll
            try: set.destroy(USR_SET)
            except: pass
            try: set.destroy(SYS_SET)
            except: pass
            log.critical('--> failed to create shield, hint: do other cpusets exist?')
            raise instance
        log.info('--> activating shielding:')
    else:
        log.debug("shielding exists, modifying cpuspec")
        # note, since we're going to modify the cpu assigments to these sets,
        # they cannot be exclusive, the following modify() calls will make
        # them exclusive again
        cset.unique_set(USR_SET).cpu_exclusive = False
        cset.unique_set(SYS_SET).cpu_exclusive = False
        set.modify(USR_SET, cpuspec, memspec, False, False)
        set.modify(SYS_SET, cpuspec_inv, memspec, False, False)
        # reset cpu exlusivity
        cset.unique_set(USR_SET).cpu_exclusive = True
        cset.unique_set(SYS_SET).cpu_exclusive = True
        log.info('--> shielding modified with:')
    # move root tasks into system set
    root_tasks = cset.unique_set('/').tasks
    log.debug("number of root tasks are: %s", len(root_tasks))
    # figure out what in root set is not a kernel thread
    tasks = []
    for task in root_tasks:
        try:
            os.readlink('/proc/'+task+'/exe')
            tasks.append(task)
        except:
            pass
    if len(tasks) != 0:
        log.info("moving %s tasks from root into system cpuset...", len(tasks))
    proc.move('root', SYS_SET, tasks, verbose)
    # move kernel theads into system set if asked for
    if kthread == 'on':
        root_tasks = cset.unique_set('/').tasks
        tasks = []
        for task in root_tasks:
            try:
                if proc.is_unbound(task): tasks.append(task)
            except:
                pass
        if len(tasks) != 0:
            log.info("kthread shield activated, moving %s tasks into system cpuset...",
                     len(tasks))
        proc.move('root', SYS_SET, tasks, verbose)
    # print out stats
    print_all_stats()
示例#2
0
         try:
             set.destroy(SYS_SET)
         except:
             pass
         log.critical(
             '--> failed to create shield, hint: do other cpusets exist?')
         raise instance
     log.info('--> activating shielding:')
 else:
     log.debug("shielding exists, modifying cpuspec")
     # note, since we're going to modify the cpu assigments to these sets,
     # they cannot be exclusive, the following modify() calls will make
     # them exclusive again
     cset.unique_set(USR_SET).cpu_exclusive = False
     cset.unique_set(SYS_SET).cpu_exclusive = False
     set.modify(USR_SET, cpuspec, memspec, False, False)
     set.modify(SYS_SET, cpuspec_inv, memspec, False, False)
     # reset cpu exlusivity
     cset.unique_set(USR_SET).cpu_exclusive = True
     cset.unique_set(SYS_SET).cpu_exclusive = True
     log.info('--> shielding modified with:')
 # move root tasks into system set
 root_tasks = cset.unique_set('/').tasks
 log.debug("number of root tasks are: %s", len(root_tasks))
 # figure out what in root set is not a kernel thread
 tasks = []
 for task in root_tasks:
     try:
         os.readlink('/proc/' + task + '/exe')
         tasks.append(task)
     except:
示例#3
0
文件: shield.py 项目: KauzClay/waggle
         # unroll
         try: set.destroy(USR_SET)
         except: pass
         try: set.destroy(SYS_SET)
         except: pass
         log.critical('--> failed to create shield, hint: do other cpusets exist?')
         raise instance
     log.info('--> activating shielding:')
 else:
     log.debug("shielding exists, modifying cpuspec")
     # note, since we're going to modify the cpu assigments to these sets,
     # they cannot be exclusive, the following modify() calls will make
     # them exclusive again
     cset.unique_set(USR_SET).cpu_exclusive = False
     cset.unique_set(SYS_SET).cpu_exclusive = False
     set.modify(USR_SET, cpuspec, memspec, False, False)
     set.modify(SYS_SET, cpuspec_inv, memspec, False, False)
     # reset cpu exlusivity
     cset.unique_set(USR_SET).cpu_exclusive = True
     cset.unique_set(SYS_SET).cpu_exclusive = True
     log.info('--> shielding modified with:')
 # move root tasks into system set
 root_tasks = cset.unique_set('/').tasks
 log.debug("number of root tasks are: %s", len(root_tasks))
 # figure out what in root set is not a kernel thread
 tasks = []
 for task in root_tasks:
     try:
         os.readlink('/proc/'+task+'/exe')
         tasks.append(task)
     except:
示例#4
0
def make_shield(cpuspec, kthread):
    memspec = '0' # FIXME: for numa, we probably want a more intelligent scheme
    log.debug("entering make_shield, cpuspec=%s kthread=%s", cpuspec, kthread)
    # create base cpusets for shield
    cset.cpuspec_check(cpuspec)
    cpuspec_inv = cset.cpuspec_inverse(cpuspec)
    try:
        shield_exists()
    except:
        log.debug("shielding does not exist, creating")
        try:
            set.create(USR_SET, cpuspec, memspec, True, False)
            set.create(SYS_SET, cpuspec_inv, memspec, True, False)
        except Exception as instance:
            # unroll
            try: set.destroy(USR_SET)
            except: pass
            try: set.destroy(SYS_SET)
            except: pass
            log.critical('--> failed to create shield, hint: do other cpusets exist?')
            raise instance
        log.info('--> activating shielding:')
    else:
        log.debug("shielding exists, modifying cpuspec")
        # note, since we're going to modify the cpu assigments to these sets,
        # they cannot be exclusive, the following modify() calls will make
        # them exclusive again
        cset.unique_set(USR_SET).cpu_exclusive = False
        cset.unique_set(SYS_SET).cpu_exclusive = False
        set.modify(USR_SET, cpuspec, memspec, False, False)
        set.modify(SYS_SET, cpuspec_inv, memspec, False, False)
        # reset cpu exlusivity
        cset.unique_set(USR_SET).cpu_exclusive = True
        cset.unique_set(SYS_SET).cpu_exclusive = True
        log.info('--> shielding modified with:')
    # move root tasks into system set
    root_tasks = cset.unique_set('/').tasks
    log.debug("number of root tasks are: %s", len(root_tasks))
    # figure out what in root set is not a kernel thread
    tasks = []
    for task in root_tasks:
        try:
            os.readlink('/proc/'+task+'/exe')
            tasks.append(task)
        except:
            pass
    if len(tasks) != 0:
        log.info("moving %s tasks from root into system cpuset...", len(tasks))
    proc.move('root', SYS_SET, tasks, verbose)
    # move kernel theads into system set if asked for
    if kthread == 'on':
        root_tasks = cset.unique_set('/').tasks
        tasks = []
        for task in root_tasks:
            try:
                if proc.is_unbound(task): tasks.append(task)
            except:
                pass
        if len(tasks) != 0:
            log.info("kthread shield activated, moving %s tasks into system cpuset...",
                     len(tasks))
        proc.move('root', SYS_SET, tasks, verbose)
    # print out stats
    print_all_stats()