From patchwork Tue May 7 12:30:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 795205 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:34e:ceec:bfcd with SMTP id k28csp269332wrc; Tue, 7 May 2024 05:31:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZC3GwkbWgXhwsPFmsO9FXruxqCkKpM+ki5arO52f2wPyjUZA77zFaeMzaX5Kl8K2MOP7HdijEpRDfHHHsMHuX X-Google-Smtp-Source: AGHT+IGBIaeRf8lnQZAxAtNypZamK8DvsfFOVmQi7QNVgpQU0geeGlPTLX+Ig2kU+rwyb4kKEvUb X-Received: by 2002:ad4:5aea:0:b0:69b:5ecd:7c9a with SMTP id c10-20020ad45aea000000b0069b5ecd7c9amr15226944qvh.51.1715085107437; Tue, 07 May 2024 05:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715085107; cv=none; d=google.com; s=arc-20160816; b=DgPvAr18xEJTNAQkWBkMFq4JaHcXpnmoS9mWOVCGUCD3wDw4bL3dxVTJF4/D7VNlJF magkicfLR6ZRCICN25qBa0MxNkOqgae+FmVkz7dhY6Z8j7dwqU8j+yJ4WYXkkjF19ftN 3nRXLLdZTvzy9SVmyt0eWC08wtSk04xXrydQA3DQR9PAp4yzVCg3CinPqoTbj0rL7gXv FNlzqRWX7PIi/G+Y+Ml5jPA/cC1NQ25NY6j3P+JHx8CS8/gg/Tk6lrct6b+fKOx3ZitO h+YimbHgRumSZ24zS9jQ3bBsUSs7xAFBrkJQ4IilAHdqqH748/x6vD2RM/HZksq4Zpoy m8DA== 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=sliD5j3ZsW+Ih/VrgBbXH2a/MnjoDv1oe45cMQ/IOgo=; fh=o+0Cxzn0vqd9qaat0OKQ9MH4Aye4czSmxiTGhWeCDvg=; b=sQwn0E3L/BghFmLhpja7TA0brlm8A2SYr1yh6NwgCCbsez6uxfMAWYbZLRntstJras yDCXGFGME6e8MNd/McrYrpzBGbvla+RGlWnxJR7t3mS0PakBtv+AnfkQYnGNwjdmYFn+ jyBpF1qN222by8b0TcWucCnYtRaZNiA7GuiiyMSeyUm9j9pn/t/Fxfw1ZqJycV7xrxm+ eelfJvlFwn+EmODZa9iw4x17NcnrckJ/mFwNPloGtR/ctu+KzUNWACw434Q7p8V5de3G Sg08/JHCXPADYJ8JmV9YFOG8ucNir8AmsGJG7VF2XG5eUz1lLEJRDG11PanRSXzxctVd MTfA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RuyzOz74; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o15-20020a05622a044f00b0043ad39858a4si11878557qtx.98.2024.05.07.05.31.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2024 05:31:47 -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=@linaro.org header.s=google header.b=RuyzOz74; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4Jyq-00066B-Sn; Tue, 07 May 2024 08:31:37 -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 1s4Jxx-0005lf-Dh for qemu-devel@nongnu.org; Tue, 07 May 2024 08:30:44 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4Jxv-00076E-Ov for qemu-devel@nongnu.org; Tue, 07 May 2024 08:30:41 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2e367c2457bso22553661fa.1 for ; Tue, 07 May 2024 05:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715085036; x=1715689836; 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=sliD5j3ZsW+Ih/VrgBbXH2a/MnjoDv1oe45cMQ/IOgo=; b=RuyzOz74ucJoZ/ZTU8wfy08MCYBqrTw3ZR/D0eLYXGOfOdPb2dd3MGmybs/+VafoB6 WgRCjom7pNkBKMmRl+BdyJY6CsRV9HIXXZqowZTazPSFZjePVviY7tjOOg71ZABqgcJI +EEnklpir90PNPGX5L0NCpMgqRMbnV+IGpVan0ALfu6n162eSlSM/NOFML+m2RZa6Zwi f/90zjWW2yvmBENayhQ1a6e4+SP6VAiUh4lXeCxSsDzLs01gUTTIiz79aPEl0of0O8om l8QGBRcVlD/2nNJNTc5/tCRfECs0tB8Jb1iKOX2YJOpHsUS2adA7HjKpGj4/PwO7vEBI yyZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715085036; x=1715689836; 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=sliD5j3ZsW+Ih/VrgBbXH2a/MnjoDv1oe45cMQ/IOgo=; b=ZPT+VQQWaGPhcorcpgqH8hZrCDfjAX7TI48e3EVt5o3h4s7iSi2P1UOZX+FuiMAmcE ilnqHb3uOYjynD3T8ojITTqFgcfN332CIzub+wuW4l9T1h33r63mp9O38N4W7W/HHztG vfh8tt4skyPfMZ/McaIuFY+mMcDKj2ZzfvkpiwTO8WsmHtwE9KDfAssKUW0OfjnnjIpl OffmraRumLpZwAHaxBaBO3ghJHJuYuPMaDa+9NLmKmx96EmxTTUsBPkixdAB/gXLdEZv N12FunxrvNtUng0Y7llQg3ESKjZOL6mBrtoI88120aDdX25I2buCR2UWWtN13ZF+PC6s yhBQ== X-Forwarded-Encrypted: i=1; AJvYcCXbyBs1bFey3sdvxHfHbnnrSwa2gfSl/zq1txG+BzFfctnjk4YtQdhAsUrGimO6cranK/WPI4sK53tXa2Br5IOxTgr7+4s= X-Gm-Message-State: AOJu0YxAvgE6hzhqUOkA1FOQF6Tj4QDRVC5sDbyZ/rN0ynvXDJSgTQZn LqfFifJuDUomZQUJDiA8HBRwa4r4wvOYSee/Y2UpMGtNHPCc+NkIMkUZK6NJswiwnPsvJBS58vT 8 X-Received: by 2002:a2e:9297:0:b0:2e4:f8e:3a64 with SMTP id d23-20020a2e9297000000b002e40f8e3a64mr769862ljh.30.1715085036211; Tue, 07 May 2024 05:30:36 -0700 (PDT) Received: from m1x-phil.lan ([176.176.177.243]) by smtp.gmail.com with ESMTPSA id y10-20020a5d620a000000b0034ddb760da2sm13072941wru.79.2024.05.07.05.30.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 07 May 2024 05:30:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Mattias Nissler , qemu-devel@nongnu.org Cc: David Hildenbrand , "Marcel Apfelbaum" , Peter Xu , Richard Henderson , john.levon@nutanix.com, "Jonathan Cameron" , "Elena Ufimtseva" , Paolo Bonzini , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Tue, 7 May 2024 14:30:23 +0200 Message-ID: <20240507123025.93391-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240507123025.93391-1-philmd@linaro.org> References: <20240507123025.93391-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-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 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é Reviewed-by: Richard Henderson --- 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,