From patchwork Tue May 7 14:34:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mattias Nissler X-Patchwork-Id: 795218 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:34e:ceec:bfcd with SMTP id k28csp330016wrc; Tue, 7 May 2024 07:37:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUc5lRNDmU1ZguwgKT8u8oEUQ/7RhH11DgbzHazyViF8PtMJw1idWeXj7TARjfwX7PVQ46ZWRxUAOepLp82f98 X-Google-Smtp-Source: AGHT+IF282of1wyTBOr0nDx8zbermRLrayQ5eA7lmpA0B7Ga7nM5z231qM+CrrXdZpLP/0CcV0QQ X-Received: by 2002:a67:fc8a:0:b0:47c:14bd:7ccd with SMTP id x10-20020a67fc8a000000b0047c14bd7ccdmr10054395vsp.15.1715092661031; Tue, 07 May 2024 07:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715092661; cv=none; d=google.com; s=arc-20160816; b=Mq4awoqEFpE3/hZ33ie4wmIq9iUd2PAu23FeZV4rP6YSC/+85z3xz1PpvVM/9dVyav J4fo8//URWvdh3AhUa6bkD0AykPLLUrhyH2QoXNY1LGjZe+7D2gzZxAQZgcYavO5bQWv SwKFJK5yqh+AIszOyhIbo0yRyr7vp86MRXDQ7GsPy5rJ27T1OnMvCg7FrYu+1MZ7EDHf WIfPX0CksZBj7mwhgf2xasBIBQer9uEfu8BwovsnByLA9XvAY11USS8L3GY49+1rZxTc Nevw28e27FORYhWpma8v8YReutU8vDvamhLZYmqhLBuh0Zjj7NjACdWn3KWBKHMSliXw 8WCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s8UQwJWo0cr2ZRaC4+6kRjAHtdNM0XskKMAiaHBTEPQ=; fh=ySwHlx+BRgjkXXLiCOKoBNZv1ecHsUzSGNivnI6gmi0=; b=ZHRGWSdvWjFENElquWolgfVM8/U5ouy+jxE8QW5qgjAlqqU+xgD1i5RdPBuymu7nKh 232N6+kZKs6uS9W+NZ80T+iSf31oRtxoxA7XCPtIcy+2aXAXYm/vOudUT3xCzd8Y9sUf 6Z71iyer+y57B6hu+00jH6lCjQ+SZ+wcxd7o8Tt+Lan9hm4kJXmS3D4N/DOOhC+Ru8sw FJ/Nsx2ju6Xld1vOK4kUGoucFz21b5uk3hCjsfKxvn+6qDT9CcUxjM1v15vjkBQV71W9 VpulIFrJ1yTARq1LieDXOFSFhcXgPb0+KUmhHkieBxtu2IVvi+m80y2b5G59hncIg/ai MCGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=QoEjEsmj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id dh7-20020a056102578700b0047eebcecea3si2299137vsb.577.2024.05.07.07.37.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2024 07:37:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=QoEjEsmj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4Lu9-0005jd-LM; Tue, 07 May 2024 10:34:53 -0400 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 1s4Lu7-0005ca-Hy for qemu-devel@nongnu.org; Tue, 07 May 2024 10:34:51 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4Lu5-00025N-N0 for qemu-devel@nongnu.org; Tue, 07 May 2024 10:34:51 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso2448278a12.3 for ; Tue, 07 May 2024 07:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715092488; x=1715697288; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s8UQwJWo0cr2ZRaC4+6kRjAHtdNM0XskKMAiaHBTEPQ=; b=QoEjEsmjN7rpWd/sbNtl7UgF+fLVGYN/nN8XE2byNqc5u4OpwDuZSwFI0iZcN2fyUe Mr/qqZdmyCqE1F4EqSqaLw7W9mV+6U5CE79Vkgzg5GTitlmWfUJ5pbp5U1SDR6eqUpzY qJOQKMV3khOpu4Wbw1l9VJr/6QoPY5K4VZsQF2HDAe+PG+wWc7TP9lxV14XtwJiMsbFD K3HISguEtmNK0ocJPYNavcZPPBVu4Wj6PsgjgaF8zbGIB24uL+zqVqpw4sXsb2V9xraH zkXrUwJ0wBro0o+BFGqVAop6OYBCqtsJOgM0fW+2rZPIzeaGEXx/G6NFzp4VdeyqmPHC UcrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715092488; x=1715697288; 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=s8UQwJWo0cr2ZRaC4+6kRjAHtdNM0XskKMAiaHBTEPQ=; b=IEGPbQcChUc7g98n7efzu9Voo6oLqkDMW0Q/ysbB0astLKzsGrpAwoO2fjrIHXAF7S JqPllvsnuwO2hH4k5BhkvUJ8ij2MmQT1GtRKzlOy/4CMtB2/OHZ3YfQ004wAAkGCxoza xbT9FERzMwHBDByjEcWgfWgCcLsfAX8jri9cc8AnzMrmE4TDq46aqtKhP+eC3aNyj8t6 DgW7q65edmzVMfi9Szf/o5o4Q/ZXYPOMhw2neMginCsSmib13P+Gma6qPsHlhUEgJWDV /4Zd0PAd59zRAJP9mVsrrTSjFyhuP4FqfSnO6kwIhjN2KFa2a+hGAMtEcki8625WYaik TDIw== X-Forwarded-Encrypted: i=1; AJvYcCXXDK7qNj03ehKFPN/nCe+0UzQtV93DJcWrlY6JgWMxjGKnuYqrbQo0BcuT/1t46qPjxTK2/aO6i27BQmKkGeIeCufLu+I= X-Gm-Message-State: AOJu0YyszQmhhc1nr+hj5iXGExFNiQ32kqirYCL0fuNA0FUI78vCr+aC J1AEaxJU8tN9AboB4aVU0SkRbFWD4Dfd8GIC6KdEL/hF5YH+lZqndbDH2+44zfE= X-Received: by 2002:a05:6a20:e188:b0:1a7:7505:ac97 with SMTP id ks8-20020a056a20e18800b001a77505ac97mr15903702pzb.11.1715092488112; Tue, 07 May 2024 07:34:48 -0700 (PDT) Received: from mnissler.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id pq10-20020a17090b3d8a00b002af8056917csm11827206pjb.29.2024.05.07.07.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 07:34:47 -0700 (PDT) From: Mattias Nissler To: jag.raman@oracle.com, peterx@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Cc: Marcel Apfelbaum , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , john.levon@nutanix.com, David Hildenbrand , "Michael S. Tsirkin" , Paolo Bonzini , Elena Ufimtseva , Richard Henderson , Mattias Nissler Subject: [PATCH v10 1/7] system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Tue, 7 May 2024 07:34:25 -0700 Message-ID: <20240507143431.464382-2-mnissler@rivosinc.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240507143431.464382-1-mnissler@rivosinc.com> References: <20240507143431.464382-1-mnissler@rivosinc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=mnissler@rivosinc.com; helo=mail-pg1-x531.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé From: Philippe Mathieu-Daudé Simplify cpu_[un]register_map_client() and cpu_notify_map_clients() by replacing the pair of qemu_mutex_lock/qemu_mutex_unlock calls by the WITH_QEMU_LOCK_GUARD() macro. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Mattias Nissler Reviewed-by: Mattias Nissler Reviewed-by: Peter Xu --- system/physmem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index d3a3d8a45c..5486014cf2 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3086,7 +3086,7 @@ void cpu_register_map_client(QEMUBH *bh) { MapClient *client = g_malloc(sizeof(*client)); - qemu_mutex_lock(&map_client_list_lock); + QEMU_LOCK_GUARD(&map_client_list_lock); client->bh = bh; QLIST_INSERT_HEAD(&map_client_list, client, link); /* Write map_client_list before reading in_use. */ @@ -3094,7 +3094,6 @@ void cpu_register_map_client(QEMUBH *bh) if (!qatomic_read(&bounce.in_use)) { cpu_notify_map_clients_locked(); } - qemu_mutex_unlock(&map_client_list_lock); } void cpu_exec_init_all(void) @@ -3117,21 +3116,19 @@ void cpu_unregister_map_client(QEMUBH *bh) { MapClient *client; - qemu_mutex_lock(&map_client_list_lock); + QEMU_LOCK_GUARD(&map_client_list_lock); QLIST_FOREACH(client, &map_client_list, link) { if (client->bh == bh) { cpu_unregister_map_client_do(client); break; } } - qemu_mutex_unlock(&map_client_list_lock); } static void cpu_notify_map_clients(void) { - qemu_mutex_lock(&map_client_list_lock); + QEMU_LOCK_GUARD(&map_client_list_lock); cpu_notify_map_clients_locked(); - qemu_mutex_unlock(&map_client_list_lock); } static bool flatview_access_valid(FlatView *fv, hwaddr addr, hwaddr len,