Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp954207imu; Tue, 11 Dec 2018 10:07:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/WAS+nUdvtS1MmiODMaG55nSUDFRdednbjyBZBctn0hHBI9b+wAloUzzp/78oAMUsawLINZ X-Received: by 2002:a17:902:9045:: with SMTP id w5mr16229114plz.32.1544551643720; Tue, 11 Dec 2018 10:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544551643; cv=none; d=google.com; s=arc-20160816; b=RDE4Sbj2+fkMKVp2bDnY+MEpcrgsSmgQs6dCbILD2nGNLG6uyP6QjQaVZ2WK5jXu0P LP9euV8ELP15myY19HyLxavLilJBaVybqLJ1RplBuYNfhwBOD8Zz3Qkm6XIB9sEb4fZp sW5HSIIIMFBZfRrQZ6S7IMQwGtsAhi6EwJVhQ/Hf3s5tS89WuGP0gCCoHNWeK6mUYj40 JLYaClqSyfqBdgRfjVqwRpPWfW2ZrFi/G0HYydKaTIGyjAFF+jRHEqsGCiEhRwHs+MNr IgeeUzIl2k2HtapIUZ9mbOSz2qT5oMDT5f9D8BP3XM5tPPQkkjEoYXcdrscKLUpiiqeS 5i3w== 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=3/1kbNMXDbnpNCIHVIvjcyh0fdH8BH/Q56mBfvOJvaI=; b=r03QYuzmXmclmKRkIdk8IU0936rPqSOp1YSRo3Y8l3qqGXfcYT/ymdfEoyL6MGz78S Txt3gxb883cUbG7Hw+5Aomf1L71duzYhkGOpmua15g7gPUUTZv6t3q4bnbOuDt0abU4K hIGmxYjLVfLxVhuhoWzXooFzQgPmovEhGRIaTLn5akVo05+nk0iBkydgGhwxPSRCAi2d wJXr+wXGOBPPi/g2/Yo+MZ4Is809z8VyYrOWfvdsyr2hLAF05LCODl2lAQyBbBGxa85f 4J9SimFkHFH004S+zudqCuFIpSITW6FfgodJSD1hf1pFLyDb6V6fS/kSip3WTPiksR+T QjnQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89si13768375pfr.242.2018.12.11.10.07.08; Tue, 11 Dec 2018 10:07:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbeLKSF1 (ORCPT + 99 others); Tue, 11 Dec 2018 13:05:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbeLKSF0 (ORCPT ); Tue, 11 Dec 2018 13:05:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D6663082204; Tue, 11 Dec 2018 18:05:26 +0000 (UTC) Received: from treble (ovpn-122-18.rdu2.redhat.com [10.10.122.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 645785DAA0; Tue, 11 Dec 2018 18:05:23 +0000 (UTC) Date: Tue, 11 Dec 2018 12:05:21 -0600 From: Josh Poimboeuf To: Edward Cree Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Abeni , Nadav Amit Subject: Re: [PATCH v2 0/4] Static calls Message-ID: <20181211180521.ljdvnnztjnvoijge@treble> References: <0e96ac37-d5c5-86b6-833c-0de01ba18f0d@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0e96ac37-d5c5-86b6-833c-0de01ba18f0d@solarflare.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 11 Dec 2018 18:05:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 07, 2018 at 04:06:32PM +0000, Edward Cree wrote: > Sorry if this has been pointed out before (it's a very long thread), but > in the out-of-line implementation, it appears that static_call_update() > never alters key->func. Am I right in thinking that this should be > fixed by adding 'WRITE_ONCE(key->func, func);' just after the call to > arch_static_call_transform() on line 159 of include/linux/static_call.h? Yes, you're right about both bugs in the out-of-line case: key->func needs to be written, and __static_call_update() needs to be called by static_call_update. I was so focused on getting the inline case working that I overlooked those. > Some background (why does key->func matter for the > CONFIG_HAVE_STATIC_CALL_OUTLINE case?): I am experimenting with > combining these static calls with the 'indirect call wrappers' notion > that Paolo Abeni has been working on [1], using runtime instrumentation > to determine a list of potential callees. (This allows us to cope with > cases where the callees are in modules, or where different workloads may > use different sets of callees for a given call site, neither of which is > handled by Paolo's approach). > The core of my design looks something like: > > static int dynamic_call_xyz(int (*func)(some_args), some_args) > { > if (func == dynamic_call_xyz_1.func) > return static_call(dynamic_call_xyz_1, some_args); > if (func == dynamic_call_xyz_2.func) > return static_call(dynamic_call_xyz_2, some_args); > return (*func)(some_args); > } > > albeit with a bunch of extra (and currently rather ugly) stuff to collect > the statistics needed to decide what to put in the static call keys, and > mechanisms (RCU in my current case) to ensure that the static call isn't > changed between checking its .func and actually calling it. > > -Ed > > PS: not on list, please keep me in CC. > > [1] https://lwn.net/Articles/773985/ Thanks, this sounds very interesting. Adding Nadav to CC, as he has been looking at a different approach to solving the same problem: https://lkml.kernel.org/r/20181018005420.82993-1-namit@vmware.com -- Josh