Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3836223ybf; Tue, 3 Mar 2020 13:52:49 -0800 (PST) X-Google-Smtp-Source: ADFU+vtb5tPMej4BsjKrYU8DLOavr+ccyEmfYZu8MlpBOzgEXSwZ2QZ63AZZf4+Khxrnsr/2l8Jy X-Received: by 2002:a05:6830:1e24:: with SMTP id t4mr7414otr.28.1583272369473; Tue, 03 Mar 2020 13:52:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583272369; cv=none; d=google.com; s=arc-20160816; b=V2Lc30k3ErogehbrZPU4HPbcDili09g2OLVX/IF1+RP3XTjBW8LNK8ZuxqVsHEJ7Tw 088zjgfksq31a4V8GfYZebKVWs8LkX9xfQmovcT3yP3nhJjPfsgpMzSVmzLFoZQqMxlu pSZ1jKEC9f59vjVjU68GkdYagZ2a9mNGIPjIkR/yQezSOL2IZWlGJtNsvhKxVYuPVS6D eMdKUfP3MmwVwcZZkgFkcWtu6CblrkJJxTqXZBBkD7+6wgF1g0AZ13LT6Usg+lFW8gn9 sZq2WFjETlOmVgiWtKKhcxHWjt3BKFTYwrA8g06ru+YuzwuQYFy8WZgtoCLNy80N8JAs IEWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Xky47bVPzg5Gl/0BGZMbvIE/TEeUaGB5mMzvY0QEU7Y=; b=j1PmROzSV3e3243ydefSUCJkIpHzY/lWw0+H1hYsPE4fr/uKDWUrWVzB0yyrgyZLmA jyZhFHcZ2FHoZXj0hC4q8PjrA+wgK3Z+r+P2EWiUQnlmrDZ882KFIulrHVBe8mvY3gdn kTXBS5e29DPobyIp+UqHenh3qI8tGZGQNfVmtIjqVk5TtWPwOkO90jEeq9P/ldBeW77l 5SYsELfghFTWjuv7qv5LdbO3MFrAddahUaBp8uAgAkvu+hQYNr5B748+RwFJBiVKG490 iyvDuzn58a/XUNFfnUNLPcuW8XC+EZskQqEbRsnYRRqfXQGA8MnPGSlvvT8Fh21OOpeg XnFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PTUUzihw; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si5896802otq.81.2020.03.03.13.52.37; Tue, 03 Mar 2020 13:52:49 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=PTUUzihw; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbgCCVvF (ORCPT + 99 others); Tue, 3 Mar 2020 16:51:05 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:38306 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgCCVvF (ORCPT ); Tue, 3 Mar 2020 16:51:05 -0500 Received: by mail-qv1-f67.google.com with SMTP id g16so63704qvz.5; Tue, 03 Mar 2020 13:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Xky47bVPzg5Gl/0BGZMbvIE/TEeUaGB5mMzvY0QEU7Y=; b=PTUUzihwL3qO9sZetyfxD9eyNpBmcTkVaplWkwbDcPZ5gHHqwiV8ulscpDLg7ANjwP d7od1VptGo3sJp5yCHoB5tkozmVffqFzrECuVWK9DrmQKKl3MAwg/Av/2FO7pZf46b3p P3jRWU7g9BYy2xyx0IgmEZuakR4S7a0NDMK1BODWsmpgfAQul84NUIhK+0IyA3zh09Ii VQP+UJeKVNQE80/iu8qNT8p+PFkSHvTxsE3lF/BY84Q1+LRzS00H52vhTmGf7kJ0JyIs xJUpVcfjiyuxO60g4XeG8sgMudoIzrAQ/bV3dS3YkSRzX1L7D2R3RJdwOsSkCQDr9GNQ t6rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Xky47bVPzg5Gl/0BGZMbvIE/TEeUaGB5mMzvY0QEU7Y=; b=mimhxlgq8x4RlG6NDtkI0s+yPRB4KygklM5FjkAhUVYpncJ/LUB9OU7SGTQcumKflB eeldJHfnHCuxnNJUZ+W/Lhsp2Tezur8y7cPbUvZp6zagt1AV3p/gOiXSPENk2MTpWAxi hnVCHp4WrRUSmhA6jef9OHQV4LUsKdg22/oSUrPtUdiI3Kteu1WF0/aqIW606IBojg09 mxxWHChF2wlXkBgt5eaqE7pww3zsxzKYv6e/J6IUaxexn46/iIPPgJVnpTSDeXXGTrD6 gxFKjGpamD8rQHwIOX/alyoCD4aHE5Vep0RMUcgDT37hJLDp5ZbKuDrDoaBQHG2VQSsb CrOg== X-Gm-Message-State: ANhLgQ0QgtnrY3Wj2sZ4ZLMTzJcI3gazh5aHp/URQi0pscsOQ9WfYq6u qomsp/sqQpJlOTzrJ7IwI2a/yUqiWMQqbDTaC40= X-Received: by 2002:ad4:4993:: with SMTP id t19mr5833155qvx.224.1583272264109; Tue, 03 Mar 2020 13:51:04 -0800 (PST) MIME-Version: 1.0 References: <202002242114.CBED7F1@keescook> <202003031301.083CF048C2@keescook> In-Reply-To: <202003031301.083CF048C2@keescook> From: Andrii Nakryiko Date: Tue, 3 Mar 2020 13:50:52 -0800 Message-ID: Subject: Re: [PATCH] kbuild: Remove debug info from kallsyms linking To: Kees Cook Cc: Masahiro Yamada , Michal Marek , Linux Kbuild mailing list , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 3, 2020 at 1:06 PM Kees Cook wrote: > > On Mon, Mar 02, 2020 at 10:55:04PM -0800, Andrii Nakryiko wrote: > > On Mon, Feb 24, 2020 at 9:17 PM Kees Cook wrote: > > > > > > When CONFIG_DEBUG_INFO is enabled, the two kallsyms linking steps spend > > > time collecting and writing the dwarf sections to the temporary output > > > files. kallsyms does not need this information, and leaving it off > > > halves their linking time. This is especially noticeable without > > > CONFIG_DEBUG_INFO_REDUCED. The BTF linking stage, however, does still > > > need those details. > > > > > > Refactor the BTF and kallsyms generation stages slightly for more > > > regularized temporary names. Skip debug during kallsyms links. > > > > > > For a full debug info build with BTF, my link time goes from 1m06s to > > > 0m54s, saving about 12 seconds, or 18%. > > > > > > Signed-off-by: Kees Cook > > > --- > > > > I've tested locally, seems to be generating BTF properly (I haven't > > timed anything, though). See nit below, but otherwise: > > > > Acked-by: Andrii Nakryiko > > Thanks! > > > > > > scripts/link-vmlinux.sh | 28 +++++++++++++++++++--------- > > > 1 file changed, 19 insertions(+), 9 deletions(-) > > > > > > > [...] > > > > > @@ -106,6 +114,8 @@ gen_btf() > > > { > > > local pahole_ver > > > local bin_arch > > > + local bin_format > > > + local bin_file > > > > > > if ! [ -x "$(command -v ${PAHOLE})" ]; then > > > echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available" > > > @@ -118,8 +128,9 @@ gen_btf() > > > return 1 > > > fi > > > > > > - info "BTF" ${2} > > > vmlinux_link ${1} > > > + > > > + info "BTF" ${2} > > > > Any reason to exclude linking from "BTF" step? It's still a part of > > BTF generation, so seems fair to have BTF encompass both vmlinux > > linking and BTF generation/deduplication? > > I'm not sure I'm following what you're saying here. If you're asking why > BTF linking is separate from the final vmlinux link, it's because of how > kallsyms is generated. Currently it's using a rather brute-force No, I meant that you moved `info "BTF"` to after `vmlinux_link` call, which will make it appear (from make output) as if BTF generation phase is shorter than it is. No big deal, was just wondering if it was done on purpose. > approach to figure out exactly where everything is going to be in the > final link, and for that it need to have both the BTF symbols present > and the kallysms symbols present. So, unfortunately, each needs to be a > separate step. I spent some time trying to merge BTF and kallsyms phase > 1, but I didn't find a viable solution. I'm *sure* there is a better way > to handle kallsyms, but I haven't had the time to really investigate it. > I think it would require some close coordination with linker behavior > changes... > > > > > > LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} > > > > > > # dump .BTF section into raw binary file to link with final vmlinux > > BTW, in looking at BTF generation, why is this cut up into three steps: > pahole, objcopy, objcopy... shouldn't pahole just gross an output method > to dump the final .o file? That would be MUCH nicer. Especially since > the first step ends up rewriting (?!) the original ELF. This is a lot of > needless IO... Just mostly historical reasons, that was the interface pahole already supported. I agree that it's a good idea to teach pahole to just emit a binary BTF section dump. > > -- > Kees Cook