From nobody Sat Nov 23 21:51:23 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1728804742; cv=none; d=zohomail.com; s=zohoarc; b=nh9XIxTYU3SW60H3WCovtSzt8ky+aW0XuEk1YsRhGrqoNdOQWwBEB2qmZV2SZdElwUrk19dgAg+u441f4jd2ycD6LkuIFpxme3ZJFt7MtayxvVb9/v0quqLs7OugIcgFN2iX2s4NbJzeoQkIW5vgERp3LEXAE0+Or5eQ/2v5yQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728804742; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s77a5vU3vVH8tVW9WZPSomumraIRL1/RPd/WxHRdauA=; b=ZJVV3FkPZ+v/6x1XVGSL5TC/8Wl5eNkK6+4NI1Mw57FhjCTZQoPMW5Ru1+hWW6zw87gP9KOapfRCFccmX86+glRa1nU/HsQ8pobTdZMhjdTOzXm2miGUaNGuD1UzA1OpRBm5hRht5/DSaj4mWFwlNllENckn64Y2tr8/sORCbLI= 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+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728804742862330.6065596346409; Sun, 13 Oct 2024 00:32:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szt4c-0007lJ-7q; Sun, 13 Oct 2024 03:31:30 -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 1szt4a-0007kr-Mo for qemu-devel@nongnu.org; Sun, 13 Oct 2024 03:31:28 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szt4Y-00064T-VO for qemu-devel@nongnu.org; Sun, 13 Oct 2024 03:31:28 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-71e52582cf8so446827b3a.2 for ; Sun, 13 Oct 2024 00:31:26 -0700 (PDT) Received: from localhost ([157.82.207.107]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-71e4cdd06edsm2353836b3a.32.2024.10.13.00.31.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Oct 2024 00:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1728804685; x=1729409485; darn=nongnu.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=s77a5vU3vVH8tVW9WZPSomumraIRL1/RPd/WxHRdauA=; b=yuAkmtDPa7QiTgg4blH56YWL0afUVZIAku2OwEK54DJW1yAS8GgVKWmczeK7eo8Pfr GZfWVmGHAkt3JTj4mplaGJKuaRwN9CR4PqHOLfUDOgotMAY7DwHa2/LMJBQj705JlsKj 2AGOQIey7QxYA8ArIIv/MF0YIn5pIstvJ41BbReonCxLbnQaj2K6oo/Bfnzc/Ew1cXsZ iOuZw0tZPkMgfoWiHpXtx4vHQtPCdBkZb/O9QcbOYLWL6NxJ/L7u7y9L0k064VdFZ0mc sKhqh33YPcWXbm6DYFX9yBgvW8DMov90/9jqZNczssmmQfnTnblBTlpuWPMwFHE+9pe9 Z3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728804685; x=1729409485; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s77a5vU3vVH8tVW9WZPSomumraIRL1/RPd/WxHRdauA=; b=lidqzLKQh61Xvz5YMP0aEuIfxjeB4hBUXzrYofa01hT2Om+0gU4bsD6w9XYrKcJ5v/ pXnLV34OvfLlmg09/lruNizObA7pPl80nkSiVocF2H7aTBUrxGm5J4XuuUjs6dyn8Bvr V7Kl8iymKLqv5KOO5hI4dF8l0Et/+Bva49nOsl+d2R8+FVH/sXYrtfYjqofvJd9ysL3o cFM9H2AdBNXOyF2DTEpOOp1gyPSCWzbZRZVGFNyQAtniQvTOaZjHi6n9m1Sr1T6j5KSs E1hdQb2hqKRnY+wqIBQx9sqzoCcrKeOBQq+wD0WuMbpZtW17Bf+08aF3cuO0CPJ7pIST LIQA== X-Gm-Message-State: AOJu0YwjrQNl8XDl4coAD0O5wFU9gqgqjHMCSBAaOUD1HXKWZNTCGnJT b+xeScxot5L4o3IW3fo5WPE7BwbezieOurthQE8iKqfqtM9EhKwFNv4uKeiIiU8= X-Google-Smtp-Source: AGHT+IGGpewwtpHrLwXYwHjnNgp5WSATkcx14zwxmkpvjOVbiR1n0mTSAK2jPH5LbSQQNkHnH/ZnBg== X-Received: by 2002:a05:6a00:2304:b0:71d:fe5b:5eb9 with SMTP id d2e1a72fcca58-71e4c151ad7mr8266387b3a.10.1728804685003; Sun, 13 Oct 2024 00:31:25 -0700 (PDT) From: Akihiko Odaki Date: Sun, 13 Oct 2024 16:31:13 +0900 Subject: [PATCH] rcu: Call drain_call_rcu at exit MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241013-rcu-v1-1-a93b7c5957f3@daynix.com> X-B4-Tracking: v=1; b=H4sIAEB3C2cC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxNDA0Nj3aLkUt0kEwszEwNTo0RDA2MloMqCotS0zAqwKdGxtbUArowjtlU AAAA= To: Paolo Bonzini Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 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; Received-SPF: none client-ip=2607:f8b0:4864:20::434; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x434.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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1728804744978116600 call_rcu() callbacks may have potential memory leaks, but QEMU may sometimes exit before draining the callbacks and leave the leaks undetected by LeakSanitizer. For example, PCI devices register a call_rcu() callback by calling address_space_destroy() and they will not be freed until it gets drained. This hides memory leaks that is going to happen when PCI devices loose references to the memory allocations. Call drain_call_rcu at exit to expose memory leaks by call_rcu() callbacks deterministically. Signed-off-by: Akihiko Odaki --- util/rcu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/rcu.c b/util/rcu.c index fa32c942e4bb..118a974e3438 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -415,6 +415,7 @@ static void rcu_init_complete(void) qemu_thread_create(&thread, "call_rcu", call_rcu_thread, NULL, QEMU_THREAD_DETACHED); =20 + atexit(drain_call_rcu); rcu_register_thread(); } =20 --- base-commit: 31669121a01a14732f57c49400bc239cf9fd505f change-id: 20241013-rcu-b4864052a103 Best regards, --=20 Akihiko Odaki