From patchwork Sat Feb 4 16:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 650640 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp1435059pva; Sat, 4 Feb 2023 08:08:54 -0800 (PST) X-Google-Smtp-Source: AK7set+30M0FySHkXWQdSIV+i0IbgVkS0vFTIp302G3CtUvthuNlI3JRwGqT1ZjO6q+y5UnjtgRj X-Received: by 2002:ac8:5f10:0:b0:3b8:6b6b:28c2 with SMTP id x16-20020ac85f10000000b003b86b6b28c2mr24868444qta.68.1675526934382; Sat, 04 Feb 2023 08:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675526934; cv=none; d=google.com; s=arc-20160816; b=Qt4gnbeFZoeMjtJwa5jcQn/DvutkuD5nWeh3otC3Yur5LxZk4ZsfRQRxo/wwVRcdm1 tCk4NAh4yTo1YcjqVOqa6G+SDTanUQTfN3jgFOzEl9KWT64A63J1krWf2qKotCJDn4Ld 1pMljrGFc+reA61TiuEy8QGy8xRohCrf5pUetRz7BHjILCr7O103OO1TksyZKrmeoKaE 2huLQmKJA8JJUpfS5QHqEGxeuXxZm6CAjQRKI00vJWpR3dMhzMm6aVxoFT5Badsgq4rC HeEX1JqXhGDPzRzcU/EjVmEK3xHwcDlITDXCkAFDakxJFdZKnnIXTYyoVRl/LkAEKEHa sUvQ== 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:ui-outboundreport :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=MYHax3KomdEi9/+JkpNiXL/NyGKdRnuq5Qlfur1hEPE=; b=gmZ8gcY9PuxnfHRzNXLeFyoXkrPXZEPXVn2fmiyvJ98653bvqNKW2ethBJWSfkZtjY qgKXjBRz6k0/1wDJw+PNrPqmxEjUUHb0j0u2AZISFvtx7rBkr6onFV+CzgCfIALPthhy Z0d+fMAAnXIBvsghc6OP9dP7hEJsSpOyXwFOt3PJLzvmqglwIlTGMdui8elVGTJWJuUU 7K4IxDmNXKvvMcdcfxKI0FbyDbHbt6FL66s93LDgLNGsWG49UrqAeMVJjEB5l0nOPN6j WNCczOhWkZsH0l7BWbAzv906hHW0T8VyHixmr5JeQMImSredyoIUA3BhEmO5EGjoLeJm C2EA== ARC-Authentication-Results: i=1; mx.google.com; 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 d20-20020ae9ef14000000b0072b86bfb504si4089683qkg.474.2023.02.04.08.08.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Feb 2023 08:08:54 -0800 (PST) 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; 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 1pOL5s-0005D4-RI; Sat, 04 Feb 2023 11:08:48 -0500 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 1pOL5m-00054w-LE for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from mout.kundenserver.de ([217.72.192.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5j-0006uL-Pz for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:08:42 -0500 Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M58SY-1pNFA13WJ2-001EhF; Sat, 04 Feb 2023 17:08:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Laurent Vivier Subject: [PULL 07/22] linux-user: un-parent OBJECT(cpu) when closing thread Date: Sat, 4 Feb 2023 17:08:15 +0100 Message-Id: <20230204160830.193093-8-laurent@vivier.eu> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230204160830.193093-1-laurent@vivier.eu> References: <20230204160830.193093-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Owlqyx/EvkIoUWNRsGD4j+1tCD4Nki7NYcXG55uQHL7ZVWMbifu 2AgzM+olSZVjAUb3g/wRaqopX1csaZ/3wS+CCoN7AZePULsy/LhICylAy51dg1IZDb/OJT5 6yNzGjO8tJ2pOjYCqSACDI94s4q81Hjf19NPLr6E3uxfx6GjzhFmUagHeK/aB3YSa+2Loer EoseEHop/6SX3YKaf9ywA== UI-OutboundReport: notjunk:1;M01:P0:PrJprO64Gww=;4oMAwbGPJHekz3HNgnTbk3NPld7 yk5NYxI9dzEK+FwBmnLtPDec+Ifz/fGAHjso3v0KCG7EXncGWt8p2nSzPMga3MK2vFGN20ZMU 2CFV4pR3FNbspeYIVSjR/C5JULPVsJDe4iGrcpXPLBZjWOYOATVAGkl8Hjf5+m6nVUc6IPXtb r7ssHKjKN6ZvIj1LXVxd5Ng2O9o3Sq9PQvE268W8aLwUv5KaJggZPO19BXUK1Ww01g0V5khlD NS2AbuQtaLUA0KVaPtD7f/EV6OP84crS2hPV8gLXRhtwLt7TlTN4GEFt6TkSKTgXiorP2MLNt be3Ojq7wuFYS1FuApW9pcG6g1HHmRn5RnweQuaJULuV1Qixzwb1jhmrm8nUSxIIlzEjLf/x1p 8xjNo2gnJCRDvKNYEYtm6wNhcw9L/+SWqc7qNCTIOzF+Drq5Rt76qw8D9sO/eeDzghBnNhxTH FllDg21r3jJ8yjYPx17kvDBMIutImCxKpavz0D8nIdmblMWRZE02tmL9vKInrvBkPZPy7i9sG d5D4lqw0n16WZYResDFshfD3ILfvFywCCxdHqx3041kH1SbWFLXRaeN0JMvE6yM3yZOrE76vS Q3iN7Y5A2VOZ2Sb0XX2IRDMeUEprkrVcSx319/A/rwla+S1nq/UkpqFehEJgFQ8whHjNo0xn2 AIK21Q04YxV6esUa37yTFwj48m50jlSHa+/BftSF/w== Received-SPF: none client-ip=217.72.192.75; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson This reinstates commit 52f0c1607671293afcdb2acc2f83e9bccbfa74bb: 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 Message-Id: <20220811151413.3350684-2-alex.bennee@linaro.org> The original patch tickled a problem in target/arm, and was reverted. But that problem is fixed as of commit 3b07a936d3bf. Signed-off-by: Richard Henderson Message-Id: <20230124201019.3935934-1-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3e72bd333ede..dbf51e500b4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8756,7 +8756,13 @@ 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); + if (ts->child_tidptr) { + put_user_u32(0, ts->child_tidptr); + do_sys_futex(g2h(cpu, ts->child_tidptr), + FUTEX_WAKE, INT_MAX, NULL, NULL, 0); + } + + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); /* * At this point the CPU should be unrealized and removed @@ -8766,11 +8772,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, pthread_mutex_unlock(&clone_lock); - if (ts->child_tidptr) { - put_user_u32(0, ts->child_tidptr); - do_sys_futex(g2h(cpu, ts->child_tidptr), - FUTEX_WAKE, INT_MAX, NULL, NULL, 0); - } thread_cpu = NULL; g_free(ts); rcu_unregister_thread();