a query in mb_free_ext()

Vijay Singh vijju.singh at gmail.com
Fri Aug 17 03:33:14 UTC 2012


Does anyone here understand this bit of code in mb_free_ext()?

        /* Free attached storage if this mbuf is the only reference to it. */
        if (*(m->m_ext.ref_cnt) == 1 ||
            atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
                switch (m->m_ext.ext_type) {
                case EXT_PACKET:        /* The packet zone is special. */
                        if (*(m->m_ext.ref_cnt) == 0)
                                *(m->m_ext.ref_cnt) = 1;
                        uma_zfree(zone_pack, m);
                        return;         /* Job done. */

Why would *(m->m_ext.ref_cnt) == 0 be true when the if condition
checks only for ref_cnt to be 1? Should the atomic_fetchadd_int() be
checked for <= 1?

Also, why is the packet zone special? Any history here?

-vijay


More information about the freebsd-net mailing list