--- clean/alloc.c Fri Feb 23 20:55:35 2007 +++ alloc.c Fri Feb 23 21:35:20 2007 @@ -24,33 +24,21 @@ static inline int t3_mr_ring_cons(struct mem_ring *mr, struct mem_ring_ent *mre) { - int cons, ncons, prod, rc = 0; + int cons, ncons; union prod_gen pg; KASSERT(inited, ("alloc before init")); mr->mr_try++; -retry: critical_enter(); do { cons = mr->mr_cons; pg.pg_prodgen = mr->mr_prodgen; ncons = MEM_RING_INC_CONS_IDX(cons); memcpy(mre, &mr->mr_vec[cons], sizeof(*mre)); - } while (cons != (prod = mr->mr_prod) && - (rc = atomic_cmpset_int(&mr->mr_cons, cons, ncons)) == 0); + } while (cons != mr->mr_prod && + atomic_cmpset_int(&mr->mr_cons, cons, ncons) == 0); critical_exit(); - - if (rc == 0) { - mr->mr_fail++; - } else if ((pg.u.gen == mre->mre_gen && prod > cons) || - (pg.u.gen != mre->mre_gen && prod < cons)) { - /* - * We read this after prod was incremented but - * ring entry update occurred - */ - printf("lost race - retrying\n"); - goto retry; - } + mr->mr_fail++; if (mr->mr_dmat) { KASSERT(vtophys(mre->mre_mbuf->m_data) == mre->mre_ds.ds_addr, @@ -59,14 +47,11 @@ } KASSERT((uintptr_t)mre->mre_mbuf > PAGE_SIZE, ("bad mbuf value in cons mbuf=%p idx=%d", mre->mre_mbuf, cons)); - - return (rc == 0); } static int t3_mr_ring_prod(struct mem_ring *mr, struct mem_ring_ent *mre) { - int cons, rc = 0; union prod_gen pg, npg; if (mr->mr_dmat) { @@ -82,14 +67,10 @@ npg.u.prod = 0; } mre->mre_gen = npg.u.gen; - } while (npg.u.prod != (cons = mr->mr_cons) && - (rc = atomic_cmpset_int(&mr->mr_prodgen, pg.pg_prodgen, npg.pg_prodgen)) == 0); + } while (npg.u.prod != mr->mr_cons && + atomic_cmpset_int(&mr->mr_prodgen, pg.pg_prodgen, npg.pg_prodgen) == 0); critical_exit(); - - if (rc) - memcpy(&mr->mr_vec[npg.u.prod], mre, sizeof(*mre)); - - return (rc == 0); + memcpy(&mr->mr_vec[npg.u.prod], mre, sizeof(*mre)); } static inline void