Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1142765pxx; Fri, 30 Oct 2020 03:14:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZBxId03nAV8RbmaQ6XDe4xoR9rPMdDkdhF1CuzFUemkOR9IN4llrpkE3RcELRra3XI3Be X-Received: by 2002:aa7:cd98:: with SMTP id x24mr1382166edv.237.1604052873491; Fri, 30 Oct 2020 03:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604052873; cv=none; d=google.com; s=arc-20160816; b=BmpwR4bWxfFGuszDU7nVFcFBQSzKya0APjW5S83bTWQvlwd63vdClDpnXdC54sc/ZS mS3h9TrqZ1T7tB2UOpQwNpcM/5qIEXIr0DSnlAJ4/NCRUmCDJT8pQ7ZlxOwLudxT0nFw 4pOuC5gJN84oCkUsuSNfTGkFPUEVIo7UJIQrC5+TmHo5B151qdf1vpOjTP0wuqZabXRa cZFIQvHLGt8ArJNT4krBrCJ0U/k10lyfwbtaMP48KZYGk1i30cV2rnc4i2yBGa6aqE8i 6LKh6hMzoyVDHdFHjepmPjHhIQPdlNoKHpnRInTdCRSNR6egERhXSZVEVFzmCV6KaIab 0TJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=u7YtPu1a20CnPHKzQzS9jt9YAYOEyPc1Wfcc8V34Xok=; b=rO48InqLlloAB7ta/4RlO8Ik8J6yP8B6jv6gsTF+V6Ut1i3dF84LzxVchJdFXRyRwr mSDgrOgLmgbZ8HtiC6Opi/sBhPsd91NmqP2Q2D/vg8ot0KfcFN1nAuk9PJlSQ1gRutTh PKpArpdmOv7fve38phvs5BkoikqVpL/2aCRGDgYyHSst4t18Yxywqqqk3KbPrUOL5ILO /DWTFQZufV1gMzR42eiqU3HcE7CZeZMc7FW0oAhAi5VD2J2KEbMZ9ZhURbTat5wAcmkj 8Nukwh7Q4lKL6w+eblGwONQeFtsekkiLtJrIvJMQxiEkfnUsS1A8rKR1XtYXRqhQjI3J 4p+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fVtxGVHL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb7si3795574edb.328.2020.10.30.03.14.11; Fri, 30 Oct 2020 03:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fVtxGVHL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbgJ3KKW (ORCPT + 99 others); Fri, 30 Oct 2020 06:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgJ3KKU (ORCPT ); Fri, 30 Oct 2020 06:10:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBA7C0613CF; Fri, 30 Oct 2020 03:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=u7YtPu1a20CnPHKzQzS9jt9YAYOEyPc1Wfcc8V34Xok=; b=fVtxGVHLRaB/i9LkESEDWY4fpY i1nZDijtIzs41S7n2+bLrB1hRAtmpSLn55vJmu3SVqpsd/cccJGwSqAMDzFIn6Cd65G4QVAiZMkhw oOC+dvwW+up7FAVrEgw+uu7d93QJDK6PzTBYn3DekeUNXXD2rooW09tj9dSBlsski5m2hjjh21wjd V0MfX3DJcVT+NHG4uwVzlLiaLsBsTP/zsTzvYyhS4/wWNEf3+gij5dQ2JKukorVbT5GdYMr8+Z2pG Fk09Ew+jE6c1rsXU2eVd9BsphbsVJseRUBAZyWw32IIUkNr+2uDujapgkD3FBUNVPDO+swYk3pToJ KvHniNtQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYRMF-0008Dy-CF; Fri, 30 Oct 2020 10:10:07 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E2E79307197; Fri, 30 Oct 2020 11:10:04 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D01612BEF0521; Fri, 30 Oct 2020 11:10:04 +0100 (CET) Date: Fri, 30 Oct 2020 11:10:04 +0100 From: Peter Zijlstra To: Mark Wielaard Cc: Namhyung Kim , Stephane Eranian , linux-toolchains@vger.kernel.org, Arnaldo Carvalho de Melo , linux-kernel , Ingo Molnar , Jiri Olsa , Ian Rogers , "Phillips, Kim" , Mark Rutland , Andi Kleen , Masami Hiramatsu Subject: Re: Additional debug info to aid cacheline analysis Message-ID: <20201030101004.GB2628@hirez.programming.kicks-ass.net> References: <20201006131703.GR2628@hirez.programming.kicks-ass.net> <20201008070231.GS2628@hirez.programming.kicks-ass.net> <50338de81b34031db8637337f08b89b588476211.camel@klomp.org> <20201030091649.GB3100@wildebeest.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201030091649.GB3100@wildebeest.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 30, 2020 at 10:16:49AM +0100, Mark Wielaard wrote: > Hi Namhyung, > > On Fri, Oct 30, 2020 at 02:26:19PM +0900, Namhyung Kim wrote: > > On Thu, Oct 8, 2020 at 6:38 PM Mark Wielaard wrote: > > > GCC using -fvar-tracking and -fvar-tracking-assignments is pretty good > > > at keeping track of where variables are held (in memory or registers) > > > when in the program, even through various optimizations. > > > > > > -fvar-tracking-assignments is the default with -g -O2. > > > Except for the upstream linux kernel code. Most distros enable it > > > again, but you do want to enable it by hand when building from the > > > upstream linux git repo. > > > > Please correct me if I'm wrong. This seems to track local variables. > > But I'm not sure it's enough for this purpose as we want to know > > types of any memory references (not directly from a variable). > > > > Let's say we have a variable like below: > > > > struct xxx a; > > > > a.b->c->d++; > > > > And we have a sample where 'd' is updated, then how can we know > > it's from the variable 'a'? Maybe we don't need to know it, but we > > should know it accesses the 'd' field in the struct 'c'. > > > > Probably we can analyze the asm code and figure out it's from 'a' > > and accessing 'd' at the moment. I'm curious if there's a way in > > the DWARF to help this kind of work. > > DWARF does have that information, but it stores it in a way that is > kind of opposite to how you want to access it. Given a variable and an > address, you can easily get the location where that variable is > stored. But if you want to map back from a given (memory) location and > address to the variable, that is more work. The principal idea in this thread doesn't care about the address of the variables. The idea was to get the data type and member information from the instruction. So in the above example: a.b->c->d++; what we'll end up with is something like: inc 8(%rax) Where %rax contains c, and the offset of d in c is 8. So what we want to (easily) find for that instruction is c::d. So given any instruction with a memop (either load or store) we want to find: type::member.