From nobody Thu Nov 13 03:20:25 2025 Delivered-To: importer@patchew.org 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576516203; cv=none; d=zohomail.com; s=zohoarc; b=Tpj9TIM48jm5Wa4nUsT/9PDZOySmAklEaLLYmj6Qd3ru70prueLgaYlKEvw53z+g1GqJioUuV58R8aDEXpB/CjucwDBHexJRRdhGvfBZrXq0i5FRfa7GCAmUFISs2kkF48VccZghNpeTts5wBhRiBgKXGtm/eGQH778mtc9EkuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576516203; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PMUWoCpuqKP+tFU4xIk4lPZAxU6QOkIu0guoobq7qFU=; b=TFE/9RzqDCZu22Z/GVqV5HDwkLOaIdn3/LUt0SdjqHiggAlFujffUD65OnznqP32bcpg95lxK00pVqXRjQ2QA//3YNaCqwLo6eACbCpDF6FFhND5GoYl40woVMJOtzhnInEhMTMQY0asdlzZy5UTGBSlNUghzzLXYMdZOWF1LPw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576516203130714.347258934697; Mon, 16 Dec 2019 09:10:03 -0800 (PST) Received: from localhost ([::1]:57134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igtsf-0005VP-Ip for importer@patchew.org; Mon, 16 Dec 2019 12:10:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57521) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igtFl-00060T-Q7 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igtFk-0000hy-N5 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:49 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:37047) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igtFj-0000dK-US for qemu-devel@nongnu.org; Mon, 16 Dec 2019 11:29:48 -0500 Received: by mail-wm1-x341.google.com with SMTP id f129so7410565wmf.2 for ; Mon, 16 Dec 2019 08:29:47 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id q68sm19962334wme.14.2019.12.16.08.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2019 08:29:45 -0800 (PST) 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=PMUWoCpuqKP+tFU4xIk4lPZAxU6QOkIu0guoobq7qFU=; b=C9sOyLQpIf9UG8d9SMxCbzTpCG4ty2fqSJZhYNSXG3jYoW49sUByVo8/7lyBJVZlmu tt6TUA3uuSTp/xroFqbWPzK4/D+9yxDomNBQTy2ofEfgvuYOLXM4ZGz8C0TMpXyxJs2r HMiZmb+NvhNjWtGu0r/SGpwuHrgumUJFSQTgLwvIRrBgQC7J6dsI/KK8nRXvAa32LH5y eOqbxJDN+U7cDmRl8iL0/qM27Kl+A/AuLigA+KCQLMtyRQbS8w/txju8JrUJP6d+n4CA G/aiblgelJNslnuNBQ3ytOQ8OZuaKjs8YYJqIlPYDjk2ycs9H99950koFphAyWYWirX6 STPQ== 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=PMUWoCpuqKP+tFU4xIk4lPZAxU6QOkIu0guoobq7qFU=; b=AWryTgHukShGm3KHN0jvREPWJ2Q81wNYn26QJ3kBsqguYvfVHnNlxW9Ch9yUqnwQJg QbnOGxlYcN8gKTd5PJfFUtIFiSGZx5Bsp1mxmTFwVOX26EJX6bYoPj7n2Ds60EfOaG2K 6hn6io32hIpWof4wgqMgxqPxsbuIkmvTgFknxPmbS98HiQAxH9pd4klvPXZb8TcRD/sV O9e8q47s/2PiabdX0pvQnLniTZZED0+GO4aRG0wYa2hLl9cjy5AWrYdrzvXqTIdSKZEo ZK8JBOlIcaUgnjEsxIdbcEltwyAGDFm7CC5pEt1BKLAHLECISmhRKBQRSzHP2xgfxXTM zy/Q== X-Gm-Message-State: APjAAAXPhk7fXr2ZSgQzfLxS6HmqjJ1U8HRMD6MW6crQPcBLzP3Ihuz0 2G43st3Fgd2btgaEGKS+oN869YYm X-Google-Smtp-Source: APXvYqxdKGIP9cMmvM5dLh6wVeaP0szbeL01d62k1FoRC5gckefhUxKFuVPBXy5n/bW9qi4+vwxiRA== X-Received: by 2002:a1c:740b:: with SMTP id p11mr33186397wmc.78.1576513786750; Mon, 16 Dec 2019 08:29:46 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 59/62] hyperv: Use auto rcu_read macros Date: Mon, 16 Dec 2019 17:28:43 +0100 Message-Id: <1576513726-53700-60-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576513726-53700-1-git-send-email-pbonzini@redhat.com> References: <1576513726-53700-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:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Use RCU_READ_LOCK_GUARD and WITH_RCU_READ_LOCK_GUARD to replace the manual rcu_read_(un)lock calls. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- hw/hyperv/hyperv.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index 6ebf31c..da8ce82 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -546,14 +546,14 @@ uint16_t hyperv_hcall_post_message(uint64_t param, bo= ol fast) } =20 ret =3D HV_STATUS_INVALID_CONNECTION_ID; - rcu_read_lock(); - QLIST_FOREACH_RCU(mh, &msg_handlers, link) { - if (mh->conn_id =3D=3D (msg->connection_id & HV_CONNECTION_ID_MASK= )) { - ret =3D mh->handler(msg, mh->data); - break; + WITH_RCU_READ_LOCK_GUARD() { + QLIST_FOREACH_RCU(mh, &msg_handlers, link) { + if (mh->conn_id =3D=3D (msg->connection_id & HV_CONNECTION_ID_= MASK)) { + ret =3D mh->handler(msg, mh->data); + break; + } } } - rcu_read_unlock(); =20 unmap: cpu_physical_memory_unmap(msg, len, 0, 0); @@ -619,7 +619,6 @@ int hyperv_set_event_flag_handler(uint32_t conn_id, Eve= ntNotifier *notifier) =20 uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) { - uint16_t ret; EventFlagHandler *handler; =20 if (unlikely(!fast)) { @@ -645,15 +644,12 @@ uint16_t hyperv_hcall_signal_event(uint64_t param, bo= ol fast) return HV_STATUS_INVALID_HYPERCALL_INPUT; } =20 - ret =3D HV_STATUS_INVALID_CONNECTION_ID; - rcu_read_lock(); + RCU_READ_LOCK_GUARD(); QLIST_FOREACH_RCU(handler, &event_flag_handlers, link) { if (handler->conn_id =3D=3D param) { event_notifier_set(handler->notifier); - ret =3D 0; - break; + return 0; } } - rcu_read_unlock(); - return ret; + return HV_STATUS_INVALID_CONNECTION_ID; } --=20 1.8.3.1