From patchwork Mon Dec 16 16:28:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1210658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C9sOyLQp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47c7634Ngwz9sRM for ; Tue, 17 Dec 2019 04:08:59 +1100 (AEDT) Received: from localhost ([::1]:57076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igtrc-0003l4-U6 for incoming@patchwork.ozlabs.org; Mon, 16 Dec 2019 12:08:56 -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) 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) 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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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, bool fast) } ret = HV_STATUS_INVALID_CONNECTION_ID; - rcu_read_lock(); - QLIST_FOREACH_RCU(mh, &msg_handlers, link) { - if (mh->conn_id == (msg->connection_id & HV_CONNECTION_ID_MASK)) { - ret = mh->handler(msg, mh->data); - break; + WITH_RCU_READ_LOCK_GUARD() { + QLIST_FOREACH_RCU(mh, &msg_handlers, link) { + if (mh->conn_id == (msg->connection_id & HV_CONNECTION_ID_MASK)) { + ret = mh->handler(msg, mh->data); + break; + } } } - rcu_read_unlock(); unmap: cpu_physical_memory_unmap(msg, len, 0, 0); @@ -619,7 +619,6 @@ int hyperv_set_event_flag_handler(uint32_t conn_id, EventNotifier *notifier) uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) { - uint16_t ret; EventFlagHandler *handler; if (unlikely(!fast)) { @@ -645,15 +644,12 @@ uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) return HV_STATUS_INVALID_HYPERCALL_INPUT; } - ret = HV_STATUS_INVALID_CONNECTION_ID; - rcu_read_lock(); + RCU_READ_LOCK_GUARD(); QLIST_FOREACH_RCU(handler, &event_flag_handlers, link) { if (handler->conn_id == param) { event_notifier_set(handler->notifier); - ret = 0; - break; + return 0; } } - rcu_read_unlock(); - return ret; + return HV_STATUS_INVALID_CONNECTION_ID; }