Print this page
6138 don't abuse atomic_cas_*

*** 66,76 **** */ void mem_node_add_slice(pfn_t start, pfn_t end) { int mnode; - mnodeset_t newmask, oldmask; /* * DR will pass us the first pfn that is allocatable. * We need to round down to get the real start of * the slice. --- 66,75 ----
*** 93,107 **** mem_node_config[mnode].physmax = end; } else { mem_node_config[mnode].physbase = start; mem_node_config[mnode].physmax = end; atomic_inc_16(&num_memnodes); ! do { ! oldmask = memnodes_mask; ! newmask = memnodes_mask | (1ull << mnode); ! } while (atomic_cas_64(&memnodes_mask, oldmask, newmask) != ! oldmask); } /* * Let the common lgrp framework know about the new memory */ lgrp_config(LGRP_CONFIG_MEM_ADD, mnode, MEM_NODE_2_LGRPHAND(mnode)); --- 92,102 ---- mem_node_config[mnode].physmax = end; } else { mem_node_config[mnode].physbase = start; mem_node_config[mnode].physmax = end; atomic_inc_16(&num_memnodes); ! atomic_or_64(&memnodes_mask, 1ull << mnode); } /* * Let the common lgrp framework know about the new memory */ lgrp_config(LGRP_CONFIG_MEM_ADD, mnode, MEM_NODE_2_LGRPHAND(mnode));
*** 117,127 **** void mem_node_del_slice(pfn_t start, pfn_t end) { int mnode; pgcnt_t delta_pgcnt, node_size; - mnodeset_t omask, nmask; if (mem_node_physalign) { start &= ~(btop(mem_node_physalign) - 1); end = roundup(end, btop(mem_node_physalign)) - 1; } --- 112,121 ----
*** 154,167 **** /* * Delete the whole node. */ ASSERT(MNODE_PGCNT(mnode) == 0); ! do { ! omask = memnodes_mask; ! nmask = omask & ~(1ull << mnode); ! } while (atomic_cas_64(&memnodes_mask, omask, nmask) != omask); atomic_dec_16(&num_memnodes); mem_node_config[mnode].exists = 0; } } --- 148,158 ---- /* * Delete the whole node. */ ASSERT(MNODE_PGCNT(mnode) == 0); ! atomic_and_64(&memnodes_mask, ~(1ull << mnode)); atomic_dec_16(&num_memnodes); mem_node_config[mnode].exists = 0; } }
*** 212,222 **** */ int mem_node_alloc() { int mnode; - mnodeset_t newmask, oldmask; /* * Find an unused memnode. Update it atomically to prevent * a first time memnode creation race. */ --- 203,212 ----
*** 229,242 **** panic("Out of free memnodes\n"); mem_node_config[mnode].physbase = (uint64_t)-1; mem_node_config[mnode].physmax = 0; atomic_inc_16(&num_memnodes); ! do { ! oldmask = memnodes_mask; ! newmask = memnodes_mask | (1ull << mnode); ! } while (atomic_cas_64(&memnodes_mask, oldmask, newmask) != oldmask); return (mnode); } /* --- 219,229 ---- panic("Out of free memnodes\n"); mem_node_config[mnode].physbase = (uint64_t)-1; mem_node_config[mnode].physmax = 0; atomic_inc_16(&num_memnodes); ! atomic_or_64(&memnodes_mask, 1ull << mnode); return (mnode); } /*