From patchwork Fri Jun 10 14:38:55 2022 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: 580596 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp1807074max; Fri, 10 Jun 2022 07:40:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVVEX48fNHLXeoykKsgdeN9EhRQ+cWXKp49sv1D+2jZmAsn/i/9dopS+3AZAFL5zF6Bzob X-Received: by 2002:a05:620a:4312:b0:6a6:5b66:5b9b with SMTP id u18-20020a05620a431200b006a65b665b9bmr31504181qko.224.1654871999951; Fri, 10 Jun 2022 07:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654871999; cv=none; d=google.com; s=arc-20160816; b=yCoQh6gDgupde1J74qxYwRMlCvZGRt0dRlFm3AQTaa2rz/cUGjVeAFkLuKaYKD3BtI t31VMl4sA+p8F9arvQtlrIA8fzg+yq3zvTuwK+R3HMaf/3dZwh+00KQfPd8dm6GeOj5I 5sqOXajK6bDgG8mj2rVhi2OdtsZWYcunh2k2z/2EpWZchdLURwoBhBSy9fijXqiwVdOX TR2x7rTNVeVpn2pRZHpNfvOFPxJuC/jPTkE5wIPamr5YOXhQwcfoLeDwfbsJOeRMGiuj A0iwiItd2Z5JFa384nzbfFBDpoBNsJpjHZG+6UjJd6VjWTYHiAC/q7TBz2h8rNOAY2Id 8hWg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=lQXKo2MEbNEG3rTNGzTwuOJdxJfjTrkY07wuid3v4OM=; b=lCKzxUv6sAhRXShsBtMN2/KGzFXYoxF6l8NAiP7BykTj5OrwcRMISgYMrS4VPE1Fh3 eZbruai0EXCuIwpr5i+A3Nx+kG5Fr/RAnxDl1tYbw/4okYQkSTzfmM1ogqcl2u/dCOOx /e6NZIy5wha+YDPQ9qZF93AOe+vtFqcAupNqj66R2mjZsKdsElKT//1HEjqC/+lNiEqQ UQOQR5436l8eAcjohRFtFemxM6OU1pj4dsYqxAS7x4KGuOmg0DH7HA5gk6/tkt2a+zGL cJRnBgdTKBx/VkL9gFNN1xQj57wBimvlOErS9O8ClU7/lKrwpL8EhLkmTHhYfyeaezlb bgdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sGoNW8mr; 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 g21-20020ac87d15000000b002f364655293si13642784qtb.697.2022.06.10.07.39.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jun 2022 07:39:59 -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=sGoNW8mr; 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]:39892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzfnr-0003Lo-Hq for patch@linaro.org; Fri, 10 Jun 2022 10:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzfn5-0003Ij-Kj for qemu-devel@nongnu.org; Fri, 10 Jun 2022 10:39:11 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:34526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzfn3-0002LZ-L2 for qemu-devel@nongnu.org; Fri, 10 Jun 2022 10:39:11 -0400 Received: by mail-ej1-x62c.google.com with SMTP id o7so20589978eja.1 for ; Fri, 10 Jun 2022 07:39:08 -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=lQXKo2MEbNEG3rTNGzTwuOJdxJfjTrkY07wuid3v4OM=; b=sGoNW8mrzWifUADG1EDHyKs4oY6qgWdpiC1INchx+C5yQwBOl/zJc7EegJm+VSNsd+ W8ZpgAEesGSCa86rbN9WGLu/nuxeKkrThEJKyW24QA1Et4rpm7xN94Uz26/28ccScBT8 bfu29MvJ15KhJBQInfnJviTPvuzjECZQdv8TVw3brnrt+kqfmpvyoCLPpzkBCHzXdPTo Mgo7Qqw2z0gKcI6wUf7drX1RtJeDSduo1Lgg8YRft1eMsAsdKOuKmctPehUg5kVp83ir zjPUL6XPMV5jzWP5zDaEVfv+d8FXhkvkgO9e2ZwIifsLpgHr/KJ9U2+3Am/AlTakkvT7 fweQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lQXKo2MEbNEG3rTNGzTwuOJdxJfjTrkY07wuid3v4OM=; b=RgjfxFuBjNPZEZR1/bp9kkKQ3BZ+t0ylcJgnNZM2MQL4k+yNc/DxMWfEnJxkAfgi9P GT5rwSWvH6nIOhhex/J4+6c8PWljq31rCExD9MOnmRvLcz70foqUcnz+k5I+UBgmLTB1 9AowTBeeNFT9XSzohh6lOPAlre0+LL7cKNGv9xlgq8J4SZTwBObHTAEt8EQKzT9KC0r8 TQEz6QYlQ1s4Sf2yOsKFO0+8MgqmO/Jmv2Y8OKj+xOt5kyasWBlWHo5h7G3VhLIa3xS5 ghy8VGGGiC10eA6ARhQ44UHIQtCgiFLQavyws4db8FDX0FRpiyxrLwK2OTGHomdiabpr FQKg== X-Gm-Message-State: AOAM5310KPEK1T7sGQh0FWuIMWpbhLeE3iiHG1hPjUGoPChEalvfmdg4 CZuad/fIWnx7JrTtsWEV5lwT4A== X-Received: by 2002:a17:906:fcd1:b0:70a:a374:905c with SMTP id qx17-20020a170906fcd100b0070aa374905cmr40980905ejb.583.1654871947340; Fri, 10 Jun 2022 07:39:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id ck11-20020a0564021c0b00b0042de3d661d2sm16621027edb.1.2022.06.10.07.39.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 07:39:06 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A36381FFB7; Fri, 10 Jun 2022 15:39:05 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, thuth@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Subject: [RFC PATCH] linux-user: un-parent OBJECT(cpu) when closing thread Date: Fri, 10 Jun 2022 15:38:55 +0100 Message-Id: <20220610143855.1211000-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x62c.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, T_SCC_BODY_TEXT_LINE=-0.01 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" While forcing the CPU to unrealize by hand does trigger the clean-up code we never fully free resources because refcount never reaches zero. This is because QOM automatically added objects without an explicit parent to /unattached/, incrementing the refcount. Instead of manually triggering unrealization just unparent the object and let the device machinery deal with that for us. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866 Signed-off-by: Alex Bennée Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f55cdebee5..c413d32311 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8566,7 +8566,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, if (CPU_NEXT(first_cpu)) { TaskState *ts = cpu->opaque; - object_property_set_bool(OBJECT(cpu), "realized", false, NULL); + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); /* * At this point the CPU should be unrealized and removed