Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4043025pxb; Tue, 17 Nov 2020 09:47:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzW3AFs/ihdIAI1V599JvLzdNUteDU3GxNj0x/z5+/6yU9xNYt+vCsY1C9ZqzXiDl+CL2vJ X-Received: by 2002:a17:906:cc8c:: with SMTP id oq12mr21701159ejb.177.1605635252000; Tue, 17 Nov 2020 09:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605635251; cv=none; d=google.com; s=arc-20160816; b=gGHYjGqHN9M6AKtDfr2TglyDX9pqW8NwrMf3UOKBf3+YcOroKDkSDeX9YTI90MMF+O m6TVPfwhY/tmTuW9gGXCFgOdXEZeGpZgT6Lc8NnU3DSM+P0FRs47BgtijnH2kIT4oDsm MPWcQxlKKH5VMMMWA9s8Zv4QBo0wOLu1BtIlpKPqWENoxGF6/HUU/M8yUScKAmoKqu5T i4Q+lwbnq1pkbDIofCwNp628uTcjWXKFPTgVZz7U/kmpUPva/o+CLYDzdWEjknXmdim6 DwQA1ldiTUk/TJpT3OXTtKH5APL5TpL9C1WjFb6lbzMZam68sc1QQ41H66M9nn6KclmZ KZxg== 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=2GSwm4P6ju37kNY0Px5Z4jjmjc0+Rh8WZjnb09bmRkk=; b=d73LtH6P9yrYeU4HWCN6RhkAJ5/u7SW0KJ2ODpNddb3f5ONJCktWqtI/6yu0zS0qkO VlRibfR9aoXsYa0gniNvXazmNN+LMquI8IPZDa0xXGSIJs01UYKh4b/hIg0neqUqWWVY DQ5O4yfmqPjV1s3cxI17dI1SDEkRXOQDCXO5zTM1vsc+/NBicbXekSr605wzXbckY6fU 1/ycTVOppT67G/WFtyFB8PTboJE+JX4eGedkziKTOvxH2qcjs7sdV9mphv4cYuxpFprb NUhxpB+Mg/fLDAFkAAeV+YasmEUVDOsgbycvAw5p36qm5Es2utsl3YiDpR478ofIlxSg RW0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BDNZnNxq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qh17si14700681ejb.333.2020.11.17.09.47.08; Tue, 17 Nov 2020 09:47:31 -0800 (PST) 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=@kernel.org header.s=default header.b=BDNZnNxq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729131AbgKQRnh (ORCPT + 99 others); Tue, 17 Nov 2020 12:43:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:42622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbgKQRng (ORCPT ); Tue, 17 Nov 2020 12:43:36 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7D0EA2083E; Tue, 17 Nov 2020 17:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605635015; bh=E6HWsnYm3SnHpM8JEcIpgapNiVSLIULbsQPmNXW/KLo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BDNZnNxq+YMtlA85kbVAssgE8qQsvSBqMBjwl6QLj/h0mhkiGaM2bLxvu1IWRJRdl auPt3EGYltgCb5T36XHnAffSpPgsUE1zsHQChZxR6G0vHyCjB3FtZ5segwBPpDkZAf 3Uq7CED3K3kxkv+uELx34qjsn/EecrMaPCHXe8go= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 603DE40E29; Tue, 17 Nov 2020 14:43:33 -0300 (-03) Date: Tue, 17 Nov 2020 14:43:33 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Jiri Olsa , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 13/24] perf tools: Allow mmap2 event to synthesize kernel image Message-ID: <20201117174333.GU614220@kernel.org> References: <20201117110053.1303113-1-jolsa@kernel.org> <20201117110053.1303113-14-jolsa@kernel.org> <20201117124437.GO614220@kernel.org> <20201117151651.GD1216482@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117151651.GD1216482@krava> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Nov 17, 2020 at 04:16:51PM +0100, Jiri Olsa escreveu: > On Tue, Nov 17, 2020 at 09:44:37AM -0300, Arnaldo Carvalho de Melo wrote: > > Em Tue, Nov 17, 2020 at 12:00:42PM +0100, Jiri Olsa escreveu: > > > Allow mmap2 event to synthesize kernel image, > > > so we can synthesize kernel build id data in > > > following changes. > > > > > > It's enabled by new symbol_conf.buildid_mmap2 > > > bool, which will be switched in following > > > changes. > > > > Why make this an option? MMAP2 goes back years: > > > > 13d7a2410fa637f45 (Stephane Eranian 2013-08-21 12:10:24 +0200 904) * The MMAP2 records are an augmented version of MMAP, they add > > 13d7a2410fa637f45 (Stephane Eranian 2013-08-21 12:10:24 +0200 905) * maj, min, ino numbers to be used to uniquely identify each mapping > > > > Also we unconditionally generate MMAP2 events if the kernel supports it, > > from evsel__config(): > > > > attr->mmap = track; > > attr->mmap2 = track && !perf_missing_features.mmap2; > > > > So perhaps we should reuse that logic? I.e. use mmap2 if the kernel > > supports it? > > mmap2 itself is not a problem, the problem is the new > bit (PERF_RECORD_MISC_MMAP_BUILD_ID) that says there's > build id in mmap2.. older perf tool won't understand > that and report will crash Is this theoretical or have you experienced it? Would be good to tweak the perf.data reader code to not crash on unknown bits like that :-\ But by looking at machine__process_mmap2_event() I couldn't imagine how that would crash. It would get bogus maj, min, ino, ino_generation, but probably that wouldn't make it crash. - Arnaldo int machine__process_mmap2_event(struct machine *machine, union perf_event *event, struct perf_sample *sample) { struct thread *thread; struct map *map; struct dso_id dso_id = { .maj = event->mmap2.maj, .min = event->mmap2.min, .ino = event->mmap2.ino, .ino_generation = event->mmap2.ino_generation, }; int ret = 0; if (dump_trace) perf_event__fprintf_mmap2(event, stdout); if (sample->cpumode == PERF_RECORD_MISC_GUEST_KERNEL || sample->cpumode == PERF_RECORD_MISC_KERNEL) { ret = machine__process_kernel_mmap_event(machine, event); if (ret < 0) goto out_problem; return 0; } thread = machine__findnew_thread(machine, event->mmap2.pid, event->mmap2.tid); if (thread == NULL) goto out_problem; map = map__new(machine, event->mmap2.start, event->mmap2.len, event->mmap2.pgoff, &dso_id, event->mmap2.prot, event->mmap2.flags, event->mmap2.filename, thread); if (map == NULL) goto out_problem_map; ret = thread__insert_map(thread, map); if (ret) goto out_problem_insert; thread__put(thread); map__put(map); return 0; out_problem_insert: map__put(map); out_problem_map: thread__put(thread); out_problem: dump_printf("problem processing PERF_RECORD_MMAP2, skipping event.\n"); return 0; }