From patchwork Tue Jul 16 14:01:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 169064 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp900994ilk; Tue, 16 Jul 2019 07:02:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRKXWgItYxAxhM+2NktvREX6zgvsy/Gnuzx7k7a6siXahmAtRKwCva0pWXZm4SxjpFXirC X-Received: by 2002:aa7:d5cf:: with SMTP id d15mr29446325eds.67.1563285721377; Tue, 16 Jul 2019 07:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563285721; cv=none; d=google.com; s=arc-20160816; b=jT6gFuzA0o1cEpOuh0gTI+yjxY70LXrfxY4vPbdZhFU3kjMmlKBbzX79jT5AXR6jVW oKvpBNtJ5qipPpmW9IZfWC06A+WQ67tqydG9ohnZHkBpZwRaupW1aUzC1ssFli7eh8uF dYjIZi6f5PZ9Ce9zDFw7NEllUYaAJHVy4+e9ulz3awoyL0ROw0C94tsx9QMRglCp4Tin wEj7z0F5K73ZAol2Xikt1Y+QeFlFY90OuCDiCmj+qKV+dB10vgx7fC6XwRNNrCtKokj5 3l47tCmrg2wDR1hRPMTwexKlN4lfxEo+lpl6YiHUr4Dkbd57SP7v0QXHzf6rBh0K15+l S2rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature; bh=mz7/qAWIZBgCxy/KQHnwd3kx6dvkYS2R0nAOMZwpcnc=; b=YVMjxw6gO3hYJ++SRV8Y/zbydaIAc815p+g9VuOQ4tCXjl1JPlS0GTngQBde1qyicj lCmnKj2d8TaHi1FtUqNel6fYSrGSCTsvDZKrHWK7U6005tD8yBBA7mSbZpUTFvXdq+uw +4w1QplGFajt7BrZmMISQUg0+5WCvVu+mk+Sdvrs9DgelxV/sDDnrkV34ZKo4gbGgCws Spe5kX2V7YLjtzUtmZxUo3RcLe4DFVVkiVSAZB0WqFLU5OcNXNT+jeQRVpA955DnzrBf fYxLSgcmpYN92LQAMo8C1wq4KTbnMLnNI6FPJIlCaC+lKfT8Io6EspF/++n5BYGF82pM COCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lO9SRqxt; 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=fail (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 e6si11028017ejx.201.2019.07.16.07.02.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2019 07:02:01 -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=fail header.i=@linaro.org header.s=google header.b=lO9SRqxt; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnO1o-0006Wq-2w for patch@linaro.org; Tue, 16 Jul 2019 10:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33405) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnO1b-0006Wj-OU for qemu-devel@nongnu.org; Tue, 16 Jul 2019 10:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnO1a-00064X-Jj for qemu-devel@nongnu.org; Tue, 16 Jul 2019 10:01:47 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53421) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnO1a-00063q-A9 for qemu-devel@nongnu.org; Tue, 16 Jul 2019 10:01:46 -0400 Received: by mail-wm1-x343.google.com with SMTP id x15so18790542wmj.3 for ; Tue, 16 Jul 2019 07:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mz7/qAWIZBgCxy/KQHnwd3kx6dvkYS2R0nAOMZwpcnc=; b=lO9SRqxtMYzubpB8KHB3tzm+dQIkcf3/WC7Aia5YfoZjHyWCBWQKdSIEHpFZ9u6/b7 lleANc7jnXUSXe3e17lSHFEH7xkLSO8a0rdgAHQkdBCqCzebIeA3gMIuk5ZuGrAorkZt 9PJ3iWIULeg3iJZ/VZbzhhOXFYR9HMGB9QWIxzOSY4QEXkSDGlf7HHLAujMTib3xr2V0 CNwNRmntUJoieNUdMUBcNJnsYV1xWXUwSrzzXJLsv/Z6shza1kCCEzjmLyDd9UqpLS+9 Z/IqUd+qHSEkR0cnpsrNb9IYN9EdtX/WSUzr7VeX+rNmYJxmlUOTKuZ/LyVO9N0hBy0H +v3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=mz7/qAWIZBgCxy/KQHnwd3kx6dvkYS2R0nAOMZwpcnc=; b=TDdBAASEMqeWP7dAwM/V6sQVANDuV8h4sFRG3fsDoTfLerIWLhuF+f6eEv4majfz0b YT8DitcN25GL8NdsftoU4wtNbmdjJsT2Q1eu5Xf/C7Ui/1TEvBiWEP9lupjGeyU1MxO4 GWO3JnJggISZB3wzop6u5Jys1iKcysiFrpsn14NEm9dvr1F3wvLsg8UkNrBV1RBU2Hr/ oOQdzDJH/HIedCRL+SXx6QjsdYPh+cRAoR0UgkSI51PY9hTqqqQEDuwA0LMeI4OYLdyy 1Eu8qSpjZfUf0+X1ueIADYWmVZCqOC1jAdt9fuyPIM30RjmuibNzIK61I9IZnzP/KvFU t+Iw== X-Gm-Message-State: APjAAAXmuBRmEVnLLsj331/rlBUEUROGhEuA9jarj9RSrztSvke4y08T IqQO41Y90KIKyJEpRr2bCsSa9Q== X-Received: by 2002:a1c:968c:: with SMTP id y134mr30300379wmd.75.1563285704980; Tue, 16 Jul 2019 07:01:44 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 15sm14734964wmk.34.2019.07.16.07.01.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 07:01:44 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B9DD31FF87; Tue, 16 Jul 2019 15:01:43 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 16 Jul 2019 15:01:33 +0100 Message-Id: <20190716140133.8578-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [RFC PATCH for 4.1] linux-user: unparent CPU object before unref 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: 1836558@bugs.launchpad.net, Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When a CPU object is created it is parented during it's realize stage. If we don't unparent before the "final" unref we will never finzalize the object leading to a memory leak. For most setups you probably won't notice but with anything that creates and destroys a lot of threads this will add up. This goes especially for architectures which allocate a lot of memory in their CPU structures. Fixes: https://bugs.launchpad.net/qemu/+bug/1836558 Cc: 1836558@bugs.launchpad.net Signed-off-by: Alex Bennée --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) -- 2.20.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39a37496fed..4c9313fd9d0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7183,6 +7183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, NULL, NULL, 0); } thread_cpu = NULL; + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); g_free(ts); rcu_unregister_thread();