From nobody Sat Jul 12 14:49:36 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678142081; cv=none; d=zohomail.com; s=zohoarc; b=FcZW25IodWkpC9VzCnTgpWrGnnnohPMGRtHGjrDAO5QBjRVjcoUXRFK9K8IHFmNecPOFOmnZOxmnahyZf7kRgMs0fyJWNKITqsci20qR4qsw9T/xe9BdekQ+Q0e+yGnxgmyE+I9/Gb9zvXE/AK6m+YSoVrfQEMrAnrWCisntwRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678142081; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y1rNPAcKSjGM/N+sMNI8BsxsPy3EoZ3hfvlt7wnsSHM=; b=IbVtsizNFGE3v6i5spUzFGLc4ZvUNTmePsWmkC2xIBhWjoBJHlPto4713h0jY3CcDm+aDseWOBQN6qrOMz1AlBhkm9Rh47upP7qcUcscXPDKgTHH8MWLL/HpRJd0T5awoMdGvzwyGxoLT5dHpb7vUuI+0lxf+y9IBlLma34GwwQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678142081700540.2515150425504; Mon, 6 Mar 2023 14:34:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZJOp-0004Tj-8e; Mon, 06 Mar 2023 17:33:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZJOo-0004TQ-Bf for qemu-devel@nongnu.org; Mon, 06 Mar 2023 17:33:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZJOn-0003ZO-3z for qemu-devel@nongnu.org; Mon, 06 Mar 2023 17:33:42 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-tjswA7ypPj2BFnwq-E78nQ-1; Mon, 06 Mar 2023 17:33:39 -0500 Received: by mail-ed1-f71.google.com with SMTP id r9-20020a05640251c900b004d4257341c2so10198259edd.19 for ; Mon, 06 Mar 2023 14:33:38 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ay24-20020a170906d29800b0090953b9da51sm5111325ejb.194.2023.03.06.14.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 14:33:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678142020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y1rNPAcKSjGM/N+sMNI8BsxsPy3EoZ3hfvlt7wnsSHM=; b=hBE0cOC3JQbcNl2PRKEZPnOtjnX265FRPljIvFVDoVf6aOOJbYszYtXXmQy0rXqU9J4v1t XtCFJtNBAgJcJgnrlu+yB+J/B5eN1vG5z9YSS7tsaWp/Pd9D/HAytDbBW6lb9n9s5aw1B0 ZGeb/kzCzhDIeSBbNwbhsjHAzlqavLQ= X-MC-Unique: tjswA7ypPj2BFnwq-E78nQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678142017; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y1rNPAcKSjGM/N+sMNI8BsxsPy3EoZ3hfvlt7wnsSHM=; b=u59cPZbKvFLajvKND2orYwy+Key8dzjlN7RgNL/CA9S5xsQcR6k5Jwj7cYVSOaXJF6 52YiFNHb7SyVKMLW4vWrSg1hPpDBvoRf6rUiSvdkVl++EJVN/VJLPcAj6wIcdMu7ilEm cMTqhtrgunD2a8ekYOBz6z0nMT7fC0urYqPQbRU1GYHynSIeHe18VkW8/Nw5Ajni+kDf 3tQWfJE+YGOU+dRVa3Kd8cAFMmXAZyIaCeE05yMbyVdPsLwk/Y/cBpeN40mMcZHlzBCw UOg86JXJS769C230++10RjatfpEVwCZ+fNncG4cWomrXJ4TECypdJ1H69bs8aOJYdtpj IwmQ== X-Gm-Message-State: AO0yUKXB5cpwvj1Faq9nDo0WF7Q7SQTxKfgpyHXNVGYEmzUzrrgSRS74 9L0sUep29bPcUMYlQhvGT9GbvxQki6QDRG8mzAI0KwNUa9FoEH484vkWYpY3+W86Jq7IPDYTObj Ar/MP6TQTyZGsS6l98e3ZJTAwky0yBE0NKh8T9aCQ8QUHU15Xb/Q8fP4KHNOH6AQzRKTeWaXiKq s= X-Received: by 2002:a17:906:85c3:b0:881:f614:44ed with SMTP id i3-20020a17090685c300b00881f61444edmr12876635ejy.30.1678142017597; Mon, 06 Mar 2023 14:33:37 -0800 (PST) X-Google-Smtp-Source: AK7set/vTmi9j+MVwfqTUWwYHjVvj3Z4BdZWRStWGuwU751O2iiGBCHbVUss2vDVlBkd+sJ6TF5EIA== X-Received: by 2002:a17:906:85c3:b0:881:f614:44ed with SMTP id i3-20020a17090685c300b00881f61444edmr12876617ejy.30.1678142017330; Mon, 06 Mar 2023 14:33:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: gshan@redhat.com, eesposit@redhat.com, david@redhat.com, stefanha@redhat.com, cohuck@redhat.com, eauger@redhat.com, richard.henderson@linaro.org Subject: [PATCH v2 9/9] async: clarify usage of barriers in the polling case Date: Mon, 6 Mar 2023 23:33:06 +0100 Message-Id: <20230306223306.84383-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230306223306.84383-1-pbonzini@redhat.com> References: <20230306223306.84383-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678142083319100001 Content-Type: text/plain; charset="utf-8" Explain that aio_context_notifier_poll() relies on aio_notify_accept() to catch all the memory writes that were done before ctx->notified was set to true. Signed-off-by: Paolo Bonzini Reviewed-by: David Hildenbrand Reviewed-by: Stefan Hajnoczi --- util/async.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util/async.c b/util/async.c index e4b494150e7d..21016a1ac7c1 100644 --- a/util/async.c +++ b/util/async.c @@ -474,8 +474,9 @@ void aio_notify_accept(AioContext *ctx) qatomic_set(&ctx->notified, false); =20 /* - * Write ctx->notified before reading e.g. bh->flags. Pairs with smp_= wmb - * in aio_notify. + * Order reads of ctx->notified (in aio_context_notifier_poll()) and t= he + * above clearing of ctx->notified before reads of e.g. bh->flags. Pa= irs + * with smp_wmb() in aio_notify. */ smp_mb(); } @@ -498,6 +499,11 @@ static bool aio_context_notifier_poll(void *opaque) EventNotifier *e =3D opaque; AioContext *ctx =3D container_of(e, AioContext, notifier); =20 + /* + * No need for load-acquire because we just want to kick the + * event loop. aio_notify_accept() takes care of synchronizing + * the event loop with the producers. + */ return qatomic_read(&ctx->notified); } =20 --=20 2.39.1