Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2137100ybk; Mon, 11 May 2020 12:50:54 -0700 (PDT) X-Google-Smtp-Source: APiQypIENIHXfq37y6nK45Y6HJRPmPZ1ClBTmgtogOKXLgrpKM9X5BJALhU1keu2IdcSF3pPpsCk X-Received: by 2002:a50:ec0c:: with SMTP id g12mr15470475edr.140.1589226654443; Mon, 11 May 2020 12:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589226654; cv=none; d=google.com; s=arc-20160816; b=xCoi+ShXq5yEJ3mYntBpPq1zkcCK2WGM09z7EjuhhJbRLoCyqDEC5NQAypB8N0rKjL 0c/BHHNjNp0Y/k40NZMxafsSTmf3RHm0XgO2KTSWXxA9iAx1WAzrePfVt6nZrje44AqX YGcrjaRT4wk/e6j51c4ApjzKu1zrNfy8ijESkQ7vDB3E3jsgVLaB2TW9R6OT74XPr0L0 tSCA8wqaRu7ckrmr/KGbp+jMk/9WimKFVcrqpURLi54mXqH5mZZ0+Wo82+EhZAO8Oo4z xcb8P9xb9sKvOM2E/yjfzEaWGYpGMwfCuU7Az4VbZr4JJmU+FFvareCl5bJBB6AUllH7 syXQ== 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=obtfchfQ/OPhJMfF79ZShU1dKR1UxYR8Owona5jtjgI=; b=FkeYeNBc3iDx1i3PLdr91ezzMsuKOe1SwczvgARDUha5PKMuQ4XVyMTRg3HtwuShZn YpmfwWxMt64WcZoue0VemL0LdwrkZHDenfcRMJWOrQrv9G3S00J9mE75KksXcRA1wLU2 IkSAKL5X2KfGXfxNerx0xcwaHRtzIOd+JfiGrpVSmKWpqfmbhCcOwH7jNYn9N3L+y1qD 4cFbT20ZBcstuDLciiowmIY6Ur4Bu2ish/tTR/NwZ0v1JYiBuhTWM1ut8VvNW/bxLntQ UNH7glSIUfMzSngHikdP+RW9SjmiIRZr/pWJ9QFBGCuQy+ofoFlnzB+qGbR2Fq8Tjw/B tkxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si1065516ejx.41.2020.05.11.12.50.24; Mon, 11 May 2020 12:50:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729703AbgEKTs3 (ORCPT + 99 others); Mon, 11 May 2020 15:48:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728613AbgEKTs2 (ORCPT ); Mon, 11 May 2020 15:48:28 -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 7899A206F5; Mon, 11 May 2020 19:48:26 +0000 (UTC) Date: Mon, 11 May 2020 15:48:24 -0400 From: Steven Rostedt To: Lai Jiangshan Cc: Joel Fernandes , "Paul E. McKenney" , rcu , LKML , "kernel-team@fb.com," , Ingo Molnar , dipankar , Andrew Morton , Mathieu Desnoyers , Josh Triplett , Thomas Glexiner , Peter Zijlstra , David Howells , Eric Dumazet , Frederic Weisbecker , Oleg Nesterov , Masami Hiramatsu Subject: Re: [PATCH RFC tip/core/rcu 09/16] rcu-tasks: Add an RCU-tasks rude variant Message-ID: <20200511154824.09a18c46@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> <20200316180352.4816cb99@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 Sun, 10 May 2020 17:59:27 +0800 Lai Jiangshan wrote: > Hello > > I think adding a small number of instructions to preempt_schedule_irq() > is sufficient to create the needed protected region between the start > of a function and the trampoline body. > > preempt_schedule_irq() { > + if (unlikely(is_trampoline_page(page_of(interrupted_ip)))) { > + return; // don't do preempt schedule > + > + } > preempt_schedule_irq() original body > } > > // generated on trampoline pages > trace_trampoline() { > preempt_disable(); > trace_trampoline body > jmp preempt_enable_traced(clobbers) > } > > asm(kernel text): > preempt_enable_traced: > preempt_enable_notrace(); > restore cobblers > return(the return ip on the stack is traced_function_start_code) > > > If the number of instructions added in preempt_schedule_irq() and > the complexity to make trampoline ip detectable(is_trampoline_page(), > or is_trampoline_range()) are small, and tasks_rcu is rendered useless, > I think it will be win-win. To make this even more complex, with ftrace direct callers (used by bpf to define their own non ftrace trampoline), if a direct call is on the same location as a ftrace caller, we have something like this: ftrace_caller: save_regs call ftrace_ops_list_func cmp ORIG_RAX jnz do_direct restore_regs ret do_direct: mov ORIG_RAX to return restore_regs ret What the above is basically doing, is that the ftrace_ops_list_func() will call the ftrace callbacks, but also a special callback to handle the direct that is also registered to that same location. The direct callback will place the address of the direct trampoline into ORIG_RAX. Then on return from ftrace_ops_list_func(), it will jump directly to the direct caller. To implement what you are proposing, you have to have a way to keep preemption off between the setting of ORIG_RAX and the jump to the direct caller (which would require its own preempt_disable() section). But if we preempt between the two, the direct trampoline may disappear and then this code will jump to it. -- Steve