Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp6860921imm; Sun, 20 May 2018 12:19:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoy3e0jJpNfDBQK3aGgAF12xTHw9r6QQOe2CU5vnG6HxYAFaUKGrJnIwUblGZGeKBP3eU5n X-Received: by 2002:a63:7c01:: with SMTP id x1-v6mr13529080pgc.286.1526843956078; Sun, 20 May 2018 12:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526843956; cv=none; d=google.com; s=arc-20160816; b=e5Hjj0gbYILQlHLQQ5CiEfJfnHCUxB144bWGT2Sp9D2fKtyNeOvzZB7V96ymVdCJN0 FLnnIHriskqwmCp8Z5LUTxd+svxfmWfjFkFpNacy22APBEQUACITGuSB3RsY2H7yZfoE RqXlKSDOIlhLoMjJCR6e+c5614G6l/YbMV9T3NLx8CfozsbD9X7/ZDBKE+shwNiHqFEO 0Fy3RMkeCMeBTfAxNtqrKr8cvlHT+v6H7OJT4y0lIPt9XtcM3InI/D6GIibwobrOL4z0 t/YX9wroqhYBu6g+ih2LSb2RlSMUpM2wTdWkRr11VU4BJ7eTSySoDIxaDrThH1rM3F1q L1Zw== 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:dkim-signature:arc-authentication-results; bh=afj7cwX/+5OQ8UrWhdPZ520EddR12mDuzj2/2SegCvI=; b=Q3tJz26LCxT2yLoIKoAWgwgVCHeMypjCJYXbpxLeJ66Y1in+d3VM+K+gv0kpXCr0gU 7UDmHkgJDUkAh2QhptU3EHrMQrEof2NULpWwLmxw7gSrKDO8u5Y1MLxKsUXiHGlXLslu VzTDIyU/zwm0wdsMXQ1sXjBw7rPkVW80r/wB7vUx598v6nclAJcPIXvMX9R27B3i3ORw Abgb++4F4oJWMQfRzz1DjUqY/d1Ay8gO3NCUOE9/GA31LRAvAeHrNicoP684lkmQSMsy vJJJyF5YsHL/0GBVo9UlF6n3NQfZhLOGteTzsOBNT9GZ2SBwXwe6XGFRqUS79ESsxJqj SGUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=MDpu9q+W; 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 d132-v6si9840309pgc.253.2018.05.20.12.19.00; Sun, 20 May 2018 12:19:16 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=MDpu9q+W; 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 S1751310AbeETTSt (ORCPT + 99 others); Sun, 20 May 2018 15:18:49 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:45575 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbeETTSs (ORCPT ); Sun, 20 May 2018 15:18:48 -0400 Received: by mail-pg0-f49.google.com with SMTP id w3-v6so5385417pgv.12 for ; Sun, 20 May 2018 12:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=afj7cwX/+5OQ8UrWhdPZ520EddR12mDuzj2/2SegCvI=; b=MDpu9q+WQep0GWWfoS31aarJQSYbMSLNh5yOFwdv/7hbP8rnjY1Trj7HkfAszmZoQT xbgGtwkyLACEMucJwW9jU+E3vzsFVVBpyG8vrmPImelMxLsUTEob+G7Z51xKSQRxm+K/ Gnja7unTxVWlP/qUL+HBKe+FYzhQiSVpaP000= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=afj7cwX/+5OQ8UrWhdPZ520EddR12mDuzj2/2SegCvI=; b=s4ZGXXdHd6WEWcdK3MZ+5Bv0nGz2aHF87zfuw/BL13DgxVNerWtQc2HpcBdZaJko0F EwfvzXFCDnqcV3HVLHCUbRoC9f6mgYeeDQrKgnh5VbzFg+kCiyqe8MHPoxbud3GgH3AW edn4iA9cp9quIrrlcq30LhM+n1bKk8odL5/snOFmkAbxNFaOz7ac9ACV7wSjWtckKjHZ 9hZiTBpfch80BmSxFdqOaKjDg2i39ND7c8mVsHN3cwgr+EhJk5OQFEVVZeZ2TRdRVZkc py4MoBiAdp2MA1z2DSh/bAROThiK9593+b3+K1zbZpikwYV0/rpwBYVgPW12XA3NBGrx EZkQ== X-Gm-Message-State: ALKqPwe9yIrByXndLp29bAt5C6XlIN0LO5suR9VoKesXNIrxjnsilR2p z2Ox+Xg2lyQ1akcRIUhGPXOFrg== X-Received: by 2002:a63:4384:: with SMTP id q126-v6mr13325443pga.294.1526843927979; Sun, 20 May 2018 12:18:47 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id z129-v6sm19482356pfb.108.2018.05.20.12.18.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 May 2018 12:18:47 -0700 (PDT) Date: Sun, 20 May 2018 12:18:46 -0700 From: Joel Fernandes To: Steven Rostedt Cc: "Paul E. McKenney" , byungchul.park@lge.com, mathieu.desnoyers@efficios.com, Josh Triplett , Lai Jiangshan , linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: Tasks RCU vs Preempt RCU Message-ID: <20180520191846.GA248075@joelaf.mtv.corp.google.com> References: <20180518183623.GA163151@joelaf.mtv.corp.google.com> <20180519022918.GV3803@linux.vnet.ibm.com> <20180519225905.GB134184@joelaf.mtv.corp.google.com> <20180520004938.GZ3803@linux.vnet.ibm.com> <20180520112843.57079857@grimm.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180520112843.57079857@grimm.local.home> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 20, 2018 at 11:28:43AM -0400, Steven Rostedt wrote: > > [ Steve interrupts his time off ] Hope you're enjoying your vacation :) > On Sat, 19 May 2018 17:49:38 -0700 > "Paul E. McKenney" wrote: > > > I suggested to Steven that the rcu_read_lock() and rcu_read_unlock() might > > be outside of the trampoline, but this turned out to be infeasible. Not > > that I remember why! ;-) > > Because the trampoline itself is what needs to be freed. The trampoline > is what mcount/fentry or an optimized kprobe jumps to. > > > : > nop > > [ enable function tracing ] > > : > call func_tramp --> set up stack > call function_tracer() > pop stack > ret > > ^^^^^ > This is the trampoline > > There's no way to know when a task will be on the trampoline or not. > The trampoline is allocated, and we need RCU_tasks to know when we can > free it. The only way to make a "wrapper" is to modify more of the code > text to do whatever before calling the trampoline, which is > impractical. > > The allocated trampolines were added as an optimization, where two > registered callback functions from ftrace that are attached to two > different functions don't call the same trampoline which would have to > do a loop and a hash lookup to know what callback to call per function. > If a callback is the only one attached to a specific function, then a > trampoline is allocated and will call that callback directly, keeping > the overhead down. Right, I saw your trampoline prototype tree. I understand how it works now, thanks. > There is no feasible way to know when a task is on a trampoline > without adding overhead that negates the speed up we receive by making > individual trampolines to begin with. Are you speaking of time overhead or space overhead, or both? Just thinking out loud and probably some food for thought.. The rcu_read_lock/unlock primitive are extrememly fast, so I don't personally think there's a time hit. Could we get around the trampoline code == data issue by say using a multi-stage trampoline like so? : call func_tramp --> (static trampoline) (dynamic trampoline) rcu_read_lock() -------> set up stack call function_tracer() pop stack rcu_read_unlock() <------ ret I know there's probably more to it than this, but conceptually atleast, it feels like all the RCU infrastructure is already there to handle preemption within a trampoline and it would be cool if the trampoline were as shown above for the dynamically allocated trampolines. Atleast I feel it will be faster than the pre-trampoline code that did the hash lookups / matching to call the right function callbacks, and could help eliminiate need for the RCU-tasks subsystem and its kthread then. If you still feel its nots worth it, then that's okay too and clearly the RCU-tasks has benefits such as a simpler trampoline implementation.. thanks! - Joel