From nobody Wed Nov 5 14:26:04 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153487188117263.81872002759337; Tue, 21 Aug 2018 10:18:01 -0700 (PDT) Received: from localhost ([::1]:55013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAI3-00065U-Vk for importer@patchew.org; Tue, 21 Aug 2018 13:18:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA4Z-0001zN-A0 for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA4V-0006mA-9F for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:04:02 -0400 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:53043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA4U-0006U1-Dx for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:58 -0400 Received: by mail-wm0-x232.google.com with SMTP id y139-v6so854074wmc.2 for ; Tue, 21 Aug 2018 10:03:47 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=tm/btBHjNv+Plz2ZAsHTrj0ppG0VKwzeRKILFdh3A0I=; b=uUJZZXaos87fFI8kYgsCD3Y+8QaAx087f6FRlrNPwPMf3Qc2WbAIBYRcaF44PKR0zq oUEAk9O2enZckrOI+dQ/YPMgjA5y5YGq7RqYbnZhM26EEWp75nW+BoRdAp75D/Sh/oq7 odUYJ0BU1c+jq03oqc6JNff+/TbMCbElhoRy+FJEZAvY1Yh/Dp4NENoE0oz7Jl6fDW8Y UIDx/gh13h6EPgItkSgQzHa0TUhkDIFmKWPt7SrYWX1G6NcqlpTNW+exGbKEtXv+NllI sTsqSHrxCnRG/hL5ZikcTIrO9JMewuyWLSLuA8mB+NiGtKAAh09tBYPTYTF4vtU+asOF ZwNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=tm/btBHjNv+Plz2ZAsHTrj0ppG0VKwzeRKILFdh3A0I=; b=UbZCCAl8ga8GmlsianW1ACYSqtq0PNcieZE5pQh/QRobrp12Upfmerd6wOGvUa4T5C mWrSaJXP9WPXHgJ1eelf835oaaBEHZ5W8gk9Wnf122pranvIAOSd3+4M9Y0kHD4VjmsK FATxa67PaHk2EjZOv/M3rKg0KVA+GsggWZ+4T9saOwk3NW5X2w0Cufx2aC+X8L3B8nui gq+m4AhTFhvWCTBJD/Iyvl7oCOeDQXF+5uY07sUGoxqfLR/QUITs3tP0W1nE6fJzqeXu Z8RZkyAW6lmP76OBnPPxFuv3Y2D/Nz2GAqZe7CvMQsJqWa9l3DZ+ecRvwuxNvobyVfDD vXvw== X-Gm-Message-State: APzg51DMBYVGZTTqhjHmmlfIctaNrYteqgQUDZmmqvYJcMVDuIK+a88s GTUEUKWlYb9MmYxw5twPmXUE7KbM X-Google-Smtp-Source: ANB0Vdb1IlietamEiz2MhH5iIPtm4FRq6OfizkY7ViIOrcZxn7fEKsO/pMUzoqsq05pGl5Yl4zgYBw== X-Received: by 2002:a1c:ea53:: with SMTP id i80-v6mr135028wmh.113.1534871026274; Tue, 21 Aug 2018 10:03:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:02:11 +0200 Message-Id: <1534870966-9287-40-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::232 Subject: [Qemu-devel] [PULL 39/74] rcu_queue: add RCU QTAILQ 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: "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Message-Id: <20180819091335.22863-5-cota@braap.org> Signed-off-by: Paolo Bonzini --- include/qemu/rcu_queue.h | 66 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 66 insertions(+) diff --git a/include/qemu/rcu_queue.h b/include/qemu/rcu_queue.h index e0395c9..904b337 100644 --- a/include/qemu/rcu_queue.h +++ b/include/qemu/rcu_queue.h @@ -193,6 +193,72 @@ extern "C" { (var) && ((next) =3D atomic_rcu_read(&(var)->field.sqe_next), 1);= \ (var) =3D (next)) =20 +/* + * RCU tail queue + */ + +/* Tail queue access methods */ +#define QTAILQ_EMPTY_RCU(head) (atomic_read(&(head)->tqh_first) =3D= =3D NULL) +#define QTAILQ_FIRST_RCU(head) atomic_rcu_read(&(head)->tqh_first) +#define QTAILQ_NEXT_RCU(elm, field) atomic_rcu_read(&(elm)->field.tqe_nex= t) + +/* Tail queue functions */ +#define QTAILQ_INSERT_HEAD_RCU(head, elm, field) do { \ + (elm)->field.tqe_next =3D (head)->tqh_first; \ + if ((elm)->field.tqe_next !=3D NULL) { \ + (head)->tqh_first->field.tqe_prev =3D &(elm)->field.tqe_next; \ + } else { \ + (head)->tqh_last =3D &(elm)->field.tqe_next; \ + } \ + atomic_rcu_set(&(head)->tqh_first, (elm)); \ + (elm)->field.tqe_prev =3D &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_TAIL_RCU(head, elm, field) do { \ + (elm)->field.tqe_next =3D NULL; \ + (elm)->field.tqe_prev =3D (head)->tqh_last; \ + atomic_rcu_set((head)->tqh_last, (elm)); \ + (head)->tqh_last =3D &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_AFTER_RCU(head, listelm, elm, field) do { \ + (elm)->field.tqe_next =3D (listelm)->field.tqe_next; \ + if ((elm)->field.tqe_next !=3D NULL) { \ + (elm)->field.tqe_next->field.tqe_prev =3D &(elm)->field.tqe_next; \ + } else { \ + (head)->tqh_last =3D &(elm)->field.tqe_next; \ + } \ + atomic_rcu_set(&(listelm)->field.tqe_next, (elm)); \ + (elm)->field.tqe_prev =3D &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_BEFORE_RCU(listelm, elm, field) do { \ + (elm)->field.tqe_prev =3D (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next =3D (listelm); \ + atomic_rcu_set((listelm)->field.tqe_prev, (elm)); \ + (listelm)->field.tqe_prev =3D &(elm)->field.tqe_next; \ + } while (/*CONSTCOND*/0) + +#define QTAILQ_REMOVE_RCU(head, elm, field) do { \ + if (((elm)->field.tqe_next) !=3D NULL) { \ + (elm)->field.tqe_next->field.tqe_prev =3D (elm)->field.tqe_prev; \ + } else { \ + (head)->tqh_last =3D (elm)->field.tqe_prev; \ + } \ + atomic_set((elm)->field.tqe_prev, (elm)->field.tqe_next); \ + (elm)->field.tqe_prev =3D NULL; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_FOREACH_RCU(var, head, field) \ + for ((var) =3D atomic_rcu_read(&(head)->tqh_first); \ + (var); \ + (var) =3D atomic_rcu_read(&(var)->field.tqe_next)) + +#define QTAILQ_FOREACH_SAFE_RCU(var, head, field, next) \ + for ((var) =3D atomic_rcu_read(&(head)->tqh_first); = \ + (var) && ((next) =3D atomic_rcu_read(&(var)->field.tqe_next), 1);= \ + (var) =3D (next)) + #ifdef __cplusplus } #endif --=20 1.8.3.1