Print this page
6138 don't abuse atomic_cas_*

*** 69,79 **** 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. --- 69,78 ----
*** 96,110 **** 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); } /* * Inform the common lgrp framework about the new memory */ --- 95,105 ---- 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); } /* * Inform the common lgrp framework about the new memory */
*** 121,131 **** 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; } --- 116,125 ----
*** 157,170 **** /* * 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; } } --- 151,161 ---- /* * 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; } }
*** 221,231 **** */ 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. */ --- 212,221 ----
*** 238,251 **** panic("Out of free memnodes\n"); mem_node_config[mnode].physbase = (pfn_t)-1l; 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); } /* --- 228,238 ---- panic("Out of free memnodes\n"); mem_node_config[mnode].physbase = (pfn_t)-1l; mem_node_config[mnode].physmax = 0; atomic_inc_16(&num_memnodes); ! atomic_or_64(&memnodes_mask, 1ull << mnode); return (mnode); } /*