Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1530765pxj; Sat, 12 Jun 2021 11:17:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/Ei0BoINVVAYEbCba4QG8N6q+tKmGzJzoD8xYV6lWZV4v3ORd80+hn17oyHE2F5jlyU9B X-Received: by 2002:a50:fd81:: with SMTP id o1mr9417212edt.382.1623521857483; Sat, 12 Jun 2021 11:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623521857; cv=none; d=google.com; s=arc-20160816; b=s3OjhXPgnfclE280/XFQ7NJ9INy/Is+9aiCIO3jgPGG5jNXiKK7SN0j9IUvnjNq5J0 Pz62y1K1tI1q6PNTvIB0DoxGHwA8EYXInLGhFDkgBNXqjla6LqyiPSTjxBe20Fqn/PmV yq+/890YGomThS1yqJJmdP2CyrTSDKxgtVIXCuII5i5qN0NI38C3en8W+XAeQnUpfNnn bhPQ88Bo03VNawTMV3pROuzo2lbCJDxr+dgn9nx0Fiy1sqqcAKdVPO49Iih1QDf70VE2 bOJpEbRUU433Y5b5HdT27XeK+AJ2cmcL3y3sTbsvCzyMXvI8fvanxchsFA6TuMoJerxV uKjA== 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=Ps52kPN0CGhy0RDCiacanmUQS9na8o/hOy6klGUnjsU=; b=0qgvM/ujGpNe+votX1ERSCdxcQj6IRt8JaR5C7s+T2TgBrDrd5szN/geoyP1RUpnKf Mhkb0xmLGxXiAOVE975HfoPUsD0uA+UUf/MOsGgccpJD79oJA/JvA/k1coUc3JC4l5Ay 9mtSXoy+9XEyeuT6hqT/UeN4h0v/yETH79ga+R4aej4CPyuHJV4EK5Ru1Qg5qyVrZH49 tSPSklp8YGMp6hp9wGQ8Vn3+lR2gMsdEVv87fcJwEWOwrrs9+OcurSTjb7L5C0cnb+49 98+ZbhLiyURSyPG0K8/zAUV62HFR/clgl0XgcSsT+S0DsWSqe1OstiefOiug0Q+JnRly ZWfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PRowg1ey; 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 b14si7990213ejq.311.2021.06.12.11.17.14; Sat, 12 Jun 2021 11:17:37 -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=PRowg1ey; 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 S231401AbhFLSRx (ORCPT + 99 others); Sat, 12 Jun 2021 14:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbhFLSRw (ORCPT ); Sat, 12 Jun 2021 14:17:52 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 151C0C061574; Sat, 12 Jun 2021 11:15:53 -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=Ps52kPN0CGhy0RDCiacanmUQS9na8o/hOy6klGUnjsU=; b=PRowg1ey+6JkXQysWPx6N6jWOY +WnQqeScl98svvQtwdxvd5Qv+pDiAYqelfE8zIYJJRAPRA/ExDjdM1OA/KrO7p7xEjfE3UhFqOvB7 +KcEFHW2ShBf8ryr4UsK6/rRdXjlZDxwXXnHCC9jmKOntXrmBEjHJX1O4yXCmRY+flSw89baz6+HB WCpxkPWJA9gcFmlp1Zf9Ky1h57irK1sZid4vp7SYmO0n7i1gxVWhP98NmFuSoCwk6DejhbjMMT7iB 9TJ3LtkKnbVz5NxnxFh1byacdVCaYqiK68RZdAVFFwvTYrep0sRhRqtg5HPFTOE8nfrcqfsx/K0lZ /xm0vysw==; 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.94 #2 (Red Hat Linux)) id 1ls8AR-003ujh-5x; Sat, 12 Jun 2021 18:15:36 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 70DCF30008D; Sat, 12 Jun 2021 20:15:33 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 598362BDFC479; Sat, 12 Jun 2021 20:15:33 +0200 (CEST) Date: Sat, 12 Jun 2021 20:15:33 +0200 From: Peter Zijlstra To: Bill Wendling Cc: Kees Cook , Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Fangrui Song , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure Message-ID: References: <20210111081821.3041587-1-morbo@google.com> <20210407211704.367039-1-morbo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 12, 2021 at 10:25:57AM -0700, Bill Wendling wrote: > On Sat, Jun 12, 2021 at 9:59 AM Peter Zijlstra wrote: > > > > On Wed, Apr 07, 2021 at 02:17:04PM -0700, Bill Wendling wrote: > > > From: Sami Tolvanen > > > > > > Enable the use of clang's Profile-Guided Optimization[1]. To generate a > > > profile, the kernel is instrumented with PGO counters, a representative > > > workload is run, and the raw profile data is collected from > > > /sys/kernel/debug/pgo/profraw. > > > > > > The raw profile data must be processed by clang's "llvm-profdata" tool > > > before it can be used during recompilation: > > > > > > $ cp /sys/kernel/debug/pgo/profraw vmlinux.profraw > > > $ llvm-profdata merge --output=vmlinux.profdata vmlinux.profraw > > > > > > Multiple raw profiles may be merged during this step. > > > > > > The data can now be used by the compiler: > > > > > > $ make LLVM=1 KCFLAGS=-fprofile-use=vmlinux.profdata ... > > > > > > This initial submission is restricted to x86, as that's the platform we > > > know works. This restriction can be lifted once other platforms have > > > been verified to work with PGO. > > > > *sigh*, and not a single x86 person on Cc, how nice :-/ > > > This tool is generic and, despite the fact that it's first enabled for > x86, it contains no x86-specific code. The reason we're restricting it > to x86 is because it's the platform we tested on. You're modifying a lot of x86 files, you don't think it's good to let us know? Worse, afaict this -fprofile-generate changes code generation, and we definitely want to know about that. > > > arch/x86/Kconfig | 1 + > > > arch/x86/boot/Makefile | 1 + > > > arch/x86/boot/compressed/Makefile | 1 + > > > arch/x86/crypto/Makefile | 4 + > > > arch/x86/entry/vdso/Makefile | 1 + > > > arch/x86/kernel/vmlinux.lds.S | 2 + > > > arch/x86/platform/efi/Makefile | 1 + > > > arch/x86/purgatory/Makefile | 1 + > > > arch/x86/realmode/rm/Makefile | 1 + > > > arch/x86/um/vdso/Makefile | 1 + > > > +CFLAGS_PGO_CLANG := -fprofile-generate > > > +export CFLAGS_PGO_CLANG > > And which of the many flags in noinstr disables this? > > > These flags aren't used with PGO. So there's no need to disable them. Supposedly -fprofile-generate adds instrumentation to the generated code. noinstr *MUST* disable that. If not, this is a complete non-starter for x86. > > Also, and I don't see this answered *anywhere*, why are you not using > > perf for this? Your link even mentions Sampling Profilers (and I happen > > to know there's been significant effort to make perf output work as > > input for the PGO passes of the various compilers). > > > Instruction-based (non-sampling) profiling gives us a better > context-sensitive profile, making PGO more impactful. It's also useful > for coverage whereas sampling profiles cannot. We've got KCOV and GCOV support already. Coverage is also not an argument mentioned anywhere else. Coverage can go pound sand, we really don't need a third means of getting that. Do you have actual numbers that back up the sampling vs instrumented argument? Having the instrumentation will affect performance which can scew the profile just the same. Also, sampling tends to capture the hot spots very well.