Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp345518ybl; Thu, 15 Aug 2019 18:46:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuVmh+yURAgB/f4KEkFH7MA4YIDB2P+/DFoLSNx/EnWgiMDbyrXaTaooaTv78sDwGpC9ef X-Received: by 2002:a62:187:: with SMTP id 129mr8442564pfb.128.1565920002938; Thu, 15 Aug 2019 18:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565920002; cv=none; d=google.com; s=arc-20160816; b=0C5DPUC4OIloyKj9xwortuAkIawokPkbAujhsonaJfnXGBJiYQ0n65sFD6ozPmcPez eHZljQJdDdHEzQIw+FciCvcxQ5OTDeQAY9znoLuKi2Wk3Dw2D6Kj2qtEevMxXDBd0qGx CtLx/pgUJ9YDL3gd9lt2VV2sEa0Gk+4SQmIuIzKJo9UGKrRwXzaqtfvH9Ey5xa6PxzEh c1UsvrHUu5LuMXJiM08aaKqat5wKQ6+pcERopkMCA6847Uhar8UYWz0sl8X+SlRoKZVQ b7UvDxo1pZ1EHJWaZO1Ytj5g3051ggLYOi5qxuKQh2ousQl2PYHqu5NsHHhZhIljPhiI KubQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1/p96Axpw0rHsxKvgAnkX2TPQwGbqpRMoy2NJLiILjI=; b=Xmvwe2rBkTnV3JpyfW0WzYjJkNHxfu0++k9VJv+KPkKm5gbPTXm6OTS5ayoXkbseeY 30jy3RnR1SwiAgvdRJuL0gcY6a6ULkyBB0BcGm9THP86gGvo4nhdyf0JEJJ3W8ZDP+md 6KGOl9N22VG6ubn8sOIPhrXRVEroh8qHv8jG/NDIJU0eLV/x7u9zwSjLeoDCg7Tg8Grl 2maDOjkR6XkuZZUT4EwVH4J0awxny127SNV7fEm3ssnRxFFzmGTc/DKTLNUOcd2aK3Gh qrv5nQIKtJzGr/9wkPpvSat9noF/N08h6i1nNTQcnG4J0kVJFuNTqoFPV62scGjGvgp/ abwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gg18FaJL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si3176706pfh.185.2019.08.15.18.46.26; Thu, 15 Aug 2019 18:46:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gg18FaJL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfHPBpw (ORCPT + 99 others); Thu, 15 Aug 2019 21:45:52 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36116 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725983AbfHPBpu (ORCPT ); Thu, 15 Aug 2019 21:45:50 -0400 Received: by mail-pf1-f193.google.com with SMTP id w2so2274351pfi.3 for ; Thu, 15 Aug 2019 18:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1/p96Axpw0rHsxKvgAnkX2TPQwGbqpRMoy2NJLiILjI=; b=Gg18FaJL00NzcRt4W/j4JgqHWrONHfBYA9r8BcsQbvriweFSoDnIzZ9HTDaq3j1sN3 mdQwP3as5jSogC4XkurlHBh3eFk+CIQlTMe2tXGsAtu+zpX3zw4gsVoYRQ9/GiQBslKN pl94B3b02xKzLyxX6FbcVfZ3BYOgY0eGyvUWyymYGxVzO2r7B7J/7xWHlzFUk6V5s2mf a5NQsBxgsivAID73l7snH0MFpHauCIYNvGVPxFUu+W7hdKn/1zw0NoK3c3YuONnjhUbd UgbFN5XGhNPK0u7BI0IRLwlpz4TxLie/tJ5zsdUiTcZIiNdHxRPhwU1YR10xky4HxKBJ cqzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1/p96Axpw0rHsxKvgAnkX2TPQwGbqpRMoy2NJLiILjI=; b=rZ+qxOr1VUE74SDsxw/AOBW/HZweIwXlOr3vykD/P26F77gMOPgVUrbVh/2tlJwBLV G7yaQ7UcENmm+Vi3yUveaUEVl7FXCGB+iJVlkvkW+xW7pOCCYsdZm8We1g9v5JW2WRmD VVXKDDTG1g7wHM6y0UEJg4kvpRdC8Cxvl0zoywl2u7Sw5VmD0WrdDidb4hGEjosiUpjJ 6qSk142uvQPeidxljgzc4Honld3iae55WbLMPxq8jaFpNGWxzziMG033OwRXtHL3CIGh VPTofI/R14hW5V7bn1nAl1swiGz9b6hlz4cmQptjHQ0xdnnyOvP7DfLDq158bJ0+zEDO l4SQ== X-Gm-Message-State: APjAAAXegSfQEL/PMufLshveqCHg61ZHPIFz0PEqPwwcTIWnas2sS3s1 CARVOPPM04JNjSB6mh1T+iC7tw== X-Received: by 2002:a65:430a:: with SMTP id j10mr5932866pgq.374.1565919949052; Thu, 15 Aug 2019 18:45:49 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li456-16.members.linode.com. [50.116.10.16]) by smtp.gmail.com with ESMTPSA id v15sm3255539pfn.69.2019.08.15.18.45.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Aug 2019 18:45:48 -0700 (PDT) Date: Fri, 16 Aug 2019 09:45:41 +0800 From: Leo Yan To: Adrian Hunter Cc: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, Mathieu Poirier , Peter Zijlstra , Suzuki Poulouse , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5] perf machine: arm/arm64: Improve completeness for kernel address space Message-ID: <20190816014541.GA17960@leoy-ThinkPad-X240s> References: <20190815082521.16885-1-leo.yan@linaro.org> <20190815113242.GA28881@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Adrian, On Thu, Aug 15, 2019 at 02:45:57PM +0300, Adrian Hunter wrote: [...] > >> How come you cannot use kallsyms to get the information? > > > > Thanks for pointing out this. Sorry I skipped your comment "I don't > > know how you intend to calculate ARM_PRE_START_SIZE" when you reviewed > > the patch v3, I should use that chance to elaborate the detailed idea > > and so can get more feedback/guidance before procceed. > > > > Actually, I have considered to use kallsyms when worked on the previous > > patch set. > > > > As mentioned in patch set v4's cover letter, I tried to implement > > machine__create_extra_kernel_maps() for arm/arm64, the purpose is to > > parse kallsyms so can find more kernel maps and thus also can fixup > > the kernel start address. But I found the 'perf script' tool directly > > calls machine__get_kernel_start() instead of running into the flow for > > machine__create_extra_kernel_maps(); > > Doesn't it just need to loop through each kernel map to find the lowest > start address? Based on your suggestion, I worked out below change and verified it can work well on arm64 for fixing up start address; please let me know if the change works for you? diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f6ee7fbad3e4..51d78313dca1 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2671,9 +2671,26 @@ int machine__nr_cpus_avail(struct machine *machine) return machine ? perf_env__nr_cpus_avail(machine->env) : 0; } +static int machine__fixup_kernel_start(void *arg, + const char *name __maybe_unused, + char type, + u64 start) +{ + struct machine *machine = arg; + + type = toupper(type); + + /* Fixup for text, weak, data and bss sections. */ + if (type == 'T' || type == 'W' || type == 'D' || type == 'B') + machine->kernel_start = min(machine->kernel_start, start); + + return 0; +} + int machine__get_kernel_start(struct machine *machine) { struct map *map = machine__kernel_map(machine); + char filename[PATH_MAX]; int err = 0; /* @@ -2687,6 +2704,7 @@ int machine__get_kernel_start(struct machine *machine) machine->kernel_start = 1ULL << 63; if (map) { err = map__load(map); /* * On x86_64, PTI entry trampolines are less than the * start of kernel text, but still above 2^63. So leave @@ -2695,6 +2713,16 @@ int machine__get_kernel_start(struct machine *machine) if (!err && !machine__is(machine, "x86_64")) machine->kernel_start = map->start; } + + machine__get_kallsyms_filename(machine, filename, PATH_MAX); + + if (symbol__restricted_filename(filename, "/proc/kallsyms")) + goto out; + + if (kallsyms__parse(filename, machine, machine__fixup_kernel_start)) + pr_warning("Fail to fixup kernel start address. skipping...\n"); + +out: return err; } Thanks, Leo Yan