Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4737112pxv; Tue, 29 Jun 2021 14:27:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBmQJkytQTnBQSt80Ei/qsBwFxjKtu+7N9tZluI1DcmEvitlvWOu1yAddxNzM7rxypfFz2 X-Received: by 2002:aa7:d955:: with SMTP id l21mr43076695eds.35.1625002066590; Tue, 29 Jun 2021 14:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625002066; cv=none; d=google.com; s=arc-20160816; b=nLw/F/CKWVy8SHyqde/RXBW9nCw8IAAEIFNF7wQltimY+igSDGQJfEVb9T7sLUXJ6I E0s/+b0CnLVHOz5VU6G9oUW3AWt2vA/EoyC6NFroiPC5IcJKV86Gs9bfbO4aCUsP7CF0 Pjx9Y2aXzJaTNHkT6qQTYAXemIP7rrm5hwnKESnVcD4WjOCffXRiRIgjIhNMQSMs8JBB CTg1StfF1EHU0HTjat/aUrz0hiMrFQFalVpGTzXwAyxgSdJ6CDOXlu+Buud9Vi2n8Utx k+xGquM9uAddBXeqVac2HcmlnMa3rgmsCSKRJtk8t0Wmeok9eVMOJGrpMz3QQHG2XN4n qsUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=at0ZjCEHdnjAbauppHO6g8ow1KqhQCXYe0Z+hJPVLYA=; b=SMe878godnD2NmKAt/exkmcJt6YqOR0lHpevJz31oCHhhsSF67MLI99szOR5S4TK0o vMYQ3XFYIx43Jvq7gaLQMNByIV/drGip5+lCsepLHdZJed3QBfH8TtIeksb8LdR5Nf4J fopO+SVkjKxpLHGEIYIgMBkV3cqY12T1NSiOnn1zNweBR+QHXkjbLbF6jTiKucYkQKkS XwLt2bK9musWUpquGXYNW+0MCWMziv5dUOlpyqT8580v+TKddX6cNqrO5HmDXpE+WAl5 Y6opjSHTfyxqlrxtgYV0SWOAm2Sdvo1eW9UyDsIOJNs5HZNjgCXcowXxG+NXxJzV/tmg r7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="AZ/qR6zw"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si19166622eda.200.2021.06.29.14.27.23; Tue, 29 Jun 2021 14:27:46 -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=@google.com header.s=20161025 header.b="AZ/qR6zw"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235642AbhF2VIZ (ORCPT + 99 others); Tue, 29 Jun 2021 17:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233238AbhF2VIW (ORCPT ); Tue, 29 Jun 2021 17:08:22 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C396BC061760 for ; Tue, 29 Jun 2021 14:05:53 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id a18so752034lfs.10 for ; Tue, 29 Jun 2021 14:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=at0ZjCEHdnjAbauppHO6g8ow1KqhQCXYe0Z+hJPVLYA=; b=AZ/qR6zwYLsWzcqtsPkz97l2LxlMlRiYeyeHths2LQs4XpqgJKhvlGo5NmHKYeMSyh p/TLMuZb7L3ptpeUeWhly//DSTtHdYoGyCKRB/4DChOs8FjYg2FrVE9ULy8fPv9WOmq8 fhlPI6M+h5fsD0DGhuOuealtNn9WKWY1l06OmfO1MMNp+BD3I3jQ6YNshOaU4GNfJxtS 2LF/uik/PnDPv1yTp5gmBun1yHVDhsAoZzxcUQMA1inVgVRqjLAbTeDXUdbR9o1qAx+n NV21rwFkLBwMbLgfv/wC4b02ljLpXQnLkddBaPGIWf6xvNTwCskS5uw3loLvzFjY0xP+ 6YlA== 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=at0ZjCEHdnjAbauppHO6g8ow1KqhQCXYe0Z+hJPVLYA=; b=BuuWBu2MAWVwtYTY1D+yc8IMoUqjrBxDyjZdKemVOU3ukL7jBVnNOpEuDbAHeCLnEi u4SmHeS5YiVgk3WmPka/c6hl1FRs314qbQBdtlj7rCSCmDk40GPjm17UdLwT+nUhZVzJ aO+el8E6H82pPUQnVPWH6v5B+LbOHjosfC20xtrz+swgPixkGBHDvRfEYYrxpXHrRcyK oqa5pAFgPucX5fMAXg0mKMAPZopqsfL3QP3fkCbuBAvH4ftZSTah36y2xkrRsXJZ301O t1tt73VR+yznEmY9mcgBdnTVhtNzKBLdfEZLKBkTTm/w5TbDcTJbYpngEYUIW+1BWnpA xvYw== X-Gm-Message-State: AOAM5331JqqHvCplRIUKv03i5WF+s6GxnKsYpQJtg4Cwuu57IVgx8/W2 Moih2Ntk9YVyu5h4J4XASzKoINtpgzXdzG/jRZLDyA== X-Received: by 2002:a05:6512:3e24:: with SMTP id i36mr23461870lfv.368.1625000751708; Tue, 29 Jun 2021 14:05:51 -0700 (PDT) MIME-Version: 1.0 References: <202106281231.E99B92BB13@keescook> <20210629131400.GA24514@C02TD0UTHF1T.local> In-Reply-To: <20210629131400.GA24514@C02TD0UTHF1T.local> From: Nick Desaulniers Date: Tue, 29 Jun 2021 14:05:40 -0700 Message-ID: Subject: Re: [GIT PULL] Clang feature updates for v5.14-rc1 To: Mark Rutland , Peter Zijlstra , Kees Cook Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Bill Wendling , Bill Wendling , Catalin Marinas , clang-built-linux@googlegroups.com, Fangrui Song , Heiko Carstens , Jarmo Tiitto , Lukas Bulwahn , Masahiro Yamada , Miguel Ojeda , Nathan Chancellor , Peter Oberparleiter , Sami Tolvanen , Will Deacon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 29, 2021 at 6:14 AM Mark Rutland wrote: > > Hi Kees, > > I thought the PGO stuff was on hold given Peter had open concerns, e.g. > > https://lore.kernel.org/r/20210614154639.GB68749@worktop.programming.kicks-ass.net > > ... and there didn't seem to be a strong conclusion to the contrary. Hi Mark, If I could rephrase Peter's concerns in my own words to see if I understood the intent correctly, I'd summarize the concerns as: 1. How does instrumentation act in regards to noinstr? https://lore.kernel.org/linux-doc/20210614153545.GA68749@worktop.programming.kicks-ass.net/ https://lore.kernel.org/lkml/YMcssV%2Fn5IBGv4f0@hirez.programming.kicks-ass.net/ 2. How much of this code can be reused with GCC? https://lore.kernel.org/linux-doc/20210614154639.GB68749@worktop.programming.kicks-ass.net/ 3. Can we avoid proliferation of compiler specific code in the kernel? https://lore.kernel.org/linux-doc/YMca2aa+t+3VrpN9@hirez.programming.kicks-ass.net/ --- Regarding point 1, I believe that was addressed by this series, which Peter Ack'ed, and is based on work I did in LLVM based on Peter's feedback, while collaborating with GCC developers on the semantics in regards to inlining. I notice you weren't explicitly cc'ed on that thread, that's my fault and I apologize. It wasn't intentional; once a cc list as recommended by get_maintainer.pl gets too long, I start to forget who was on previous threads and might be interested in updates. https://lore.kernel.org/lkml/YNGQV09E9xAvvppO@hirez.programming.kicks-ass.net/ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223 --- Regarding point 2, I believe I addressed that in my response. Similar to GCOV, we need the runtime hooks which are compiler specific in order to capture the profiling data. Exporting such data to userspace via sysfs can be easily shared though, as is done currently for GCOV. https://lore.kernel.org/linux-doc/CAKwvOd=aAo72j-iE2PNE5Os8BPc0y-Zs7ZoMzd21ck+QNeboBA@mail.gmail.com/ --- Regarding point 3, I agree. There's currently 2 big places in the kernel where we have very compiler specific code, IMO: 1. frame pointer based unwinding on 32b ARM (especially but not limited to THUMB). 2. GCOV This series does ask to add a third. At the same time, there are differences between compilers that are unlikely to converge without great need. Compiler IR is generally not interchangeable between compilers; the compiler runtimes (ie. symbols typically provided by libgcc_s or compiler-rt) are (generally) tightly coupled to their respective compilers. Since PGO relies on the respective compiler runtimes, we wind up with compiler specific runtime support for this feature. For a semi-freestanding environment like the Linux kernel, that means duplicating the ABI for these compiler runtime libraries, with additional code for kernel specific synchronization, memory management, and data retrieval (sysfs). Further, asking compiler vendors to break their existing ABIs with their compiler runtimes to support a shared interface for profiling data is also a hard sell. That's a major issue regarding frame pointer based unwinding on 32b ARM as well; existing unwinders must change to support the latest spec, yet not all code will be recompiled to match it as the same time the unwinder support is added or updated. Unless the compiler runtime was statically linked, then upgrading that shared object might break binaries when they are run next. I'm not saying it's impossible, but is it worth it? Do the compiler vendors agree? -- Thanks, ~Nick Desaulniers