Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3058920ybh; Mon, 16 Mar 2020 15:04:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuCsU7CkrCNNqSiWGDNa7Jqi87QiNiBsVQz0akQLPnCkS2sKUCVAYilpy0OF3RPLzIiWuLv X-Received: by 2002:a9d:708a:: with SMTP id l10mr1235515otj.152.1584396275384; Mon, 16 Mar 2020 15:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584396275; cv=none; d=google.com; s=arc-20160816; b=PgoqucECSgUGmB0QuNsCkLO592T4O262KrH66x4eXYePRBcx4x1G0eCXo+rVotw5Nw S8+Q5p510kdMuwvtqW21B8qkKhk1YiZwLABeokjARAsiujpExtnI21K4p3wy5pDQpZbQ Kie78to9kzX4tJ9p3ha/ueSJJKu5IVKXshBKBumKp8eu8KP8dunqsDxUw11ifLd2OvZt 7hQaDpfBf5O0Ju1409DeJ6fiN1aW5ah/oW9tNDXrOrYOq4o4kIATmXkV+Iq3OdTx17PL e4ia+R3NNlWxlO0uoby5+K7mnTdP8V52UNyW34G2NTUGEY1XOoT5yv7ZWRYm6wlJM7qF 5yfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=vqQSuL0VJp84qtydoWYJqMrkEhMTaiMOsEMVEZtWMBA=; b=hHcHOSBijwTixmf9uVwshoS635BOkHmslpSFPbl2MSyPeZvFn73E2hgTDLWy5k4Wcc /czYMpKhSWyVn30Vno4lqsFKXsLBoiVk6PHif9mn5YgUdus9ra7HuQ/8ML/kZ8bkAi56 I0he9b0uC/QnNj3l5izGXY4wwajm0qqpfhUvPlFWzmuUXa/Ep3LixG4UbfM49tPQQMyL +h/ykb/1bbLThzr8lzbM05ep/efUtdrzda0oYoKFweMbmXcxAxriAJQBG2oiOmrYMRkK A/KINZJ3BYUR/8P+86qrOxdHIaxR/NZC06iasa2Y92qJAu/QIHOj3lE1FchOki2wiBQh BO6Q== 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 l75si611842oig.59.2020.03.16.15.04.22; Mon, 16 Mar 2020 15:04:35 -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 S1732737AbgCPWD4 (ORCPT + 99 others); Mon, 16 Mar 2020 18:03:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732652AbgCPWD4 (ORCPT ); Mon, 16 Mar 2020 18:03:56 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E199D20674; Mon, 16 Mar 2020 22:03:53 +0000 (UTC) Date: Mon, 16 Mar 2020 18:03:52 -0400 From: Steven Rostedt To: Joel Fernandes Cc: "Paul E. McKenney" , rcu , LKML , "kernel-team@fb.com," , Ingo Molnar , Lai Jiangshan , dipankar , Andrew Morton , Mathieu Desnoyers , Josh Triplett , Thomas Glexiner , Peter Zijlstra , David Howells , Eric Dumazet , Frederic Weisbecker , Oleg Nesterov Subject: Re: [PATCH RFC tip/core/rcu 09/16] rcu-tasks: Add an RCU-tasks rude variant Message-ID: <20200316180352.4816cb99@gandalf.local.home> In-Reply-To: References: <20200312181618.GA21271@paulmck-ThinkPad-P72> <20200312181702.8443-9-paulmck@kernel.org> <20200316194754.GA172196@google.com> <20200316203241.GB3199@paulmck-ThinkPad-P72> <20200316173219.1f8b7443@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Mar 2020 17:45:40 -0400 Joel Fernandes wrote: > > > > Same for the function side (if not even more so). This would require adding > > a srcu_read_lock() to all functions that can be traced! That would be a huge > > kill in performance. Probably to the point no one would bother even using > > function tracer. > > Point well taken! Thanks, Actually, it's worse than that. (We talked about this on IRC but I wanted it documented here too). You can't use any type of locking, unless you insert it around all the callers of the nops (which is unreasonable). That is, we have gcc -pg -mfentry that creates at the start of all traced functions: : call __fentry__ [code for function here] At boot up (or even by the compiler itself) we convert that to: : nop [code for function here] When we want to trace this function we use text_poke (with current kernels) and convert it to this: : call trace_trampoline [code for function here] That trace_trampoline can be allocated, which means when its no longer needed, it must be freed. But when do we know it's safe to free it? Here's the issue. : call trace_trampoline <- interrupt happens just after the jump [code for function here] Now the task has just executed the call to the trace_trampoline. Which means the instruction pointer is set to the start of the trampoline. But it has yet executed that trampoline. Now if the task is preempted, and a real time hog is keeping it from running for minutes at a time (which is possible!). And in the mean time, we are done with that trampoline and free it. What happens when that task is scheduled back? There's no more trampoline to execute even though its instruction pointer is to execute the first operand on the trampoline! I used the analogy of jumping off the cliff expecting a magic carpet to be there to catch you, and just before you land, it disappears. That would be a very bad day indeed! We have no way to add a grace period between the start of a function (can be *any* function) and the start of the trampoline. Since the problem is that the task was non-voluntarily preempted before it could execute the trampoline, and that trampolines are not allowed (suppose) to call schedule, then we have our quiescent state to track (voluntary scheduling). When all tasks have either voluntarily scheduled, or entered user space after disconnecting a trampoline from a function, we know that it is safe to free the trampoline. -- Steve