From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1583524A046 for ; Wed, 24 Dec 2025 11:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766576901; cv=none; b=CC0d85i4PMCNdHxMtGCqk9PBQDPkr05z2g/+ixzBz6EBSUO+0YuPhEX5hIEfHR7Z1HKz7IuELI+NTvuKlnj2y9FbCOl1IrVQV7wAGLcrvnGCONU54c+z5yGEVyJU9jrYwrqvWtC+rlPauoXsr6Uxjs3OlZquuPaE6bU6R80JxCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766576901; c=relaxed/simple; bh=+lmWrVRoB9NV1lG7We0TArMYCWYCFqVWUWrRovJRVsQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CEZo6tZ+BmlFNPQiPjq0XdODeReLJMPq6lEc3MXvxWVmXDtZbnIA8jZc7gNwOptSeV1CVS4igZqInbEZ9/F6Lxt72tOpxK6Ku9sPN/8f+W9SFob0Mx4lKV5WqwnyygWx0lStB9LnOMFjnbzs81fR4ZdnhQ03NjllGBlefLAezt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qrOFOCb+; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qrOFOCb+" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-47a80d4a065so30529325e9.2 for ; Wed, 24 Dec 2025 03:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766576898; x=1767181698; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=WmwJnPK0/k19zvjzfNZyD+piNt5FoQgvIZxs3BnyujY=; b=qrOFOCb+rUhEtXle0N+t7ynLaxalCYdFy940CkPVSvbRDaCBvXJFD+ufw1/ahXICWO Ceo92mY9qu6b0t1kQ5IPr8NLdx3aKVpTHLaAuMK1ReRL+ifCS9GXPmoQzwrmfRU3DPNt loz2ewcJm4F7vBDtXrfepg546qNqh3d/cnE4D3OrUqzlG4WXAfFLAZNTSDMh/ScIEVoL ptDJ765xSphWU/hCZmcADRYbsXYEg451GVCcybGMyFTr4sMq0B7dEPykxFlEL1Kc44YB J/zzdkKHaTAeE2u1ihG4ikhk8E0s/64RUuGPXwl1LtMOo36FvMslMve+gG3XApBQEr/Z Os7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766576898; x=1767181698; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WmwJnPK0/k19zvjzfNZyD+piNt5FoQgvIZxs3BnyujY=; b=cKEHnkGWIVnPRDIgS+MlUsa57oSEcJooFuGUVCuWLg39w+w8L8BIZcCb1xFeqUDFP8 L1ozw9ZMlt8q+KDG6b0Epawewvzg2DPbvdaSYeNQZds7VaqgON1YY+fOTM1Uoz6qJKrf BshEeEGXLL8QjreWpr6Msy3nFYRI24oS9M0F8kpnxvBitQavNURDUFq4gNhO2t4ahWTO XWOfqkdyOShpEk+QEmK4Dq1W8AG5qAyrV/lKtoClxMkJnY5oErQOUhH0s8CmFZYGoeMi ovCB5SZWwItLNXwvPYPa1pNy+5os1AXBsMuu8LlbbxMfio1wl4x9IoabqfXbkT33lKBP CYFA== X-Forwarded-Encrypted: i=1; AJvYcCWNUI+58XsM+Uptu/A7y8Yzksiek+5SG5b3RfhNp9gfCa2+ZBFq9sjoK+mYHM57jlEt+N3tQ73QZeIqYEY=@vger.kernel.org X-Gm-Message-State: AOJu0YwMlRedF8W0GN1fL881Ck4iUZx5m7kNrrWvQc7SnxcAqSjPdlpr lvLxE6WwnQIwe8gO9O5VyDpKdp71/S4ENiJL1LxQBLftXE894E90bCXZ6ORlcwqbcdc= X-Gm-Gg: AY/fxX7JR35c05DFTv5aCxTyP4HjKVADkKMNz+oqzQkxy1+0XmXM73sVk4UFmvjefVa OP3ZOASB6ZduO2Cfpm3YMFn1Oj815U82XerJ/t5qc/h06AvhpnyynNxYRKGqf8UGOoJWKXOpZkU ymE7HZxvDIBUr5lnoOX7m4tbb2SuAjlHdpeFOh+GduGq8oPWTqDamJOHcZE2fA7lwaxD+T/EZaD /bZv8zhXJgmDU5W7a98mW8E62sFSeSuPskLS/iR63F3Yj4W8wmlyQfOIineCYjt1BFelgULNTEO 1mFqgGDjpIeC8wqFU4kNQfQTVjSqTrCU5pPXbp0mxsPGCFpREtytZc8TxBrruV5FvIJxNM7xGMo VRjZyO5pIDhR0D+Ac36AjMPv7RMI1VjwnSFSYjS5dh51csN7/4kxBQKzJflxNwOE6YTkCcdJNHx 8P4FYQS1YhpUomUp8s X-Google-Smtp-Source: AGHT+IFQnxOS8Fo9ssG9yvX5CNSoShelKmbrQ1jOaq5Jq5+SpaY/9sMIMbiDZiAMgXJiLpNEz1Bvvw== X-Received: by 2002:a05:600c:c493:b0:477:8b2e:aa7d with SMTP id 5b1f17b1804b1-47d19586cd4mr168937395e9.30.1766576898316; Wed, 24 Dec 2025 03:48:18 -0800 (PST) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47be279c637sm327991215e9.11.2025.12.24.03.48.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Dec 2025 03:48:17 -0800 (PST) Message-ID: Date: Wed, 24 Dec 2025 11:48:16 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] perf jit: close agent in Agent_OnLoad() To: Haoxiang Li Cc: acme@kernel.org, adrian.hunter@intel.com, alexander.shishkin@linux.intel.com, irogers@google.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, yuzhuo@google.com References: <51b38c17-4cb7-467b-8606-fae51f629802@linaro.org> <20251224113918.1593967-1-lihaoxiang@isrc.iscas.ac.cn> Content-Language: en-US From: James Clark In-Reply-To: <20251224113918.1593967-1-lihaoxiang@isrc.iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 24/12/2025 11:39 am, Haoxiang Li wrote: > On Wed, 24 Dec 2025 10:39:18 +0000, James Clark wrote: >> Does this actually do anything? jvmti_close() is already called in >> Agent_OnUnload(). > > I think Agent_OnUnload() is not called if Agent_Onload() fails, so it > is necessary to release the resource. > The docs say otherwise and suggest that VMDeath() is actually the one that wouldn't be called if startup was unsuccessful. But Agent_OnUnload() is always called: this function will be called if some platform specific mechanism causes the unload (an unload mechanism is not specified in this document) or the library is (in effect) unloaded by the termination of the VM whether through normal termination or VM failure, including start-up failure. ... Note the distinction between this function and the VM Death event: for the VM Death event to be sent, the VM must have run at least to the point of initialization >> The commit message is lacking any details about how this was found or >> what the effect is. > > Sorry for that. I found it by a static analyzer prototype and comfirmed > by manual review. I think it leads to a resource leak. > > If this is ok, I modify the changelog and resubmit it. > I don't think it's enough, you have to actually run the code that you submit. For all we know it results in some double free and makes it worse. > Thanks, > Haoxiang Li >