Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Oct 2018 18:40:06 +0300
From:      Lev Serebryakov <lev@FreeBSD.org>
To:        freebsd-hackers@FreeBSD.org
Subject:   What are ck_queue.h guarantees?
Message-ID:  <1551957390.20181013184006@serebryakov.spb.ru>

next in thread | raw e-mail | index | archive | help
Hello Freebsd-hackers,

  Concurrency Kit documentation says:

====
ck_queue is a queue.h-compatible implementation of many-reader-single-
writer queues. It allows for safe concurrent iteration, peeking and read-
side access in the presence of a single concurrent writer without any
usage of locks.
====

 But in all places at kernel I peeked, CK_XXXX macros are protected by
locks. Yes, even read ones.

  For example, there are a lot of addresses enumeration under locks in
 networks drivers, like this:

if_maddr_rlock(ifp);
CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
    if (inm->ifma_addr->sa_family != AF_LINK)
        continue;
    crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
        inm->ifma_addr), ETHER_ADDR_LEN);

    /* Just want the 6 most significant bits. */
    crc >>= 26;

    /* Set the corresponding bit in the filter. */
    hash[crc >> 4] |= 1 << (crc & 0xf);
}
if_maddr_runlock(ifp);

  Why is it so? Why do we bother to use CK_XXX API (which adds all needed
barriers and uses CASes) if all accesses are protected by locks, anyway?

-- 
Best regards,
 Lev                          mailto:lev@FreeBSD.org




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1551957390.20181013184006>