Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp449412yba; Fri, 26 Apr 2019 03:02:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzJKPbxQZRtLb8fM/cIqz1yXOwGbnRRM4iLQJjNelnoKEUcnZjrPkIB5AR1UeTr92aP8XV X-Received: by 2002:a17:902:8d97:: with SMTP id v23mr44718450plo.298.1556272937333; Fri, 26 Apr 2019 03:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556272937; cv=none; d=google.com; s=arc-20160816; b=bjedTB7mcKs9+No/45f8QtsO5aqu/VdmUb4ng8s4E5YlrCBjQ0SjqyOKgzKY4NP26U m8z8trZHGzyAZyjMNSMb1DiecsKneco3kutYLilLP3YAlCF3iFCAD3Fk73ZfdDtYq39D yDjC8XvH95AjaylWNKU5b54YY23IZd4gdOr9syZqO7aFzwBOWCBqB6Ygldfv0GxGtIIT nOT2U3kNxTMN7ZMaYXlmndsO5aliunoF4yN5mtSWKcT8M4Bq6uScUs9GrmawkDoyJt6B Q6tIoPDn9WBPQ/lPfajhAqmxFXW2YrgrjmUb/DTlB2WLSR/G+qRPW0qZOdR/K/aXWQ4K mMbQ== 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; bh=TwNf3+wPQCnf2muW6caoidV0iNFuGGBK+oii7LdChH4=; b=Jh0GEkyr6qhr571i3lxgGXfEBuTALShrDL5Zu/531xhCAu/jBWAHsW388xX/SEpSEH ymmhaBEWgI0zIXapO3mYssnXC5xoaoEgLqAbHsC49wqCsH4ecBqwMUtjvdfZ1EmtKggm f0O2h4JBiQLa1dneVi0+RfPhZ2LrNDlj4LazUz46OQi94QLqFyansgoRxABczSMdZdNK SPtiMZMbzryo+uI5cUBxz3sPzNkG+VFWHEUd50WKpCVK9W1+E8y0GPJItwP4jYW8PP/S 6TMiRW4NwyshG9FrcQKoebZfvB4wRMJPEZo1QcjiQaT3ioTvXHeYeyBP/mC9oPBgjdzR ux3g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si25758065pfd.105.2019.04.26.03.02.00; Fri, 26 Apr 2019 03:02:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726474AbfDZKBC (ORCPT + 99 others); Fri, 26 Apr 2019 06:01:02 -0400 Received: from nikam.ms.mff.cuni.cz ([195.113.20.16]:35224 "EHLO nikam.ms.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbfDZKBB (ORCPT ); Fri, 26 Apr 2019 06:01:01 -0400 X-Greylist: delayed 335 seconds by postgrey-1.27 at vger.kernel.org; Fri, 26 Apr 2019 06:01:00 EDT Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id AD6682804B1; Fri, 26 Apr 2019 11:55:22 +0200 (CEST) Date: Fri, 26 Apr 2019 11:55:22 +0200 From: Jan Hubicka To: Miroslav Benes Cc: Josh Poimboeuf , live-patching@vger.kernel.org, Peter Zijlstra , Mark Rutland , linux-kernel@vger.kernel.org, mliska@suse.cz Subject: Re: Livepatch vs LTO Message-ID: <20190426095522.wyymezuqzkdck6fm@kam.mff.cuni.cz> References: <20190425152628.ogk4woi3omeocwly@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > [ adding CCs ] > > On Thu, 25 Apr 2019, Josh Poimboeuf wrote: > > > Hi all, > > > > On IRC, Peter expressed some concern about -flive-patching, specifically > > that the flag isn't compatible with LTO. > > > > The upstream kernel currently doesn't support LTO, but Android is using > > it with LLVM: > > > > https://source.android.com/devices/tech/debug/kcfi > > > > And there seems to be progress being made in that direction for > > upstream. > > > > Live patching has at least the following issues with LTO: > > > > - For source-based patch generation (klp-convert and friends), the GCC > > manual says that -flive-patching is incompatible with LTO. Does > > anybody know if that's a hard incompatibility, or can it be fixed? > > Honza could know more. It was either that LTO by itself complicates > things for live patching, or that LTO adds more optimizations which are > potentially unsafe. The original patch, by Oracle, was disabling inlining of everyting else than static functions and later it was strenghtened to disable all the other inter-procedural optimization as well. With LTO this does not make that much of sense because, based on linker resolution file, GCC will turn non-static functions to static when it knows that non-LTO code will not bind to it. To make this work we would need to track what was static originally and what not. But doing so would still prevent most of LTO transforms because it is all about cross-module inlining and propagation and that all needs to be forbidden for this mode of live patching to make sense. So basically -flto -flive-patching=inline-only-static would be pretty much equivalent of -ffunction-sections -fdata-section and enabling removal of dead sections in the linker. Just slower at compile time. The clone tracking logic is more compatible with LTO becuase it does not prevent most optimizations. I guess it could work and we probably want to add support for it incrementally. > > > Also, what about the performance implications of this flag with LTO? > > Might they become more pronounced? > > It could. Theoretically. The scope for optimizations would be much > broader. > > > Also I wonder if -fdump-ipa-clones works with LTO? > > It should. According to Martin, there is (almost) nothing special about > LTO. Optimization infrastructure is the same, only the scope is not > limited to one translation unit. Yes, you will likely get considerably more clones and inline copies to care about while doing the live patch. I would be interested to know how well it work in practice. No idea if that would be a problem. Honza