From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 569FD7DA6D for ; Thu, 14 Nov 2024 16:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731601760; cv=none; b=sMZ8yL2Iejwntmewo2twN8JX9hIuuePBnvycraWoveHduCKNZr34gu9xrgJNH3FFQbrpjtwteaRxXbVnWNWscvdF5uWTb9rXyrqqfXQo85k1l2VeUqj5NsnyYWqHQHtiWGXFsAp6ocr6kUxsL8KW1XLwgLLJCtMW7EXIZQi+9DU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731601760; c=relaxed/simple; bh=jHldP1zFkwmIw1b+wrZoVG3viZlbK8CqR1ZO3jsgYBQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VJtr7RhBCxyt+jfeXCsbdmwpxcnTSrP6VV+3GIaiKBHl/1CRFSm2qWyL0OOU0/jqDo1I3Qflq8vZb6edMcqK+zOdCwH2pRs09E3gvGc52JChbErRcRgzhg6A9D5sXBYcxM13oHfMpcvOHZf9y6MOiMI1mnD52Jz2SC7YMq2kroA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=r69F1I7U; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="r69F1I7U" Message-ID: <5b777915-ef7f-4d21-8b23-cc79016aef32@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1731601755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ACbkQ9EQubbduYBGoGWvNxCoW7nZ5amK3ybGUy2gQO8=; b=r69F1I7U+fciAP5/ZN8fYGBq4LZ5V16uzwLJ8BccECQ/HOeK4c94uLGw8dOu4T+Exbreys IZJDLfWkUVKxqgaCklS5c0RH3vJkJ4jU5y1ECbHGrPZyo0bFsIvUAyY5tTnxPx8CG2QgOh lyA9Me1QARcTehKwm8lOxOoGglWYb1Y= Date: Thu, 14 Nov 2024 08:29:09 -0800 Precedence: bulk X-Mailing-List: dwarves@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH dwarves 3/3] dwarf_loader: Check DW_OP_[GNU_]entry_value for possible parameter matching Content-Language: en-GB To: Alan Maguire , Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo , dwarves@vger.kernel.org, Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, Daniel Borkmann , kernel-team@fb.com, Song Liu References: <20241108180508.1196431-1-yonghong.song@linux.dev> <20241108180524.1198900-1-yonghong.song@linux.dev> <5be88704-1bb0-4332-8626-26e7c908184c@linux.dev> <48a2d5a2-38e0-4c36-90cc-122602ff6386@linux.dev> <5e640168-7753-413a-ab00-f297948e84ef@oracle.com> <71778df3-62a6-4b1d-9ccf-4a8eb0e23828@oracle.com> <548c7b6b-3b84-4053-baa7-72976731ab87@linux.dev> <9bfe242b-b09b-47a5-9446-1cfc0897aef2@oracle.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <9bfe242b-b09b-47a5-9446-1cfc0897aef2@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 11/14/24 4:16 AM, Alan Maguire wrote: > On 13/11/2024 18:27, Yonghong Song wrote: >>> Thanks for the additional info! From Eduard's analysis, it seems like it >>> is safer to take the libdw__lock around dwarf_getlocation(s), since >>> multiple threads can access the CU location cache. I've tried tweaking >>> Eduard's modification of Yonghong's original patch and adding a second >>> patch to add locking; with these two patches applied >>> >>> - we see the desired behaviour where perf_event_read() is present in >>> BTF; and >>> - we don't see any segmentation faults after ~700 iterations where I saw >>> one every 200 or so before >>> >>> Yonghong, Eduard - do these changes look okay from your side? Feel free >>> to resubmit if so (fixing up attributions as you see fit if they look >>> wrong of course). Thanks! >> Thanks Alan for working on this. The following are some suggestions for >> patch one: >>   1. rename __dwarf_getlocations() to __parameter__locations()? >>   2. rename param_reg_at_entry to parameter__locations()? > Since it returns the register number, what about > __parameter_reg/parameter_reg()? > >>   3. You missed the following: >> static int param_reg_at_entry(Dwarf_Attribute *attr, int expected_reg) >> { >> ... >>         if (first_expr)                     // this line >>                 return first_expr->atom;    // this line >>         return -1; >> } >> > I _think_ I've preserved the behaviour described by the comment at the > start without using the first_expr code. Note that we set "ret" in the > "case DW_OP_reg0 ... DW_OP_reg31:" clause of the switch statement, so > will return that value; either directly, if the register number matches > expected reg, or eventually if we don't find any DW_OP_*entry_value > location info to return. This I think matches the described behaviour: > > /* For DW_AT_location 'attr': > * - if first location is DW_OP_regXX with expected number, returns the > register; > * - if location DW_OP_entry_value(DW_OP_regXX) is in the list, returns > the register; > * - if first location is DW_OP_regXX, returns the register; > * - otherwise returns -1. > */ > > ...but again I may have missed something here. I have some comments in v2 and will reply there. > >> Patch 2 needs adjustment as well due to the above point #3. >> Otherwise, LGTM. Since you are already preparing the patch, >> please go ahead to pose v2 after you fixing the above things. >> > Sure; if the above sounds okay, I'll submit the patches with updates. > After testing over 2000 iterations of pahole, I haven't seen a > segmentation fault so I _think_ the locking in patch 2 is sufficient to > avoid crashes. > > Thanks! > > Alan > >>> Alan