From nobody Wed Nov 5 10:09:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534670178499726.5770709655233; Sun, 19 Aug 2018 02:16:18 -0700 (PDT) Received: from localhost ([::1]:42137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJog-0003z6-Fn for importer@patchew.org; Sun, 19 Aug 2018 05:16:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1frJmS-0002N2-7R for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1frJmO-0000cO-Qq for qemu-devel@nongnu.org; Sun, 19 Aug 2018 05:13:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:56651) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1frJmO-0000bx-K8; Sun, 19 Aug 2018 05:13:48 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2FC6921B10; Sun, 19 Aug 2018 05:13:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 19 Aug 2018 05:13:48 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7776B1025D; Sun, 19 Aug 2018 05:13:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=0KjbXVqCCBCfrs SZYrSMztKsFeEBc7OXmevoNtrMLiQ=; b=vRA+fnld39CxqYaq0tyNLUY2YLi1kG tvhOrFgUYpm8q9y1K/fWQ8sWFj7pm1jcPQlhF5M2FM3DIvStiFILcFYmhg17/Rc8 QbaR93pgf8vSEY0ocbpqfP+j0cTO6ZsFll1y45t9MLJb2cDLxm99mvVVc9YXaN3P VgSt1X9Y9TObE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=0KjbXVqCCBCfrsSZYrSMztKsFeEBc7OXmevoNtrMLiQ=; b=uzM4vgMQ eajyk7draN08QsvC0zQYyEBy1GUnO1wfQnzlLgXqi6l1FATwfOKfrwOghb8SfLtz gx3RZ/sSL8Bbex4Ya9nhMtz7jv0TIPsz4vsFDF+Thjnxn9Pikm7vt9UoU/2b2MwJ Xp+fwurXsAQY6hWSiWoIh74VtRxh0cq/5H7+Yn573mFXowtxURNICwef5bXJ6/Ti df86NwzOTDijJv5B4yeBgUwFFfqPEMpZNl0InLyF9yNHbtfcls3uDZfyGMxjZJJT E2hMfwoVwd5sUjxirSWvVnTQxBFawL4KW7tSEda7/icU3jc0vvR5UclL9xULlbl3 YuqiJFHEeuuqNw== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 19 Aug 2018 05:13:27 -0400 Message-Id: <20180819091335.22863-4-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180819091335.22863-1-cota@braap.org> References: <20180819091335.22863-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v2 03/11] rcu_queue: add RCU QSIMPLEQ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Crosthwaite , Riku Voipio , Alexander Graf , Laurent Vivier , qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota --- include/qemu/rcu_queue.h | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h index 6881ea5274..e0395c989a 100644 --- a/include/qemu/rcu_queue.h +++ b/include/qemu/rcu_queue.h @@ -128,6 +128,71 @@ extern "C" { ((next_var) =3D atomic_rcu_read(&(var)->field.le_next), 1); \ (var) =3D (next_var)) =20 +/* + * RCU simple queue + */ + +/* Simple queue access methods */ +#define QSIMPLEQ_EMPTY_RCU(head) (atomic_read(&(head)->sqh_first) =3D= =3D NULL) +#define QSIMPLEQ_FIRST_RCU(head) atomic_rcu_read(&(head)->sqh_first) +#define QSIMPLEQ_NEXT_RCU(elm, field) atomic_rcu_read(&(elm)->field.sqe_n= ext) + +/* Simple queue functions */ +#define QSIMPLEQ_INSERT_HEAD_RCU(head, elm, field) do { \ + (elm)->field.sqe_next =3D (head)->sqh_first; \ + if ((elm)->field.sqe_next =3D=3D NULL) { \ + (head)->sqh_last =3D &(elm)->field.sqe_next; \ + } \ + atomic_rcu_set(&(head)->sqh_first, (elm)); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_TAIL_RCU(head, elm, field) do { \ + (elm)->field.sqe_next =3D NULL; \ + atomic_rcu_set((head)->sqh_last, (elm)); \ + (head)->sqh_last =3D &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_AFTER_RCU(head, listelm, elm, field) do { \ + (elm)->field.sqe_next =3D (listelm)->field.sqe_next; \ + if ((elm)->field.sqe_next =3D=3D NULL) { = \ + (head)->sqh_last =3D &(elm)->field.sqe_next; \ + } \ + atomic_rcu_set(&(listelm)->field.sqe_next, (elm)); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE_HEAD_RCU(head, field) do { \ + atomic_set(&(head)->sqh_first, (head)->sqh_first->field.sqe_next); \ + if ((head)->sqh_first =3D=3D NULL) { = \ + (head)->sqh_last =3D &(head)->sqh_first; \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE_RCU(head, elm, type, field) do { \ + if ((head)->sqh_first =3D=3D (elm)) { \ + QSIMPLEQ_REMOVE_HEAD_RCU((head), field); \ + } else { \ + struct type *curr =3D (head)->sqh_first; \ + while (curr->field.sqe_next !=3D (elm)) { \ + curr =3D curr->field.sqe_next; \ + } \ + atomic_set(&curr->field.sqe_next, \ + curr->field.sqe_next->field.sqe_next); \ + if (curr->field.sqe_next =3D=3D NULL) { \ + (head)->sqh_last =3D &(curr)->field.sqe_next; \ + } \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_FOREACH_RCU(var, head, field) \ + for ((var) =3D atomic_rcu_read(&(head)->sqh_first); \ + (var); \ + (var) =3D atomic_rcu_read(&(var)->field.sqe_next)) + +#define QSIMPLEQ_FOREACH_SAFE_RCU(var, head, field, next) \ + for ((var) =3D atomic_rcu_read(&(head)->sqh_first); = \ + (var) && ((next) =3D atomic_rcu_read(&(var)->field.sqe_next), 1);= \ + (var) =3D (next)) + #ifdef __cplusplus } #endif --=20 2.17.1