Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2004732imu; Sat, 5 Jan 2019 12:01:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6ZBkVvr7+kMdpFXTy0r+M4LjDRcq6vaoU5K6vk5EWYOR9kS01jrQhfk7x3bmFoq6ikqxci X-Received: by 2002:a63:cd4c:: with SMTP id a12mr5878940pgj.252.1546718498361; Sat, 05 Jan 2019 12:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546718498; cv=none; d=google.com; s=arc-20160816; b=vpST4UCjh2SnH7XOrJKwlTez3LuEga6EiHGhmLRQK4hQ53A6UVmW2gMdH47vwCRcFQ 1wqrOFcuXIGpuhdpVMQjy7FbjFnlpxONeG1tFFWkSdWGi0fENfDMHs0lmy9edQ3UAORL WpjIHYXIVU9/1IFOuJ66VytlBKE1GctgVpyEduypJGgvaaawOSGsqNctU528e59s+QE9 HV/u/ujgG0rRJo4Wd6qEySXLcsdTIWU9Cd3K8QuDrL/5t0KWM+3o8hN/X6arLNOF7IPS ibeJdWCVzDTMjZFSN//PJcOPeiVUTlmKpEfYfOoHtQeclB2+YrRAr6vvqq2uz+u6l7vK Pw2g== 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=0oxTTAJzMSOUxJJrwDUprdFh/jRzLmMNWPJ5qfUkWNc=; b=pUqWfi6Mo7F5poGr1LEBWs+OHtqjQN70fNkSSl35FgCPooAqZjKDUZ87zqituDhJj8 /v/fotEQVVKhuTImbEfiP4MBGzbiuMBJDAoA9nIqSoJ8lUUJSLQfoUqf8IszRMRjN1OQ p7lCGrinwMbrEQ5LEdnlQvp7S8Tkp2XWE7pTKtzCdS1jWKGmhG1Di11mtdv2JwkH8ABY 1srVuhgLios4i07uXXnpyqXB7gDlLEAYGm++RPnNa7cxxy++xoR+XXT7GsgUya7L78zl /mrZv/NQ5qPGx3oTIftKmlewSF7kjHxjNLOJwjarFhKgLiuR8DiPQ5pgPaa3tcA7gLno 3y7w== 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 m198si58780704pga.98.2019.01.05.12.01.23; Sat, 05 Jan 2019 12:01:38 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726363AbfAEUAQ (ORCPT + 99 others); Sat, 5 Jan 2019 15:00:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:39366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfAEUAQ (ORCPT ); Sat, 5 Jan 2019 15:00:16 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 CBF8421915; Sat, 5 Jan 2019 20:00:13 +0000 (UTC) Date: Sat, 5 Jan 2019 15:00:11 -0500 From: Steven Rostedt To: Torsten Duwe Cc: Mark Rutland , Will Deacon , Catalin Marinas , Julien Thierry , Josh Poimboeuf , Ingo Molnar , Ard Biesheuvel , Arnd Bergmann , AKASHI Takahiro , Amit Daniel Kachhap , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, "Paul E. McKenney" Subject: Re: [PATCH v6] arm64: implement ftrace with regs Message-ID: <20190105150011.6062d818@gandalf.local.home> In-Reply-To: <20190105110543.GA4298@lst.de> References: <20190104141053.360F768D93@newverein.lst.de> <20190104175017.GA7157@lakrids.cambridge.arm.com> <20190104130648.02657f3f@gandalf.local.home> <20190104224145.GA28236@lst.de> <20190105110543.GA4298@lst.de> X-Mailer: Claws Mail 3.16.0 (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 Sat, 5 Jan 2019 12:05:43 +0100 Torsten Duwe wrote: > > My point is: those 2 insn will _never_ be split by any alignment > > boundary > 8; does that mean anything, have you considered this? > > Forget that. Steve mentioned the keyword *interrupt*, which creates a > completely different situation. In short, only the instruction pointer > will be saved; and i-cache and pipeline will be freshly reloaded on return, > so this threat is highly unlikely (interrupt taken exactly after 1st nop), > but not impossible. "Puking horses..." as we say in German. Correct. > > > > > I wonder if we could solve that by patching the kernel at build-time, to > > > > add the MOV X9, X30 in place of the first NOP. If we were to do that, we > > > > could also update the addresses to pooint at the second NOP, simplifying > > > > the changes to the runtime code. > > > > > > You can also patch it at boot up when there's only one CPU running, and > > > interrupts are disabled. > > > > May I remind about possible performance hits? Even the NOPs had a tiny impact > > on certain in-order implementations. I'd rather switch between the mov and > > a "b +2". > > This one however still holds. Now, if you can add one of the changes, do a synchronization to make sure that all tasks are not preempted there, and see that first change, then make the other change to complete the transaction, there may be a solution: synchronize_rcu_tasks()! convert all first nops to "MOV X9, X30" synchronize_rcu_tasks(); convert all second nops to "BL ftrace_regs_caller" That would work. What synchronize_rcu_tasks() does, is that it wont return until all tasks have either called schedule voluntarily (not preempted), goes into user space, or goes idle. Tasks that are idle (not preempted) are not counted. Then you are guaranteed that no task was preempted at the first nop and will come back and call "BL ftrace_regs_caller". The only caveat is that synchronize_rcu_tasks() can take some time to complete (seconds even) if something was preempted and is starved from the CPU for some time. This is why you would need to group the conversions together, by changing all the first nops for all the functions you want to trace before calling the synchronization routine. -- Steve