From patchwork Mon Mar 21 14:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 12787297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDFD0C433EF for ; Mon, 21 Mar 2022 14:20:45 +0000 (UTC) Received: from localhost ([::1]:40966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWIto-00069v-LJ for qemu-devel@archiver.kernel.org; Mon, 21 Mar 2022 10:20:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWIns-0008Ud-1r for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:14548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInp-0002R4-Ix for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:35 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22LCw9ln022265; Mon, 21 Mar 2022 14:14:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=sY8w2P2t4x8VdRK7Lv2C+ZZz462dHOfHvSBQcFRHxhY=; b=zwmd2QBkgebUwtAYohuM81dGXw3urpcJhMpoYllj1v2z7zThoKKtZh7/gnehpf+MtA62 YGjhoajleLTyUGH6FStyo35aTRGLH7A5qtbh5OlnyuJ2CHDfAGhUO0iIE0K9XGRQJNk+ RO29ErLLtU8dl1NsBQX5DG3RCN9/rYZo/cbXyhfO4rFfyTtKzGHP6i7BN7qTr4e4HF4E ORF44fR+xpgwQ+MgMyKmnoefl1AufcvgROen1Ye14KAVgBz3066W69y38YfKx1C/FSKY fBnSjhmhwcAKVBouZNxKB9hqhBbPku7V+TvF5Mu8TcFZdgmNSAF+adZk92PleyetMlN0 pA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5kckd1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:20 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22LE5cUb051515; Mon, 21 Mar 2022 14:14:19 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by userp3020.oracle.com with ESMTP id 3exawgse9r-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kthslV34ZuKKLHDvWprllxyTafaiHEyKaLp5qovffO5LuzBGHTnmMFZ7jb/6YgU9jgZLgyRZNEDV2TUkj4Di6GpSHsQVoVxPP0f+hFNK9mXxGEuSOb3mcQwvOc9bn+vPPWTfV7rrnwpc8mxebeahjGpOvC1eHozNflYSGpznu3GtDSVZh11tIB1hc0zg9EzB1busPaAZtfVtxla/SqED9YtQE7NC9ahVQ41Q2MKfKc5F4yy/yNrLXUCy5AhmfMT7jMJlIysVIBpi5YISCI13rT9VjmubQOiql6B0Ob/YUbvu4lriMfliEsWGgUddT+k9y+BQPH1nyDyHca4eFTbAqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sY8w2P2t4x8VdRK7Lv2C+ZZz462dHOfHvSBQcFRHxhY=; b=myVCct7fqcPPkX+cstfglXyCAjhhcVlkdrA7p95uJQL8gg1g4cK5eKzf76bG2pqkKuqpABDyF5exxcfU7jN6dFYrSxeiSyCSBM2fhzIcyeFCQ6nj/fwvmo1BhY2b2PRNrS0Zt8oJcTYgK7ulB9FkK1yo4FdawhX+8VfGCm3sgGO/5ArDTRkJx8stSWZLIyzVVbFEpE/B+AM9YA+jIFcYNkZC7TVvKwYrgw3WcvEh3mrZXk/Kof5BP3+M9CnSgPvjVRHi0gCYU4BkIcRbZATnkvsNcqlAmQwhRaE1t/YmgbH7R4TVqd7vRueLsWPvfM2MoIKKLw51dDdBlq/sjF6M5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sY8w2P2t4x8VdRK7Lv2C+ZZz462dHOfHvSBQcFRHxhY=; b=RbevLrh65k+SGl6heu9/pVNZfUl/63N1yEpb/rFxtXojroXbX+HhOk3nmotP/aa4dBCuv1DrQMYMMBeml1u/I49/aTM5lyP32RzQZd3TlXRJ6tZcbi+PDKd64GO5dsXo5eEv5x6RNR5JCQ4tlb8s7XKNsqGxViAm1cEH8Y1YbMg= Received: from SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) by BN6PR1001MB2258.namprd10.prod.outlook.com (2603:10b6:405:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Mon, 21 Mar 2022 14:14:18 +0000 Received: from SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15]) by SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15%5]) with mapi id 15.20.5081.018; Mon, 21 Mar 2022 14:14:17 +0000 From: Mark Kanda To: qemu-devel@nongnu.org Subject: [PATCH v3 1/5] accel: Introduce AccelOpsClass::destroy_vcpu_thread() Date: Mon, 21 Mar 2022 09:14:05 -0500 Message-Id: <20220321141409.3112932-2-mark.kanda@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220321141409.3112932-1-mark.kanda@oracle.com> References: <20220321141409.3112932-1-mark.kanda@oracle.com> X-ClientProxiedBy: DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) To SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f0a7474-c24a-48f4-060a-08da0b45161e X-MS-TrafficTypeDiagnostic: BN6PR1001MB2258:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XbeU4/DRcuh2tw3qPeDCINIXcoN6W+3pnveyfcUfkQUJ1f3q/J9BTQXL+ml2iTyR+PgVggopxB0IpzPQ36an3YUKHnim4/uLgJvUOC5PLWRUtj6hSm9pY1u1IoVhrhSRmxaYy7fq2lAI7SIkODbVmXg9s8HM1DLuSB1b6xsUheqlzVGWpmGdaLcKRgtmh3YQG4oLjjWmmhT3LUgiyx9J3NwLRTWHtUSAuRB/WvpRUHcUCFRDJtP82vO+3Cb7l1WI06rwvoZEdqmKrax72DK+K+76TDHO0AFCAyl/n8BS1eZU6xlgQS2FutiycClcoQAUgQd+8R6EbHVbFSJ3rPJhRlbEOoJGPgP/dSZaIs6BTZ+zQVh20Duk/mBpqxjr93jJ9LQfR4Rvt3D0K1imtsDU8J9t0fgMz1uj4vy6Q+nD/+Z6m9kdPVNcaK+VKHssoZ5wcm2x8SlX5/TpKFKUDUQdcgPjQAW389cfmRqWsYZ3CBiRILV1kycQnBxb6Ans2eoT+oD0yfv6w90kQQzXGPMsOZh0NVTrAGD+4QrdkebllSxlLtqe6EuZq5KlnwmYMmAKNSVJiPUNCAnE5Vvis4rRe1pPMEBpzU8/FZCzWVHniKY00dxUYSWY1vsLRU4h64J2auuq9ELpYMKbejwDHAN/oAbFryZTYFo8Ybit72viQytDfB4MlRPgTcE0oDRLT+85s3wdTwfumUNUmCtVDi2G0w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB5841.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(36756003)(2616005)(2906002)(6506007)(508600001)(6666004)(66476007)(316002)(186003)(66556008)(66946007)(83380400001)(6916009)(44832011)(26005)(1076003)(8676002)(4326008)(6512007)(86362001)(52116002)(6486002)(5660300002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3fyUcpYErOOPPDK5rE07PPHjuS1t?= =?utf-8?q?Bx+2ecaEwp6DvKeabuURhOgly80YJp17C8N9jeGDXi0iJyGZ8rzSyeW9aNiRyx8Ij?= =?utf-8?q?SxwvcvXgpqaKLZGuL/Iwy3hfiCI8bK92lArhjhiMo3zlcv0eAlyZ1j2byye7IJHiH?= =?utf-8?q?E3+i6F+iZ9bFd/nydCZK5yjTbQruAGGQJIyAdTSRI2upvDx4aHvNaGjxYZicplflW?= =?utf-8?q?OVKXpzp63gBUEo7Mz9Moab2QyAOMQ69JcvWoe7NIcnEkO7I/nxck3CvWzmkDo0+zB?= =?utf-8?q?yrdHN6jHtsPgw70Y99FE7uAoSNtxn37Ez5TaCnP1ChK9Qm4x1HNCRa+H79d6ROvnL?= =?utf-8?q?JyKzOy7JbGb312m36u4+82xm7FVmWaSUB19iuusTVoeEzVebHYYMTIOeLqqQe4csw?= =?utf-8?q?IUY+12UyQID5KMh+T2T7sFo7S6iHtSpE3fGZgCrfwBtsF6o3VKTJPCJ5FOlsvzaqV?= =?utf-8?q?6/ytEhid6l49J9Zz8RJDalFYQIdbClFGcu1uDIYvKsDzzIVSmPGDAvXnpLtse6l0V?= =?utf-8?q?KlLGqEI9qY9uzxyJWdsD7iSu/tVJtQJvyALZHFkEZ75hNECgGon7mBwjFkCcRdnuH?= =?utf-8?q?gH81m/q3+Mzt2R8XGrurSCo4RwTauwGn44plVdQtvE3OJE8XbIOsrvN1I/O7YTxXP?= =?utf-8?q?3aWp6j9EujQ1GyWAkBGo8UinY9NxZCFKZRB/SxsEtm7DvTtqf8DFTZM9OeohHHpRy?= =?utf-8?q?vwjNojWisHi0b3OKkUo+uEnjj5gxwbnYshMIemq5ViqfDGObMZ3sxER34OaZY4aeR?= =?utf-8?q?JWcqN9nJQcu7ILlhWT5Jnl6nMUw55tubh73Pmes4QQOowq7Frt6OdurEgq5jVatRG?= =?utf-8?q?i4/rpV/mh1FkNj/12QfgVUglu4prZ6hKg+wVxiHsOxDX1GnDmtwkXDOPMF0JKHqOt?= =?utf-8?q?p1a94LVg31p5eGUK9v8otzypZjh84QOUrTS36pN8EP4+PJsjleF6Hsj9ZNgWe/1hI?= =?utf-8?q?NmA1YqEyu7x9Gwt/7cvlZkJRAg+QNiqy2yTEt/OONK7yoW+me+qlYCh1++CR8PmPw?= =?utf-8?q?n4ECdxoOE7i4Wtn4psajIcYitUl+rpGO1J3SrdWqlqluilZt98bwhlsBO/wZ/BN4M?= =?utf-8?q?ec/QsB/B1Vny68VpPpYJrbtAvMoVEa/ZLWNzkGd8e62rqOV+koSn/aJfWif6h3YOl?= =?utf-8?q?GzFqi7CGNw+HproXvb2XcPlGnNt2C1HY3BrV9F/YghQmBA/E34zJIVze9ByimB9Ne?= =?utf-8?q?5eF2u3BXXwtn1ZnSv+va8URZtuGQjftGq+ZS/xGqHB6p3xCQTQobeA3fU99n0VuXK?= =?utf-8?q?ITZP/DIdR2m3cVVpBmlbLQLJoQVwqMxK2T3FZ89aLsS/sLhqT/3nLuCsiEeMn+ORH?= =?utf-8?q?9JXRr6yGzi814VOPslJbaM8bdFAzsib6Yy9nGGIisOxv/1sQcV1PIPFpPlepQ/Qdr?= =?utf-8?q?O0VZnIINuN31TmmEubhqRpKY2KWuR1/Rsrlg=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f0a7474-c24a-48f4-060a-08da0b45161e X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5841.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 14:14:17.9311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3ZZ3jNk3xgTHN3W9Qin+moXENrZLJqFZSiPWrr9Gv6P5ALjMTKNYPh513+A1bb+whPikH/8U0rTVq7D2AXBRdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1001MB2258 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10292 signatures=694221 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203210091 X-Proofpoint-GUID: hXcTJZ42F9FNFRZBLHkRa3n7N3i4EBsk X-Proofpoint-ORIG-GUID: hXcTJZ42F9FNFRZBLHkRa3n7N3i4EBsk Received-SPF: pass client-ip=205.220.177.32; envelope-from=mark.kanda@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: pbonzini@redhat.com, richard.henderson@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add destroy_vcpu_thread() to AccelOps as a method for vcpu thread cleanup. This will be used in subsequent patches. Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Mark Kanda Reviewed-by: Philippe Mathieu-Daudé --- include/sysemu/accel-ops.h | 1 + softmmu/cpus.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 6013c9444c..e296b27b82 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -31,6 +31,7 @@ struct AccelOpsClass { bool (*cpus_are_resettable)(void); void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */ + void (*destroy_vcpu_thread)(CPUState *cpu); void (*kick_vcpu_thread)(CPUState *cpu); bool (*cpu_thread_is_idle)(CPUState *cpu); diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 7b75bb66d5..622f8b4608 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -609,6 +609,9 @@ void cpu_remove_sync(CPUState *cpu) qemu_mutex_unlock_iothread(); qemu_thread_join(cpu->thread); qemu_mutex_lock_iothread(); + if (cpus_accel->destroy_vcpu_thread) { + cpus_accel->destroy_vcpu_thread(cpu); + } } void cpus_register_accel(const AccelOpsClass *ops) From patchwork Mon Mar 21 14:14:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 12787299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28C35C433F5 for ; Mon, 21 Mar 2022 14:21:10 +0000 (UTC) Received: from localhost ([::1]:42180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWIuD-00076A-1Y for qemu-devel@archiver.kernel.org; Mon, 21 Mar 2022 10:21:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInq-0008U3-Ba for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:15868) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInn-0002RH-K5 for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:33 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22LCw7O5006207; Mon, 21 Mar 2022 14:14:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=UkMvu7R+yeVsyIM0RED3+6tZA4l5brwWXK5uUWdUC7Y=; b=FprvGfCEgu2qqMwckRCUBfy0qQe7XIvYZLyuKvwmmpRNswCQzpQSrf2Tk88UoUhd9sPD cPFmInKaTG/9soFxP0+37soFuw4tf4jQog98W4oYPWLYQs94vNu2cprUJwo4kjSrqjk/ OULLIhRE2OpVshHR498FumRdm7G+Sw9DgSTKoBNzWDv/XQTjqTcTQgdaxp17q9Snfuvo m/mvjwdsxyiLXLg5Rd2vce/pF+tHMdoYpHKXWU3cVVpeY1fg3OYWUhvzeFv5Olr8UoK2 DX08Ma1NYLMe0vPLvgrpJE1k4mZNNEqhzTJI0jtquO6Kb230Y7nrQUewE/BnowCf09Jh PA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew6ss3cy6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:22 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22LE5cKg051488; Mon, 21 Mar 2022 14:14:21 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by userp3020.oracle.com with ESMTP id 3exawgsea8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SF7CRJMSnukFvCaGI4Cg13y91/qMCNb3g413u6tzBSxnEUHjjNOGHtctC7VL2aHF5j3zOBsnDncUoDIJN6YIvLGCzaF5vj8eUoxifTGF66yLVu/vnGqHBI/jqhX+PUoQxB2la2Wg8hZ+kbCikFLmz/21O/9CT4hZiBTdNxyju2zduBvLpMifuaIQOBc/bAehmZ2OUXlyvNAUZW6A3iXDWU+WlPsw4vu4QETN7fp0tadIM7N2TCkR+zKPirZcELJvMCrN+VvB5XVuXBEjKs1t3Dk9uoF601lOgoZ9mxf0Yo1gNX4qt5neljRik3qMp4hW/aUelyj8ybwkrP7kXiSJlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UkMvu7R+yeVsyIM0RED3+6tZA4l5brwWXK5uUWdUC7Y=; b=K+AexoHNJidcX9tShCjJ51uPjtuA7NA0o5/py+o8ceKAO8wg2TNXN5DhQemhENXPUFrEkFau2exdS431RLJs/0R4OtCaYo0mCLBWurvUrt1zhziaqQUcIdPYowAj4kp/prWR+8EwkeboLg0s5azGqRNcrdib1u6Nr9DE3+86QX4RL94D7hMo+4KEP62K0xWdlGWDkqSdikqnt7FuK4Do4HH6tOAQNFwKjEHOCixuQXWyPOO1JhKkvIMGkhkM/mJg5KsCbHiu5yLQicxZvqmPuexwVDQhHLUuEmJt5UsUPuGbqo8iZKiUlQVletZg1lPLPQ69O7KiA4evHUOy6SB8KQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UkMvu7R+yeVsyIM0RED3+6tZA4l5brwWXK5uUWdUC7Y=; b=Tm1LQnD+puBF6x63B/gUeCPtdOSfjJJFsymM6bM4HyNjacxS85vtMuBU/uJY8z3rkkjf8Y5DKZOtrCQI019Lua6oNi4zbfLZGOr/LQ/qyVysahxAAUsYAV2T8gwDLbThVaNaZQ6mwNGak2xG34Z/lN4JlVg1QYvk5tuzY25DaBg= Received: from SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) by BN6PR1001MB2258.namprd10.prod.outlook.com (2603:10b6:405:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Mon, 21 Mar 2022 14:14:19 +0000 Received: from SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15]) by SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15%5]) with mapi id 15.20.5081.018; Mon, 21 Mar 2022 14:14:18 +0000 From: Mark Kanda To: qemu-devel@nongnu.org Subject: [PATCH v3 2/5] softmmu/cpus: Free cpu->thread in generic_destroy_vcpu_thread() Date: Mon, 21 Mar 2022 09:14:06 -0500 Message-Id: <20220321141409.3112932-3-mark.kanda@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220321141409.3112932-1-mark.kanda@oracle.com> References: <20220321141409.3112932-1-mark.kanda@oracle.com> X-ClientProxiedBy: DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) To SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8865769b-88ba-458a-dca0-08da0b45168b X-MS-TrafficTypeDiagnostic: BN6PR1001MB2258:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qyKVZdVX1IYd2aKzu4E1PnbwVS30e+To0kW4R9PzjEfR1zuSxYR5pOQhMtvbV0qY10PaTi8rF9G3dTWQzUq5eRbW5alS2pbjgv4YAHUFBaWzpwWol/PQy8V5EZCiYbL3Fv+otiFKvbn4aJQh4tLytd7ErmKliedzGV6RgScC1PY0zbdD9ql3seqwiTsPY/uYQKSquWb/QHQKbCATAiGdjhhSLH9uAZ7oMuN5PdP/5/alKcflyFXJklW/zwdWr1gi1n8wyOEdr1qdyGLj1GGq8qhFpa8h0FfASk1FIVbnBdLit/H6+8XmbH4Xiu+s/9y6PulkpEPrVIKJge4ameJaSflnFQtxCY8yuMJIaBoZ/1Qk5Hlmoi4gvJmXWnMO2XL4zGCGgkfxzUkC8wnPUOamq5WldMofaILgukchmtky/+KPSrsES2zHN14iSAAVW08V7LX/GLP+8C57q3WmOW4MSq2SJ1M/rtrjB4gEG45PJVL9+yzjkjaK4OFzRjbh/WJHm0TFaFCyNxR3sbN2/VzdRUNNVWjiP7hLX6He43rjFDofeoZ1nQBlOkzL6DisUXpyOK/8VYSwJd13QwNJnSkODeYyxOePyEXzf6Qzgmaj/zDRdxQk3d2od5TEYKD8Ye3Z1b7gwTMis5+u5g47tfrZfjWl1uNbpGmGFDJKUyesihgUqaN/1tI06oo4OX9M+z6iibPjVgICIUrZMqFm3gnT9mGiLSQgIqU+fp/HNooOGro= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB5841.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(36756003)(2616005)(2906002)(6506007)(508600001)(6666004)(66476007)(316002)(186003)(66556008)(66946007)(83380400001)(6916009)(44832011)(26005)(1076003)(8676002)(4326008)(6512007)(86362001)(52116002)(6486002)(5660300002)(8936002)(38100700002)(38350700002)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yE4K3pkREx/InfCrmLwcxYX2Q06W9vIhKf8qIxSHbGbOV6k9AwCN1fIC1/siBsUKN6Y3JwvoJ3l8ogVceUxWn0eDhaCwH5Sy6bUj+9SRWj6HoknEYCLIhjoq3H/ftYQOYyGpNST9CeMEX48vBQ/GtR+uAhTI/ZSted2wqkUAkhqkqrIfEUeLferv2ayARxjj9x3zKIzfKHFSkFPpPQp4SYc8G21NHWY1kndswHr58NHmoYdP43WWlaoRJ3uRhhGPLsiZk2c60aQRPKeYrK4rNoKQoY8GB3Ntvk0lNE2rw6KSBPvJRyIK8SBefMG3pi13nDBrKmlvJgleD7+2f1E9m6oGxSYCed6jjujWJOc4tXIOr7EHMhlVAUTiSRAfpNwWs5EDfx/y0drOM6hZvYA0Yke7VeILVxAauXoibKsHsZHaq1Cgq6G9D9QHTqSy6aQq40Yo1Eq3YcFZ10nbaj1nwRFovJE4DHWTE9aj4Qwpud6e6nx1WhY4xWH+MYrWQyrp2Ajm7sxlZSnJOkgIDmLOE8Z6DlFBtdgeYBKlZWFEN0eeb2Cw6m/Ij1wU7yooJbrSNqCJoqrpUFxawaxLnSSh9fd33a2hQv8E/LIME49CiC9iixikQJ0XAUCh8vVAncVfFNtf2xvhLHjFqapNyi6suX1shCZjMvhxJVetXZdDMHCd6Ml4m3eRdbR6vICWl8JTNSGZT3Yl3JuBLIoSvPaQmHVlnCtydkcuJFiTxhKyvh9c7JvrgPTwfOe4Mt8FOQUPRoVLr6r+7QeQK0xgsbaeLMcGIkEQTwIzfDyb08JZKBF+J9ox2tX/LEXjDy9wwueVQm+pfQbUCFbLRtqnAHxxHOBuk0cO7By5OtWOJUzFk3JZU/XGf8AyszTB6LhOS6ViOvzUT8rjRSJGH262kbn/g/Ur220Nv25dsfH/aS/gXR5v5sAXfG+6onxUi8vjqaoFOsqM8lxshG1b7OolAfn/HGkTUfaSVoRcCgAjKMcUtL4dfCq1XO433ZDCTUXXlwfbix0L2lGqJP4SIuiiFumHLAWGTe12aIgmS+zMYvhIiBhS4MyCrYGtxMy16qXq/VmT6a0pWVVR3YhRVNQ3uGytscwGq5O1TSdwBvhnhhMVBcN0VKh8w0BLbuGIejg8ts/mdK3GS/pih2n9RfDMGd2MpPTlJtPTWaIMwrInWzU2KiIH0NohvB5Ydpbr+SwKsPtKaNCvVxMujae0QHUM9neQdb22/mSjwre+Yo4MK2dx+u8FPVYkNhvQxbLqC6QgAxEATB12OVNj8Vc8EzbOWDjMn6EZDAHAG0j1kKz4Ukqh6KPd3DXHMZ7RUWhC9I8QPMrv8fB4NWwX8pp//4mp1rOubmwRtR46XqJokeOY8F7h4gBxnzFmbDo6waW4maYTzn/jsVjw0GMqGq71I/bNNRRvLY0OLszA4p4BOUgWITLSOMxL5dqadJJ57vbe/E5IIkYgumwH79HCDarSeUBRBJ8tFA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8865769b-88ba-458a-dca0-08da0b45168b X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5841.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 14:14:18.6353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g7MHpKOLzZm7KE4ymZ8I6Tdq8qSTcUVOcRPLuPf/+mDiIHt4HNlaY3Ae/vVs50+gz6siEwy0yR8wWUtBDnXhQw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1001MB2258 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10292 signatures=694221 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203210091 X-Proofpoint-ORIG-GUID: LW37XsPijQ5mt7V8eyrjd1b0TLa6GccT X-Proofpoint-GUID: LW37XsPijQ5mt7V8eyrjd1b0TLa6GccT Received-SPF: pass client-ip=205.220.177.32; envelope-from=mark.kanda@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: pbonzini@redhat.com, richard.henderson@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Free cpu->thread in a new AccelOpsClass::destroy_vcpu_thread() handler generic_destroy_vcpu_thread(). vCPU hotunplug related leak reported by Valgrind: ==102631== 8 bytes in 1 blocks are definitely lost in loss record 1,037 of 8,555 ==102631== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==102631== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==102631== by 0x92443A: kvm_start_vcpu_thread (kvm-accel-ops.c:68) ==102631== by 0x4505C2: qemu_init_vcpu (cpus.c:643) ==102631== by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520) ==102631== by 0x9344A7: device_set_realized (qdev.c:531) ==102631== by 0x93E329: property_set_bool (object.c:2273) ==102631== by 0x93C2F8: object_property_set (object.c:1408) ==102631== by 0x940796: object_property_set_qobject (qom-qobject.c:28) ==102631== by 0x93C663: object_property_set_bool (object.c:1477) ==102631== by 0x933D3B: qdev_realize (qdev.c:333) ==102631== by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda Reviewed-by: Philippe Mathieu-Daudé --- accel/accel-common.c | 6 ++++++ accel/hvf/hvf-accel-ops.c | 1 + accel/kvm/kvm-accel-ops.c | 1 + accel/qtest/qtest.c | 1 + accel/tcg/tcg-accel-ops.c | 1 + accel/xen/xen-all.c | 1 + include/sysemu/accel-ops.h | 2 ++ target/i386/hax/hax-accel-ops.c | 1 + target/i386/nvmm/nvmm-accel-ops.c | 1 + target/i386/whpx/whpx-accel-ops.c | 1 + 10 files changed, 16 insertions(+) diff --git a/accel/accel-common.c b/accel/accel-common.c index 7b8ec7e0f7..623df43cc3 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -28,6 +28,7 @@ #include "cpu.h" #include "hw/core/accel-cpu.h" +#include "sysemu/accel-ops.h" #ifndef CONFIG_USER_ONLY #include "accel-softmmu.h" @@ -135,3 +136,8 @@ static void register_accel_types(void) } type_init(register_accel_types); + +void generic_destroy_vcpu_thread(CPUState *cpu) +{ + g_free(cpu->thread); +} diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index 54457c76c2..b23a67881c 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -467,6 +467,7 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = hvf_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->kick_vcpu_thread = hvf_kick_vcpu_thread; ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index c4244a23c6..5a7a9ae79c 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -89,6 +89,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset; diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c index f6056ac836..ba8573fc2c 100644 --- a/accel/qtest/qtest.c +++ b/accel/qtest/qtest.c @@ -51,6 +51,7 @@ static void qtest_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = dummy_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->get_virtual_clock = qtest_get_virtual_clock; }; diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index ea7dcad674..527592c4d7 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -94,6 +94,7 @@ void tcg_handle_interrupt(CPUState *cpu, int mask) static void tcg_accel_ops_init(AccelOpsClass *ops) { + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; if (qemu_tcg_mttcg_enabled()) { ops->create_vcpu_thread = mttcg_start_vcpu_thread; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 69aa7d018b..0efda554cc 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -220,6 +220,7 @@ static void xen_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = dummy_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; } static const TypeInfo xen_accel_ops_type = { diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index e296b27b82..fac7d6b34e 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -46,4 +46,6 @@ struct AccelOpsClass { int64_t (*get_elapsed_ticks)(void); }; +/* free vcpu thread structures */ +void generic_destroy_vcpu_thread(CPUState *cpu); #endif /* ACCEL_OPS_H */ diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c index 136630e9b2..b6ef246cbb 100644 --- a/target/i386/hax/hax-accel-ops.c +++ b/target/i386/hax/hax-accel-ops.c @@ -79,6 +79,7 @@ static void hax_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = hax_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->kick_vcpu_thread = hax_kick_vcpu_thread; ops->synchronize_post_reset = hax_cpu_synchronize_post_reset; diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c index f788f75289..ff9033127a 100644 --- a/target/i386/nvmm/nvmm-accel-ops.c +++ b/target/i386/nvmm/nvmm-accel-ops.c @@ -88,6 +88,7 @@ static void nvmm_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = nvmm_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->kick_vcpu_thread = nvmm_kick_vcpu_thread; ops->synchronize_post_reset = nvmm_cpu_synchronize_post_reset; diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c index 1d30e4e2ed..f4ec6b3518 100644 --- a/target/i386/whpx/whpx-accel-ops.c +++ b/target/i386/whpx/whpx-accel-ops.c @@ -93,6 +93,7 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = whpx_start_vcpu_thread; + ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; ops->kick_vcpu_thread = whpx_kick_vcpu_thread; ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle; From patchwork Mon Mar 21 14:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 12787298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59513C433F5 for ; Mon, 21 Mar 2022 14:21:05 +0000 (UTC) Received: from localhost ([::1]:42016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWIu8-000703-Cb for qemu-devel@archiver.kernel.org; Mon, 21 Mar 2022 10:21:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInr-0008UZ-Qm for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:17564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInn-0002RS-Vq for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:34 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22LCw7O7006207; Mon, 21 Mar 2022 14:14:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=PotJIymLkPD7qEHT0b0viq1CcKI6l3095/ds7wdhELQ=; b=KegC7auTztLGOp55q6JWKkJ+IFHtgug/70YT4pL4lg8rCZc6qaxeHMJm1REeOLDuXl5k g5zHi4T0wZKr/Kjq8XC/ETjnlnH8jUN1Sj+NqJO+iB5UoVloXhXSADQLEErIl9DcRN0S ier9XMJjvROnIyWxis7hocgfdGwb5lOj93TpOE/ud3FMH5pkxDEq2SnCsBYK3pDD6GXA AYXRXx1S7IZukjgKt04Qj4B4Y3SlmXEz0LAYW6iCvfVildfVky1LTlqDdvQuEFlSAPpR 4T/UjKhgsA+4HFPFbywq+s4Gp3R/xbUuo58wUKkC7DAeyl25xOgU0V/84kCkSgaNq+iN wg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew6ss3cya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:22 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22LE5cKh051488; Mon, 21 Mar 2022 14:14:21 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by userp3020.oracle.com with ESMTP id 3exawgsea8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S+Fy/b+p+hsIShxFqRCyQ1EunWq5kpHlrqqEemTIV4nRnWvj0UqfRdV6iTyoTqrDNRpE6djZtA9t+LxW9Ul4EXFI7F3Mq590PqcFRM2FHjsUOhJG/K1O/oEgCrUALL2rIL0zRd0iIrywJ4R0zVb6ZICBds4H8JLyFFpVPfAKt9ZqlFDBKMQEjjGqxpH4exsBfnOoe6ovboUNSlHPjrw1CB9n6Aap8lT5ssreR/0Nv0+r8eVKT+qF1ob4BTgnqG0xjth05VHRXajNc196tSF2Wes/jK2w0jp6ALL+/SrDu8DvpEItPCsNFsLq21E71UEQbbHZUiogqpYHIWhCJVZWTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PotJIymLkPD7qEHT0b0viq1CcKI6l3095/ds7wdhELQ=; b=ZCFxOxxtGJ9g8+DI81M1FKmyB9rLyzRo59/EiXRmCcIhnjkFV4JZFzHVdhXf/G23JhiSTqqtELESpd9uwV1E2afeBwrcc0xVPHVFUTjFAHPSIsM6TmE7QnQ7/GagsiZrS4KlDizJGrwNdALCotFkHKxNDauymIEuO+c2o/FpBliaWOU2F6p901FHt43hG2dGennAFFalXKAIV6JFrF3U/NP5QCvGECIopIag5KAwSnlJmhbxl6+hAFLvBwTqGyBhMChzfdsIvWe+7SOF98fM8JgORrjAAtXiPy3hCDNR5vHbSyFl4nxGFEhiIYwSELY7oc0ampghs8AjX9ZAfNfljw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PotJIymLkPD7qEHT0b0viq1CcKI6l3095/ds7wdhELQ=; b=svsMGNxUSLkPQtBFOFqw9TsxAKTa9V09GlQomELQA4cY/tdS9Ode3PVBXJH+/BB65kIvrNp7dzaYFiF9bVJEYoDGfvGi4PxRKVGt1qIA+PD90bDp34SnfU4hkNCql0RfKz4LmwB5ObN6/A3qowaXzU24cOotHrpR3BVP0kaa92g= Received: from SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) by BN6PR1001MB2258.namprd10.prod.outlook.com (2603:10b6:405:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Mon, 21 Mar 2022 14:14:19 +0000 Received: from SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15]) by SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15%5]) with mapi id 15.20.5081.018; Mon, 21 Mar 2022 14:14:19 +0000 From: Mark Kanda To: qemu-devel@nongnu.org Subject: [PATCH v3 3/5] softmmu/cpus: Free cpu->halt_cond in generic_destroy_vcpu_thread() Date: Mon, 21 Mar 2022 09:14:07 -0500 Message-Id: <20220321141409.3112932-4-mark.kanda@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220321141409.3112932-1-mark.kanda@oracle.com> References: <20220321141409.3112932-1-mark.kanda@oracle.com> X-ClientProxiedBy: DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) To SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2deb7145-dd04-4575-83a3-08da0b4516f9 X-MS-TrafficTypeDiagnostic: BN6PR1001MB2258:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XOccuIjpP61uYWFrLivqdehWO+BVcKA1X54g5j35JZ/4I8tbhD7U+Ao82gNCcOyMbIR5NjpuBV8oLWTvx4nyEc+YfX+hYY5vIqXQ5SEmTl8cE2DnXI7+e+QBu1iWilYvToOhIA9vPMidxsdWEmrOnTw4Kq7w4/SDzIVS9PG0niT6iDuPTp1o3VY8JUrdlSYUTLZUQrB516XtWa000UgtUsVYYe6LYCqeO0CtHUs3XlxnedPagF6DGXJab5BQE2psMf6HPJ9bci4m9+c6Hd6M5IO4F8uqZGUTLaG+Y35/xnCtvfhpYA4D7xAMnuVa8cKsqhb0f02ZSUdDfSGpJZNhYWv7zV/4LaKGzJsfmdpoGF6Npxt8qBmyf6VQsoyIZrKEXjGIaEw/upn442wNRuy3mCIDcNi5lUa/wUkisFGTHB2bHHEJK6+2UIkMM80mDTBXahIHoNPpmf9zWA3sWcx0YMPZQQVx/pBB+QVMVq3WtI+8dURkzjWS2tzjVGvsdyoS37h3QLvCEt85ZBh2idgenVnEp79Abr4J6keWwC5+2Gg/wcAal03SD7QBKhqGmpZZuS3XFVQWn6BN3BnFXrXp0sf3/hHh7MMIKyyPfGUmSkEi53b42TUdfAF0uEl48f/6nCi/ABtfNd3eTR8d5FT3yzL+JglxHKqzCtuX+sZdojVGHf3Owbjp0nQ7aS27Gqrse0ALS4gyx1aORVRaKA3NkpN0gIgQ0WwKoWYC2Z6mrAM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB5841.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(36756003)(2616005)(2906002)(6506007)(508600001)(6666004)(66476007)(316002)(186003)(66556008)(66946007)(83380400001)(6916009)(44832011)(26005)(1076003)(8676002)(4326008)(6512007)(86362001)(52116002)(6486002)(5660300002)(8936002)(38100700002)(38350700002)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XmR3YY2lmSgiT4fpwNzAVs7caXhHOJa8XPfD7ePcwjZjDZQgE3AaiCXm/Qc5MZpmaO1J8RZxQpXH71d6346XUoYl2/cGA5cZCk2yl07T/Br/XnbgtcFmugsFhqkt8x6sswZfLCQiYjs7ft3K+rmR7d4VIoybRwAh8AcSKqbGalNrbSfjK765EmZq4XcK5JncXU44n54T+BkhohPzfAo3Tjeks+MGu9yzWOG6mHwMkrt0QOQ+doMjUYX09eJpRKmsl81MkLvarNCGCTFxOvIFNLKQbykMpHB27dPY7TjHRI5j7TPo7Yy1aUYKLHEHMOO7G3QcV5z2ipt5nl/j5Hls3ufR3vL301LLlVcaZuZYMXUPWxzBUEXoXvea4Nc5JJCUTebFEtPGU0RgXWHu7W5dieKMgNCDgZdmXUP6ULUlFtUq8Ax7BAJrWE/nGWXcROPgfndbPZTd19U48QjVm3Hzu9CkBCMclB26+hsq4WwsZAay93B1iZumNNQ+UtQ8LA+kLud+gMoTfpbl08Vxcw8dXnJoYmmS6EwMf7WV1u4jODLimGD2ArAICDiwxAwQ0L53os1ydyL1jZt/ZDnlqnVNqEqbcGJr7OIfUbMISdCHy9MKH0eyTWIKZbp9CXJzf3ChtZGIjDTkTUuuG9DqNRQBt8O7cxcObGQQ6fjzb6QLAQ8nlsIQksFUcgsaIds3g8RTUieBZbsChzM1oHh5Qmn/45BS1X0F3njabVblobkWdfzlO0K71wkqaTARbUeEkd7/iOiPRPZWWGMPwHFD4a//dRfNxeRl/4xyW51MX2JiclEl53UFWcweh3Ow6RokwxYFlzaiephabSK+s7g+cdfvm+22kAjH8znFOcQLlFbBi1weBuY91U7ItX141OONp6zXosEcmqSmh1CQSdeQ6XVCr7tjyuNcoZsnlgrnvGAjdyDVc+Zr9Orsw2GohyxAC0Kpbm81Isu7USur6p/cfY7ZYiHHBjH4pXUSpcn8yL1mKZ3qheA3F1TVfwkDbyqtL9MzMmb9s8Zy+NdI/2mfphDxNg5N0NPEzYPSUz4a1rEVmYcaW2jrJQ6pand+1X6GwxVJFOsjpYCse1NbXOG61zZ6pLr06fkbhE4FS/BBiM3ld7xlpanwQBFq3zephH60IloeWX3gpHqOr9zMgUDUd4I2eK/hEUWCY3csAcez4VPsKr834NX2XDSorhyEikWTb/R5xpI1TXRbkEtlJo+vVPkJV7+8WV4LD9LvFdGssBJuw2NlEihOzZpMyOUraMlYAaRfY+3rqwJl9MeRqZbgf3xQ1YfrXaVSAaU2JLgzXbKdWXgBWa1xAhinUZlb4Ur7wmfonXc0ygFdv2TDiPMO1WvSB9z3xyGrRY44MUMSVHVFwnT2PkdaBgRcwE0JyYCRu/K71K8fEwN+DRw9Hu+2/C8MEn+3TDEujdR3tt4/rdZtG33HJ4LGdmiplLwdNZ6qB1ObnOIKhm6XrAMh96oUa1/Lhg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2deb7145-dd04-4575-83a3-08da0b4516f9 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5841.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 14:14:19.4008 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5pCASNb0O+sfAQNxa47X1OeDF7ATPkfZ2P4UdCPJsDFWa0rJqpKfT401Q3M6+LlHT8hJhp93ew4AzFtxsjAigg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1001MB2258 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10292 signatures=694221 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203210091 X-Proofpoint-ORIG-GUID: wApLM5RS8qK52IiRhuiPTkIaGFwLhqVa X-Proofpoint-GUID: wApLM5RS8qK52IiRhuiPTkIaGFwLhqVa Received-SPF: pass client-ip=205.220.177.32; envelope-from=mark.kanda@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: pbonzini@redhat.com, richard.henderson@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" vCPU hotunplug related leak reported by Valgrind: ==102631== 56 bytes in 1 blocks are definitely lost in loss record 5,089 of 8,555 ==102631== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==102631== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==102631== by 0x924452: kvm_start_vcpu_thread (kvm-accel-ops.c:69) ==102631== by 0x4505C2: qemu_init_vcpu (cpus.c:643) ==102631== by 0x76B4D1: x86_cpu_realizefn (cpu.c:6520) ==102631== by 0x9344A7: device_set_realized (qdev.c:531) ==102631== by 0x93E329: property_set_bool (object.c:2273) ==102631== by 0x93C2F8: object_property_set (object.c:1408) ==102631== by 0x940796: object_property_set_qobject (qom-qobject.c:28) ==102631== by 0x93C663: object_property_set_bool (object.c:1477) ==102631== by 0x933D3B: qdev_realize (qdev.c:333) ==102631== by 0x455EC4: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda --- accel/accel-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/accel-common.c b/accel/accel-common.c index 623df43cc3..297d4e4ef1 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -140,4 +140,5 @@ type_init(register_accel_types); void generic_destroy_vcpu_thread(CPUState *cpu) { g_free(cpu->thread); + g_free(cpu->halt_cond); } From patchwork Mon Mar 21 14:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 12787296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A77C7C433EF for ; Mon, 21 Mar 2022 14:16:31 +0000 (UTC) Received: from localhost ([::1]:35662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWIpi-0002Ow-Gy for qemu-devel@archiver.kernel.org; Mon, 21 Mar 2022 10:16:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInr-0008Ua-Pz for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:17292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWIno-0002RQ-78 for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:34 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22LCwAFQ010833; Mon, 21 Mar 2022 14:14:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=BBXfA7q7lQksCSxnsxqRR7C7Fy4/CuFBSBN4efH+JcY=; b=UedfjF4aQGKcdQXKtls9ouvqnb+cotyiAassl1XOKNAZVKDbD9Mi/ynewDmal2iGq1u/ DtDWnuRhwXFZ62kQUXVGOz7uKoUVM9of64RZa7IHPYL/DcVq42EUbY30tl7jxv0PWpAC +ywaqLo3L0zVn25QkKwDZZ1R5mws1qkZAJRLGSlo/S9wxmNkHDclAVXL/hGjFPClfwGy xz4YrHlkDUyYNj2lGyKD7FkNrRdsVeeFZbVs6+e/uxIpGkmaooLzjuywolV2qrDJ5E4u dcR+xRcuXXXfhB6ZiLcyKz2lf4TUdXcSdjbfz9MBzyzEzfOXoo7rkl+DKKYt33PjMaKs Cg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5y1uecx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:23 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22LE5cKi051488; Mon, 21 Mar 2022 14:14:22 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by userp3020.oracle.com with ESMTP id 3exawgsea8-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N9gmx5D/aBNt6R7zTugFNobTDnpYuD3CyrDgBwqP/AF184OcWw5p9bGz6bEtsy85MgyjSO1Vc+4l/b4jyw12JvUB3/cgmGCrg2gl19vZ3i1jvrHCUZ+u8TIOdaBuyeDbcXStIUKxVd8bDXQouc9gfuTGxh7htdkhKIN9O2rtZTTY01rRLEOEl0IHxzkijbJdDGmRKA5WMnr2CeTsNak5svAGJN7W7yDGZ03sOYn+uzoP35OyZpT+APSZ3Pcanwa+bcL+AO0XV8TyuM/p+qMnrZTfSVAdYjI+0aQfvfdsJkMISUMXJiPvgcX4isVmX6c48rSSydahpEbmhnNwO0fXYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BBXfA7q7lQksCSxnsxqRR7C7Fy4/CuFBSBN4efH+JcY=; b=I+Iwkqq6hhTyjugIVxgyTyaFdtGzf8kImE967r1J3F6zXR8BAPCtF9KdFFuXuZML5v9qcvrkP5tM66R6DDY9KqxIrHe6dhBzBaE4cx6aKZLE1xWU6Na6EcWLwMb7t4hLOwzp/KBGnvKb4X/Jus5qua5FZZFOj1iesdXFkD0MwCpyrWFQVPSD+I/HXxFG2OZEOG4VAlXqGS5xBXnFctJZpQYQilltklmIADtlCyYTqQrYKX9ahZBVKpJo+RXc/DnXbgjtzzH38qjjDYYZ+vY41RX/LcOfARsoqU2wDRJSy9kpciBdpm3Fgy9FqXGP1hzztfCGuRv81iyEEmR65WG+cw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BBXfA7q7lQksCSxnsxqRR7C7Fy4/CuFBSBN4efH+JcY=; b=eA0x1Ziy3fIgmI9oR/xedulQ1bdtztbAOW0oKwEyOxu6VB75PXeuAX/IFNa1kTjgT4hm4pl4Kbtyan8HfWU91RQDzE+LnU9XGWWF6EYcysixc8YXEYYQdtGWapbkLSSsvDa7hugXQqmGn4eU7MN6VX/ekxQB/5szxoPHwTMFuMI= Received: from SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) by BN6PR1001MB2258.namprd10.prod.outlook.com (2603:10b6:405:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Mon, 21 Mar 2022 14:14:20 +0000 Received: from SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15]) by SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15%5]) with mapi id 15.20.5081.018; Mon, 21 Mar 2022 14:14:20 +0000 From: Mark Kanda To: qemu-devel@nongnu.org Subject: [PATCH v3 4/5] cpu: Free cpu->cpu_ases in cpu_address_space_destroy() Date: Mon, 21 Mar 2022 09:14:08 -0500 Message-Id: <20220321141409.3112932-5-mark.kanda@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220321141409.3112932-1-mark.kanda@oracle.com> References: <20220321141409.3112932-1-mark.kanda@oracle.com> X-ClientProxiedBy: DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) To SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: be5581ed-02c4-4750-3d41-08da0b451769 X-MS-TrafficTypeDiagnostic: BN6PR1001MB2258:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: soghq5xHlQakWzVYxO5mQK2RSJV7lX8Uiq90VF7FiA60/jsZi1xHOo9ytRMhFSB9HmK7ki2063yb65p28EbUOhOsH4H6YOSMzr68vzQYnHawRNPE38GOCd9u5qa578PgXDHJhkem5L7Sp3dhrKuVew6j1d+ECPRbPLRtn4SNCkeX0rsAyAaE2bcJEo2e/68GC1Xdzxzp/9IuATxKYeaJHklmCi7iJJ/t5YHNn50/cIKp2KydmdT3o7uDwo7Njwlvu0qkg6zt4EwOE49pr3PrXtMzOx0HBczOqcKZpT+r1fSTzeVHtONQeSKYFUPOEAniNMjEOd18ivTWemChDmvTFMEIi6xV9HBP6Fg/0lMuRw17komZmfPw5JGv/G0SsCOuINFZPyxfZPKfTM1k50ewu32J7n4a5AaXDtpT6DX0apdNEPfRcGiy/dmOziXfM0C3i8iJvQZqr6dqOFcUBZgvzXSU5c6G3s1fjeW+G+VUOqnt5meBP3eTWldpbSmXFM2QD8AmmkkPX4Mkm8VtcM/qDegGzbtq60OJYyC9ye3B+G2IeMMv0y1MZhCcppUvH2+0iR7zjmcs124DqxhN+dUaHSjDF8IuzVOGf+pj+ExS1PBzUe/zUDvDLomvn39/5n7yEPXtgZDj+hGyTPDvqQyQ6jfcZMVhGu885B5k+LjglNG7QB0rYnniXqlu8KbX+h8HPEq7vMRnKyRshs0hDMt+Zg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB5841.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(36756003)(2616005)(2906002)(6506007)(508600001)(6666004)(66476007)(316002)(186003)(66556008)(66946007)(83380400001)(6916009)(44832011)(26005)(1076003)(8676002)(4326008)(6512007)(86362001)(52116002)(6486002)(5660300002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rj2+rpirgzJ9NS9qND/SwiTMEsOPhM5QlP1+DwfqUBDwqxK5gZpPqqGFGgedRlms5L85RyRxkO/1Le9d3HkbukLJp52OAyQpxLb5IL/+FYcx7GDxr+HB7g7cb7wVclcwI2gg+q4zpipdzgu4HVjBsB73llNEo0i/vj0y6KxLUBVsUfMy/F1tC+qVKo3MQLTHsmIu15dwfe9EWZ+UJ/spvnjJJarnY9eg1c3jc4NQfssb9Mm640smEhA7yr1vT2SHRhmQADuh0uBI22nU/GpATbEBmT3eHJhkP/oYC8ParQtszYxyIMwoQ0cxWDlsMWfJ88nAkMXxY7k9638WbjcAFip91DeqysqZv3FDa7pf7zKxsGBTdbOP4l1EUZN09ejEdSXxEdPMo5eQAMAy/prhU2WJDpRx3U7Dm6PLw4+DV6BkJGnRhEtAmuRVnuCHIQpFJIZgGE8SKYq2zJiVGzUgfMrvu7Nq3Ef8a/2KULBsgI5DgG+ATARScLwbXm4Bh/iZk7OkfdSCU1t4hicgGDUWGKQBZhd/GbkGTqnWHYKRRVQj+mzQVCrEdaI3BK2G9F38OVDDXvLW+vfdU9vmIq1qgUxlH3Lln5JXjeb7eYMIwVr+kpC5u/SJ1LUIcNXEL0ZjAZWJfj7QK65xGy4JXlAhNDoldQZ6IXLo1tLkUgVCYs3jhBgFq55Zed2Aig1lL8Xh0zbaIqZs87qNgb5RqWHPfcDzwLlca5mKRsfYkq8xl9F/0c0bmSMaNajAzWbHXul+Tbr+TuTxyrCFMLEc5UWwOTaHrClUmYVGSFPh+qLPH8OqsD+zzQMamiFfHHSkBDHXpXCSExa/uNNPxTxVyOYiELYjVWESIIwKvJSOf5NJIG0FNxNLhWEsVCIX1/ddYrvDQUlBczExrtjPX/5IO9ZnV3EtW3dzYwM1be5waP8vhKToV/k8MQB5yu5UOHnPuFz+WaZ5oKuRFXgu6eZXoGgjeCfNFxllrNSHgDWBfe1nbxNK8DIzoTEH8mK6/9dNhm7Zmy7/nLWPkmeoZuV0GZo8EYtqDIbAcUDn/yuWxnq84kLmf7dlmRzM/hwIgXSm6oTPrbUD2swxs8aYlqeqMNJSRYs3RFa1pssIV0LxxSAw6cQSDwuRvoD/1gvNXgiGQ1CIRP4jn+joYxHx4bl0VEfZG/oN5xV27YFyMe6/224yX2rMjrQurfjC2uarry01Cq6HsSXRYe0hDn0vUCnB5WNNnRA+DQaQ2VGKfOfPXznJNYGYB6ZDvx+seqAtZvUIQ/ZcP/T0A9AfzyP6NycT7J/hfaJdq+/8inkyqX9tL7CnaltXjhzjeSD0+gecxDJ6G34EpzZ9aaizJK6MHZMrMcI4e8xTTsb+G9o7kpCILdl5BC+e545WUv4/1qjiUZokHZRwNguX5GRtO0g1nf1sDonYCUQz3u5+HySdWDqdqokYPcZPhV1CHGFBBUr+QyGkPddvdUDzDf1wgnNUO2VJ/Rjl4w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be5581ed-02c4-4750-3d41-08da0b451769 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5841.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 14:14:20.0861 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mnWOLvpafOIGJ+IVtllBFhXdOjps4HIc3cFXw9BlOlN4AzhZqtQkfen7Tts78KBxLGrmM7miRbKMGTOMSo6hJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1001MB2258 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10292 signatures=694221 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203210091 X-Proofpoint-GUID: sR7ywv6AJnTNVBBNJ5C8po8O4Hag23qq X-Proofpoint-ORIG-GUID: sR7ywv6AJnTNVBBNJ5C8po8O4Hag23qq Received-SPF: pass client-ip=205.220.177.32; envelope-from=mark.kanda@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: pbonzini@redhat.com, richard.henderson@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Create cpu_address_space_destroy() to free a CPU's cpu_ases list. vCPU hotunplug related leak reported by Valgrind: ==132362== 216 bytes in 1 blocks are definitely lost in loss record 7,119 of 8,549 ==132362== at 0x4C3ADBB: calloc (vg_replace_malloc.c:1117) ==132362== by 0x69EE4CD: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5600.4) ==132362== by 0x7E34AF: cpu_address_space_init (physmem.c:751) ==132362== by 0x45053E: qemu_init_vcpu (cpus.c:635) ==132362== by 0x76B4A7: x86_cpu_realizefn (cpu.c:6520) ==132362== by 0x9343ED: device_set_realized (qdev.c:531) ==132362== by 0x93E26F: property_set_bool (object.c:2273) ==132362== by 0x93C23E: object_property_set (object.c:1408) ==132362== by 0x9406DC: object_property_set_qobject (qom-qobject.c:28) ==132362== by 0x93C5A9: object_property_set_bool (object.c:1477) ==132362== by 0x933C81: qdev_realize (qdev.c:333) ==132362== by 0x455E9A: qdev_device_add_from_qdict (qdev-monitor.c:713) Signed-off-by: Mark Kanda Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé --- cpu.c | 1 + include/exec/cpu-common.h | 7 +++++++ softmmu/physmem.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/cpu.c b/cpu.c index be1f8b074c..59352a1487 100644 --- a/cpu.c +++ b/cpu.c @@ -174,6 +174,7 @@ void cpu_exec_unrealizefn(CPUState *cpu) tcg_exec_unrealizefn(cpu); } + cpu_address_space_destroy(cpu); cpu_list_remove(cpu); } diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 50a7d2912e..b17ad61ae4 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -111,6 +111,13 @@ size_t qemu_ram_pagesize_largest(void); */ void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr); +/** + * cpu_address_space_destroy: + * @cpu: CPU for this address space + * + * Cleanup CPU's cpu_ases list. + */ +void cpu_address_space_destroy(CPUState *cpu); void cpu_physical_memory_rw(hwaddr addr, void *buf, hwaddr len, bool is_write); diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 43ae70fbe2..aec61ca07a 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -762,6 +762,11 @@ void cpu_address_space_init(CPUState *cpu, int asidx, } } +void cpu_address_space_destroy(CPUState *cpu) +{ + g_free(cpu->cpu_ases); +} + AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) { /* Return the AddressSpace corresponding to the specified index */ From patchwork Mon Mar 21 14:14:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 12787300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3940EC4332F for ; Mon, 21 Mar 2022 14:23:46 +0000 (UTC) Received: from localhost ([::1]:48540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWIwj-00031E-6x for qemu-devel@archiver.kernel.org; Mon, 21 Mar 2022 10:23:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWInr-0008Ub-PZ for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:36 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:14542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWIno-0002R5-69 for qemu-devel@nongnu.org; Mon, 21 Mar 2022 10:14:34 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22LCw9ls022265; Mon, 21 Mar 2022 14:14:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=NwW9/0J08o9mptHOQqQPH2TfCYDcpXPmu8kOGWqy9e4=; b=wC2/oHdHXxc7B+PSy6djnEY93/BaBCeyvIxd/s+hXFxa/jMLkxvJTNke3IOIE98sTKoy wzYI5lwFS4eVVk+GpdQGE6nCJEyLL04Y9O5fzjB5a+2SqOuDg2V0lJXU1OgrCWY7xhdm EDXRFY1/3ohNNo3k+7asW6iScOu9il2R02nat/KynJAFronZrlaIBVkXVD+G5Ao0G7em Q/dA8p4e3Rp6skXoTjrLLfiPfnEmmC7Mlx/Wu5o8zxTEav3ccVrkyijXKp/yohhPZLp9 awsbaVrw6vhyk3NERjfoGF5jn29uPvaDQ/5K5dmF7iLKlU4ZPp7nZYjIOio8D3TdRtAT yg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew5kckd20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 22LE5cKk051488; Mon, 21 Mar 2022 14:14:22 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by userp3020.oracle.com with ESMTP id 3exawgsea8-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Mar 2022 14:14:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OW3CLBvCDaAlTCBwmX+9CK5GEzhIdFUayTbkvruTWtqx1dNNsq9/1ZaYvh3jbr0v3SP2eZGmHFpxP3gVYo2bN7ySOgBeFUtmLPng71Mj/QtMHAECwocpdZLb8KDQr1CCH2qWMaYOhdXhskmEPJzIJ32cazzZZPob102YZFW9wwV5UefV6PiHLw8x7IwDe//6XmEXMo7crlsPAv8kLM6n6Kfj3Ne1/vBc4tCrM83hUzPAP9njJfn6n9Swt/5lu8JQSK2R7D7+ZMXyQpI0h8tDWO5TyZi/h8Wsesj1k6a/FASogjYhOjiFiMvODoI2dJPhHKML0NfFDgRAbqu/PMFU5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NwW9/0J08o9mptHOQqQPH2TfCYDcpXPmu8kOGWqy9e4=; b=HhsHxR8qGkHb1XNcjijON+D8oeKrbYEDX0GuabBPxLbsAj8GlI9D9+/IKbpcNBUFPyiN9vzoJE4H7r7O6ugs3IsrulUPCwjPUHTewyZRl4zchSq0BO7balsuMPwVzVYTz1TPTL0qhYK5ccgo4Utzn34B1SX7/SoctcoQS6vCIzoQHkRkuLmYUPdZubK9qaZyHSipvLSfFavA6ew0ePB2zyTGIZZdN+FSKS+9c0+TQcPMbyBu6HwDiF+QdzW1ajKphzAW05ldY47f1S2Gg2jol125l3bDRpRyg+OT816bts315vKETSnoBCtIhv2WSNRipN1O10mS9tndK5KUzPn+Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NwW9/0J08o9mptHOQqQPH2TfCYDcpXPmu8kOGWqy9e4=; b=jq6iIOAXru3BSgkDvmsd0xJmyIoaxNsbbiVplcMdTOaYwYReMIoC1XzW/r4WDK9ScJJarmKb83mpG+TIR6noy5WRnvLYEsFmVSXzzPqpu3/9+5G7caodNB9iQUDSg8VZWsk+oZ0K80OhVsA9nu8iPXEYhgfPqKoGgqfrPfsuzOU= Received: from SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) by BN6PR1001MB2258.namprd10.prod.outlook.com (2603:10b6:405:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Mon, 21 Mar 2022 14:14:20 +0000 Received: from SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15]) by SA1PR10MB5841.namprd10.prod.outlook.com ([fe80::85a0:903e:852d:6c15%5]) with mapi id 15.20.5081.018; Mon, 21 Mar 2022 14:14:20 +0000 From: Mark Kanda To: qemu-devel@nongnu.org Subject: [PATCH v3 5/5] i386/cpu: Free env->xsave_buf in KVM and HVF destory_vcpu_thread routines Date: Mon, 21 Mar 2022 09:14:09 -0500 Message-Id: <20220321141409.3112932-6-mark.kanda@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220321141409.3112932-1-mark.kanda@oracle.com> References: <20220321141409.3112932-1-mark.kanda@oracle.com> X-ClientProxiedBy: DM6PR03CA0096.namprd03.prod.outlook.com (2603:10b6:5:333::29) To SA1PR10MB5841.namprd10.prod.outlook.com (2603:10b6:806:22b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5c1df8a-9f47-4c3d-835a-08da0b4517d6 X-MS-TrafficTypeDiagnostic: BN6PR1001MB2258:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VELyGiVYV7Pm3apq80ac3/0I2ML7nyRc+7nLyQp/uP1X+f6QcH/Xg+4KCsUG46Rr2rAM15zs40MKQLNYJXIpFh7vALc8dHOQlpDf2VEsu3hVWoYSCvn8nk//KhrBrDh3u6by5La75GWUypjEsuHZye5jjB97XbhGMRB/en+dsj873Pv3tjIpRmZWP945byjAN6Sz+xsMdXLMvIjZmGB7J5Y7lQHFjNa/M+tj13vtJKBBGU7GN3/bFX+qyTcuXdczcKr/5DkoDJuaEol+cPk9iz1Q3Y7AYKrN86lNEBeD+VV0I5oZyj+mUD01Q4EgcuwQgkAg0VbT9UsiW3hQe8OKVW5G0n0hzNeaRnNX/0ebPsEU+7PT1WgPqQ+VHl7rydlwz1HNvD1APcOsXJPeH0aMzW/1kuAVXwcWYt6P4LNOdSyynxHVedLR5Y2IJBNJ802TiAceFO0oTUm2WCaNw6hXzvFXoCwOZ3Dr4zA/UVhrR3rbI5iIPnOaRA9CsYLxthdoDVLdfj2OL3MJWmJlxpTcT3GoB9v/XPUNj+rP07IjDESZJw+68+lFWhVLlplCmHrf6p+rkkQf8OtL9+OvYFbWx9FQNLORRCd2NjMwokiogk1uqEO55ksRFHGeogns+GMnVyCRSwHfYn7Tbk7mRwIDjnId8vYdSciHVMB5FpAhHlKQUfwtU7Lepsi+vmBG/6aISZfLKe4qh8yHY3wiIHcDvw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA1PR10MB5841.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(107886003)(36756003)(2616005)(2906002)(6506007)(508600001)(6666004)(66476007)(316002)(186003)(66556008)(66946007)(83380400001)(6916009)(44832011)(26005)(1076003)(8676002)(4326008)(6512007)(86362001)(52116002)(6486002)(5660300002)(8936002)(38100700002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fFq69HD6l+Gv5k6yQs15r9tBelwPPu7Ik+BlEXDvEVC0qLi4dbyDNBC2UR7AD2LeoK0QYKgqZJA3ePaIgFGip5RUGGiPx5s8XHRvriUDqbUch/bU5R2CDDmiDLh9tb90MoG+0HPPvw4dEqX9bGTz2K/Wp6DXImX2YtvaLXF7zm5sMujPyNAHqCGAVtnzB5V5ltPH4OonCO9wEII4wmFHxw4tffPOdL9TmLjK++6dA8rrqYY9FqzmKejfKBNsG42E+X7CKthkCvns6CvlHj44tTiqDy7CCBYkgDdL94leu2V0WeNbOa8qQ+0Q0u+eqYLWkfp469d16TislAfo67FdGxCP2UQEYREQoTzcymo5KSUQEq5eN65/GAKGNNCT7MouffPiyFUE9qRU7YlnNfF3ourKAXVSa8mPbZFhzN+i2b/P9k6FkS8t+oT2cWP9LV+qPgONRZTpwmopQ0NcrStOoptZvwKcS0Ug8uQaQEcJPCzXaEbaPiVRv23LnCx3s2niS4UG9gaAQmMei433Zs+3ZSYpbIBT4O7sF0dE+ugv0NTdFNwfD6j0rXbL+FYaUE+VSrupq1LUwARgw1yDi6nZNySrH7fQvkj0GtXcarwv7HAcnYNDTlrxyOLyxQeacdISTt8KuWwmXQa2WnMI5i+9kUZZhhOwD3oE0tPL8k5Vi4I1NJnXPNXZLIiKSFvxS6Ep990dk+ZWQFoUr5CpzFrqD5nqWPunLF9vt13Awq35p4HLyXUSYIKwG4TQRctSStJqu/voivAiaGuslpC5mm0TUVUXZVfArWNgHkk220R+0zm0SfLCr5Ng99aLGRb5u5r6AirisLP1ARP3t72ImVGAl9SHVARxY4D4+NQuDBEJNp9RRrsWMIfA/ud93OeeBPymBRsB/WpDGCZi9t2wZwBzsBqP//v2IJlPKgvUsYGG3kqQbBSuPmzhABM1ISNdf3cV0oMSMkwiOghARdMF1Uq/2vRTpbXyhRMHdpGq4dZGqavc6nQXJaSFhIFQMiVJu7GUp61r8AkCyJgqn6CR8iYsFhqPC86YSRfJQqVii67GQ1t4STbc2Ne0wm4fm+8xngAbbzpT4BP34QY4mnbZbbak0TARlrQPwBf9kp4Ry4n3+5XjyIZgscWBUckN365RO1SiEafhiwQj0jG8j9JkBMArgI7uoNve1VtBiNPkcy5UMGrmdFlkFUHZz6xeYiMR4l2wFXHp+OdWL/651UqyMUnFpFOsyUAejhf2/PXRTjEDmTvtEo2w29cJPHLv5e1bH+HJcbYuLphDZFxPnBLZDUwFwg7EMkjdZKAdwxkvNNj0TgKvCo72HWyY/03Jn96TUWqzDO9RSqn3VKGjNnpZ4d45B4OHA50cPLo7BVxyivR+dZdHgC+GGe7g1t77yWxclPrnE1sEC4Q1scR6mcJWeMrXrfMLSHRdqAAX+XvpLgKiVRdmowpOvr1uQ2BxA4E15aUxeqS4NcU2MHnGWzpDYe0OMg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5c1df8a-9f47-4c3d-835a-08da0b4517d6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR10MB5841.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 14:14:20.8023 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DgatYsBHUGkbPlm/JvRqAyj1tLI5UDv2DfR7G2jXrWGPkJhijyZKX+u6DEk5xbsDo6bmHHXUdyROYK9lTBwa7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1001MB2258 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10292 signatures=694221 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203210091 X-Proofpoint-GUID: _iPvyKmIyBySkXlAUtIZhfjOdEHER6sP X-Proofpoint-ORIG-GUID: _iPvyKmIyBySkXlAUtIZhfjOdEHER6sP Received-SPF: pass client-ip=205.220.177.32; envelope-from=mark.kanda@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Cc: pbonzini@redhat.com, richard.henderson@linaro.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Create KVM and HVF specific destory_vcpu_thread() routines to free env->xsave_buf. vCPU hotunplug related leak reported by Valgrind: ==132362== 4,096 bytes in 1 blocks are definitely lost in loss record 8,440 of 8,549 ==132362== at 0x4C3B15F: memalign (vg_replace_malloc.c:1265) ==132362== by 0x4C3B288: posix_memalign (vg_replace_malloc.c:1429) ==132362== by 0xB41195: qemu_try_memalign (memalign.c:53) ==132362== by 0xB41204: qemu_memalign (memalign.c:73) ==132362== by 0x7131CB: kvm_init_xsave (kvm.c:1601) ==132362== by 0x7148ED: kvm_arch_init_vcpu (kvm.c:2031) ==132362== by 0x91D224: kvm_init_vcpu (kvm-all.c:516) ==132362== by 0x9242C9: kvm_vcpu_thread_fn (kvm-accel-ops.c:40) ==132362== by 0xB2EB26: qemu_thread_start (qemu-thread-posix.c:556) ==132362== by 0x7EB2159: start_thread (in /usr/lib64/libpthread-2.28.so) ==132362== by 0x9D45DD2: clone (in /usr/lib64/libc-2.28.so) Signed-off-by: Mark Kanda Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé --- accel/hvf/hvf-accel-ops.c | 11 ++++++++++- accel/kvm/kvm-accel-ops.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c index b23a67881c..bc53890352 100644 --- a/accel/hvf/hvf-accel-ops.c +++ b/accel/hvf/hvf-accel-ops.c @@ -462,12 +462,21 @@ static void hvf_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } +static void hvf_destroy_vcpu_thread(CPUState *cpu) +{ + X86CPU *x86_cpu = X86_CPU(cpu); + CPUX86State *env = &x86_cpu->env; + + g_free(env->xsave_buf); + generic_destroy_vcpu_thread(cpu); +} + static void hvf_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = hvf_start_vcpu_thread; - ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; + ops->destroy_vcpu_thread = hvf_destroy_vcpu_thread; ops->kick_vcpu_thread = hvf_kick_vcpu_thread; ops->synchronize_post_reset = hvf_cpu_synchronize_post_reset; diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 5a7a9ae79c..0345a30139 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -74,6 +74,15 @@ static void kvm_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); } +static void kvm_destroy_vcpu_thread(CPUState *cpu) +{ + X86CPU *x86_cpu = X86_CPU(cpu); + CPUX86State *env = &x86_cpu->env; + + g_free(env->xsave_buf); + generic_destroy_vcpu_thread(cpu); +} + static bool kvm_vcpu_thread_is_idle(CPUState *cpu) { return !kvm_halt_in_kernel(); @@ -89,7 +98,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); ops->create_vcpu_thread = kvm_start_vcpu_thread; - ops->destroy_vcpu_thread = generic_destroy_vcpu_thread; + ops->destroy_vcpu_thread = kvm_destroy_vcpu_thread; ops->cpu_thread_is_idle = kvm_vcpu_thread_is_idle; ops->cpus_are_resettable = kvm_cpus_are_resettable; ops->synchronize_post_reset = kvm_cpu_synchronize_post_reset;