From nobody Tue Nov 11 13:35:21 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1556034684; cv=none; d=zoho.com; s=zohoarc; b=Cwn+X2VYVwKVBhOboB+s3qk06LExhRoZIMLqulyVmqAigu5B4o0Gw/AdygI6PPQipCnlJlS479+E5w3jIEJ+i1tk+l1JS96oPga0oNA0bKkOkloxpB+d4Q2uMC5ihL3heqttTgP5rzxnvftyGkyfFYcw2YqC3xhG84aKeXxg1AE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556034684; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=VPJlZVPNAaAHat2OpQibWapvzuGRYQ0t/X9xYbxlkvs=; b=Ji8Sb0JhTDUL6M8ssvpED1mye8fa5Qzh5bxej1+5Cft0N5i7yzQ2Y/x03mb6OGwkGObrEpm1rgz9+HmDJPHNO8j1WPGp2fVV5JayazHoC0p5vWtcIJoIru58UImbOLT00y2JViFo+SZ44pFwIgbYY42WmtLJYhz4JQ0R4P4C6DA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556034683998568.1461808368629; Tue, 23 Apr 2019 08:51:23 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hIxgH-0007Ip-Br; Tue, 23 Apr 2019 15:50:01 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hIxgF-0007Ie-GJ for xen-devel@lists.xenproject.org; Tue, 23 Apr 2019 15:49:59 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 720ff71b-65df-11e9-92d7-bc764e045a96; Tue, 23 Apr 2019 15:49:58 +0000 (UTC) X-Inumbo-ID: 720ff71b-65df-11e9-92d7-bc764e045a96 X-IronPort-AV: E=Sophos;i="5.60,386,1549929600"; d="scan'208";a="84208328" From: Andrew Cooper To: Xen-devel Date: Tue, 23 Apr 2019 16:49:53 +0100 Message-ID: <1556034593-3692-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/timers: Fix memory leak with cpu unplug/plug (take 2) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Tim Deegan , Julien Grall , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Previous attempts to fix this leak failed to identify the root cause, and ultimately failed. The cause is the CPU_UP_PREPARE case (re)initialising ts->heap back to dummy_heap, which leaks the previous allocation. Rearrange the logic to only initialise ts once. This also avoids the redundant (but benign, due to ts->inactive always being empty) initialising= of the other ts fields. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall --- xen/common/timer.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/common/timer.c b/xen/common/timer.c index f60712a..650e398 100644 --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -657,9 +657,13 @@ static int cpu_callback( switch ( action ) { case CPU_UP_PREPARE: - INIT_LIST_HEAD(&ts->inactive); - spin_lock_init(&ts->lock); - ts->heap =3D dummy_heap; + /* Only initialise ts once. */ + if ( !ts->heap ) + { + INIT_LIST_HEAD(&ts->inactive); + spin_lock_init(&ts->lock); + ts->heap =3D dummy_heap; + } break; =20 case CPU_UP_CANCELED: --=20 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel