// int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid,
//                                    const libxl_bitmap *cpumap);
171246
func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint32, Cpumap Bitmap) (err error) {
	err = Ctx.CheckOpen()
	if err != nil {
		return
	}

	cbm := Cpumap.toC()
	defer C.libxl_bitmap_dispose(&cbm)

	ret := C.libxl_cpupool_cpuremove_cpumap(Ctx.ctx, C.uint32_t(Poolid), &cbm)
	if ret != 0 {
		err = Error(-ret)
		return
	}

	return
}
82900
func (c CPUMap) Sub(q CPUMap) {
	for label, value := range q {
		if _, ok := c[label]; ok {
			c[label] -= value
		}
	}
}
963896
func (d CPUDetails) CPUsInCore(id int) cpuset.CPUSet {
	b := cpuset.NewBuilder()
	for cpu, info := range d {
		if info.CoreID == id {
			b.Add(cpu)
		}
	}
	return b.Result()
}
250463
func (pool *TxPool) demoteUnexecutables() {
	// Iterate over all accounts and demote any non-executable transactions
	for addr, list := range pool.pending {
		nonce := pool.currentState.GetNonce(addr)

		// Drop all transactions that are deemed too old (low nonce)
		for _, tx := range list.Forward(nonce) {
			hash := tx.Hash()
			log.Trace("Removed old pending transaction", "hash", hash)
			pool.all.Remove(hash)
			pool.priced.Removed()
		}
		// Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
		drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas)
		for _, tx := range drops {
			hash := tx.Hash()
			log.Trace("Removed unpayable pending transaction", "hash", hash)
			pool.all.Remove(hash)
			pool.priced.Removed()
			pendingNofundsCounter.Inc(1)
		}
		for _, tx := range invalids {
			hash := tx.Hash()
			log.Trace("Demoting pending transaction", "hash", hash)
			pool.enqueueTx(hash, tx)
		}
		// If there's a gap in front, alert (should never happen) and postpone all transactions
		if list.Len() > 0 && list.txs.Get(nonce) == nil {
			for _, tx := range list.Cap(0) {
				hash := tx.Hash()
				log.Error("Demoting invalidated transaction", "hash", hash)
				pool.enqueueTx(hash, tx)
			}
		}
		// Delete the entire queue entry if it became empty.
		if list.Empty() {
			delete(pool.pending, addr)
			delete(pool.beats, addr)
		}
	}
}
342809
func (s CPUSet) Filter(predicate func(int) bool) CPUSet {
	b := NewBuilder()
	for cpu := range s.elems {
		if predicate(cpu) {
			b.Add(cpu)
		}
	}
	return b.Result()
}
591270
func (b *BigIP) DeletePoolMember(pool string, member string) error {
	return b.delete(uriLtm, uriPool, pool, uriPoolMember, member)
}
336066
func (client *peerRESTClient) CPULoadInfo() (info ServerCPULoadInfo, err error) {
	respBody, err := client.call(peerRESTMethodCPULoadInfo, nil, nil, -1)
	if err != nil {
		return
	}
	defer http.DrainBody(respBody)
	err = gob.NewDecoder(respBody).Decode(&info)
	return info, err
}
951891
func (uvm *UtilityVM) normalizeProcessorCount(requested int32) {
	hostCount := int32(runtime.NumCPU())
	if requested > hostCount {
		logrus.WithFields(logrus.Fields{
			logfields.UVMID: uvm.id,
		}).Warningf("Changing user requested CPUCount: %d to current number of processors: %d",
			requested,
			hostCount)
		uvm.processorCount = hostCount
	} else {
		uvm.processorCount = requested
	}
}
979037
func RemoveGlobalMapping(id uint32) error {
	gpm, err := OpenCallMap()
	if err == nil {
		k := plumbingKey{
			key: id,
		}
		err = gpm.Map.Delete(&k)
		gpm.Close()
	}

	return err
}
199151
func Serialize(cpus *cpux.CPUs) (p []byte) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std = NewProfiler()
	}
	return std.Serialize(cpus)
}
1115592
func Deserialize(p []byte) *cpux.CPUs {
	fcpus := structs.GetRootAsCPUs(p, 0)
	l := fcpus.CPULength()
	cpus := &cpux.CPUs{}
	fCPU := &structs.CPU{}
	fCache := &structs.CacheInf{}
	cpu := cpux.CPU{}
	cpus.Sockets = fcpus.Sockets()
	cpus.Possible = string(fcpus.Possible())
	cpus.Online = string(fcpus.Online())
	cpus.Present = string(fcpus.Present())
	for i := 0; i < l; i++ {
		if !fcpus.CPU(fCPU, i) {
			continue
		}
		cpu.PhysicalPackageID = fCPU.PhysicalPackageID()
		cpu.CoreID = fCPU.CoreID()
		cpu.MHzMin = fCPU.MHzMin()
		cpu.MHzMax = fCPU.MHzMax()
		caches := fCPU.CacheLength()
		cpu.CacheIDs = make([]string, 0, caches)
		cpu.Cache = make(map[string]string, caches)
		for j := 0; j < caches; j++ {
			if !fCPU.Cache(fCache, j) {
				continue
			}
			cpu.CacheIDs = append(cpu.CacheIDs, string(fCache.ID()))
			cpu.Cache[cpu.CacheIDs[j]] = string(fCache.Size())
		}
		cpus.CPU = append(cpus.CPU, cpu)
	}
	return cpus
}
673138
func CpuInfo(cpu int, property string) string {
	if cpuInfo == nil {
		loadCpuInfo()
	}

	return cpuInfo[fmt.Sprintf("%d:%s", cpu, property)]
}
380210
func (pool *AddressBasedPool) RemoveConn(addr string) {
	pool.Lock()
	if conn, ok := pool.conns[addr]; ok {
		conn.Close()
		delete(pool.conns, addr)
	}
	pool.Unlock()
}
1114981
func (Ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu int) (err error) {
	err = Ctx.CheckOpen()
	if err != nil {
		return
	}

	ret := C.libxl_cpupool_cpuadd(Ctx.ctx, C.uint32_t(Poolid), C.int(Cpu))
	if ret != 0 {
		err = Error(-ret)
		return
	}

	return
}
743962
func (c *ServicedCli) cmdPoolRemove(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "remove")
	}

	for _, id := range args {
		if p, err := c.driver.GetResourcePool(id); err != nil {
			fmt.Fprintf(os.Stderr, "%s: %s\n", id, err)
		} else if p == nil {
			fmt.Fprintf(os.Stderr, "%s: pool not found", id)
		} else if err := c.driver.RemoveResourcePool(id); err != nil {
			fmt.Fprintf(os.Stderr, "%s: %s\n", id, err)
		} else {
			fmt.Println(id)
		}
	}
}
1132690
func (v *Value) ReplaceObjxMap(replacer func(int, Map) Map) *Value {
	arr := v.MustObjxMapSlice()
	replaced := make([](Map), len(arr))
	v.EachObjxMap(func(index int, val Map) bool {
		replaced[index] = replacer(index, val)
		return true
	})
	return &Value{data: replaced}
}
1199433
func (prof *Profiler) cpuXPath(x int) string {
	return filepath.Join(prof.cpuPath, fmt.Sprintf("cpu%d", x))
}