Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp769343imu; Fri, 9 Nov 2018 05:54:47 -0800 (PST) X-Google-Smtp-Source: AJdET5e4lSTMHlteJA8XdY+FpOOIWkk1IO/FzROigL2cMzS6MiQKYQFxC8gd5qUaY4LB8/adq7Yy X-Received: by 2002:a17:902:8ec1:: with SMTP id x1-v6mr9027455plo.130.1541771687086; Fri, 09 Nov 2018 05:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541771687; cv=none; d=google.com; s=arc-20160816; b=vam88bSSNiq4POR9T1JUi9aLTKQv4QtbQUZMl//CmevdEAthnyw2c9QcMltEBbiebQ XA8OuJL5okBpvAf7RaPZnRMpxnGvCR1EOw1qy9wOAEq5iYgUHh0YQ44YG6u20C55VEwe RxtxTrFzarfcQAJw+AALb0bq/aNrHsSTPz9KXAyAmf/iHbo7Qt3fxIoZkRz8h/uPvAgi tAAC+rUds4+I+wQ0rcg9cK/5oMa4bsb9zO666z84b6+tVwDMqNm3cNXVGG1/i90QQ1FW leUw/H7NzQL3Q4Og3bUYTTa+Ys0EUwrluyc3MGnBxoE7SlITu4XejOk+Gdl6lF6PZvuN ZLxg== 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 :references:in-reply-to:mime-version:dkim-signature; bh=XCG/V04jlegloMSWsjMPIYWmvNahieLfPQIduirITOQ=; b=LZ0rWAlYKQCJviHTJNARj+kV8bfJ9LWpPlilGMbUmwOTx2ZPMsIh4wan2OXx/lK84b ZcV7J9Yu20e/+5EBMiOF5iZb7HHYkX7mns2ixouF+hdppZg3+LL4nFWjEKnsBjITOZz5 RrfkHqM9m4RLonukMWnpX6+IVS4Gn9ASlWiFKN75e+ixTEnSS2ut6rXTiI33wzuxHIHN i7/MdXArCrWSAoYgRqfmtR1Pn3PVFA/KMOLnpyn5+jU3rzpGIhEykSNS2ftogMxwmJO3 Hvs6B26LeY3GmoCOwfjVqETGmJ+XrBWfV5WV2X7cvnScd1kdiOLnJ2/WSPAvefV2wUtM PnvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J92Nkn/7"; 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 y10-v6si7700732plt.145.2018.11.09.05.53.59; Fri, 09 Nov 2018 05:54:47 -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=@linaro.org header.s=google header.b="J92Nkn/7"; 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 S1728024AbeKIXbM (ORCPT + 99 others); Fri, 9 Nov 2018 18:31:12 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:43851 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbeKIXbM (ORCPT ); Fri, 9 Nov 2018 18:31:12 -0500 Received: by mail-io1-f67.google.com with SMTP id t81-v6so1265766iod.10 for ; Fri, 09 Nov 2018 05:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XCG/V04jlegloMSWsjMPIYWmvNahieLfPQIduirITOQ=; b=J92Nkn/7mFYY7NnCBUAv+ehrb1wild+Cj7uEP9ILYzZubTMZtab0pgFoN8yAkYJvoU dljxioQr6w+VTC0BJONTFYlBBg44vjUslUOvnzwhB/9BHPNoqeqpHMI7xk2CoMktW4BH BVMZPhcZrpdtvFp3ZKK+tsVAEBi8X4KeAXalM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XCG/V04jlegloMSWsjMPIYWmvNahieLfPQIduirITOQ=; b=B1ZsKSGhPAEf1V+PqotFOU1kGFKaiWgClONwQXoLBlkyE7fNvnp5cNC5+H8HYhHF1z hJN0VRlB0rqQcBVeOU24MlYbtAkkaN9YVohje49BGBmaNqtDdw3pn41VqTzIg22zMhJH tM7LtlFEOQK/v/WmjODhIyDo8CjG4x59HtLTJhbZsBwbc0fX83TOUC5fkPVAA86Pt1Bu DxJfWj/kROWN0nBwg1r4c+bRxY1J/vGnEXQCprGCcnODEX9BTXTNaKIFZFkWXcSzvciN Ik+c5hM5pkX4l+OOq1/wP0W76ZJHVUn9u8zVnavKQey3QFkGOkQ+/i5u4G14h2cAsMr/ jX3w== X-Gm-Message-State: AGRZ1gJsU472C89x7SL1TdXsoGKDysKVuQggXpt6Is94TUjZe2hFPBHv c17Ia7eoW7klXVYQiDx3/ot5lhZoDyUw63CJ1NWMijp6Uc8= X-Received: by 2002:a6b:37c2:: with SMTP id e185-v6mr7094932ioa.173.1541771428539; Fri, 09 Nov 2018 05:50:28 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a6b:4f16:0:0:0:0:0 with HTTP; Fri, 9 Nov 2018 05:50:27 -0800 (PST) In-Reply-To: <20181109072811.GB86700@gmail.com> References: <20181109072811.GB86700@gmail.com> From: Ard Biesheuvel Date: Fri, 9 Nov 2018 14:50:27 +0100 Message-ID: Subject: Re: [PATCH RFC 0/3] Static calls To: Ingo Molnar Cc: Josh Poimboeuf , Linux Kernel Mailing List , "the arch/x86 maintainers" , Andy Lutomirski , Steven Rostedt , Peter Zijlstra , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov 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 9 November 2018 at 08:28, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > >> These patches are related to two similar patch sets from Ard and Steve: >> >> - https://lkml.kernel.org/r/20181005081333.15018-1-ard.biesheuvel@linaro.org >> - https://lkml.kernel.org/r/20181006015110.653946300@goodmis.org >> >> The code is also heavily inspired by the jump label code, as some of the >> concepts are very similar. >> >> There are three separate implementations, depending on what the arch >> supports: >> >> 1) CONFIG_HAVE_STATIC_CALL_OPTIMIZED: patched call sites - requires >> objtool and a small amount of arch code >> >> 2) CONFIG_HAVE_STATIC_CALL_UNOPTIMIZED: patched trampolines - requires >> a small amount of arch code >> >> 3) If no arch support, fall back to regular function pointers >> >> >> TODO: >> >> - I'm not sure about the objtool approach. Objtool is (currently) >> x86-64 only, which means we have to use the "unoptimized" version >> everywhere else. I may experiment with a GCC plugin instead. > > I'd prefer the objtool approach. It's a pretty reliable first-principles > approach while GCC plugin would have to be replicated for Clang and any > other compilers, etc. > I implemented the GCC plugin approach here for arm64 https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=static-calls That implements both the unoptimized and the optimized versions. I do take your point about GCC and other compilers, but on arm64 we don't have a lot of choice. As far as I can tell, the GCC plugin is generic (i.e., it does not rely on any ARM specific passes, but obviously, this requires a *lot* of testing and validation to be taken seriously. >> - Does this feature have much value without retpolines? If not, should >> we make it depend on retpolines somehow? > > Paravirt patching, as you mention in your later reply? > >> - Find some actual users of the interfaces (tracepoints? crypto?) > > I'd be very happy with a demonstrated paravirt optimization already - > i.e. seeing the before/after effect on the vmlinux with an x86 distro > config. > > All major Linux distributions enable CONFIG_PARAVIRT=y and > CONFIG_PARAVIRT_XXL=y on x86 at the moment, so optimizing it away as much > as possible in the 99.999% cases where it's not used is a primary > concern. > > All other usecases are bonus, but it would certainly be interesting to > investigate the impact of using these APIs for tracing: that too is a > feature enabled everywhere but utilized only by a small fraction of Linux > users - so literally every single cycle or instruction saved or hot-path > shortened is a major win. > > Thanks, > > Ingo