From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033567AbdAJBLN (ORCPT ); Mon, 9 Jan 2017 20:11:13 -0500 Received: from mail.kernel.org ([198.145.29.136]:40828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932351AbdAJBLM (ORCPT ); Mon, 9 Jan 2017 20:11:12 -0500 Date: Tue, 10 Jan 2017 10:11:01 +0900 From: Masami Hiramatsu To: Josh Poimboeuf Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Peter Zijlstra , Ananth N Mavinakayanahalli , Thomas Gleixner , "H . Peter Anvin" , Andrey Konovalov , Andy Lutomirski Subject: Re: [PATCH tip/master v4] kprobes: extable: Identify kprobes' insn-slots as kernel text area Message-Id: <20170110101101.f2dacdd07154725a943c7bb9@kernel.org> In-Reply-To: <20170109173648.k7dxu7nz22qc6upq@treble> References: <20170104100102.GE25813@worktop.programming.kicks-ass.net> <148388747896.6869.6354262871751682264.stgit@devbox> <20170109173648.k7dxu7nz22qc6upq@treble> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 9 Jan 2017 11:36:48 -0600 Josh Poimboeuf wrote: > On Sun, Jan 08, 2017 at 11:58:09PM +0900, Masami Hiramatsu wrote: > > Make __kernel_text_address()/kernel_text_address() returns > > true if the given address is on a kprobe's instruction slot, > > which is generated by kprobes as a trampoline code. > > This can help stacktraces to determine the address is on a > > text area or not. > > > > To implement this without any sleep in is_kprobe_*_slot(), > > this also modify insn_cache page list as a rcu list. It may > > increase processing deley (not processing time) for garbage > > slot collection, because it requires to wait an additional > > rcu grance period when freeing a page from the list. > > However, since it is not a hot path, we may not take care of it. > > > > Note: this can give a small overhead to stack unwinders because > > this adds 2 checks in __kernel_text_address(). However, the > > impact should be very small, kprobe_insn_pages list has 1 entry > > per 256 probes(on x86, on arm/arm64 it will be 1024 probes), > > and kprobe_optinsn_pages has 1 entry per 32 probes(on x86). > > In most use cases, the number of kprobe events may be less > > than 20, this means is_kprobe_*_slot() will check just 1 entry. > > > > Signed-off-by: Masami Hiramatsu > > Thanks for doing this Masami! I verified that it works: > > Tested-by: Josh Poimboeuf Thanks! > > I suspect that BPF generated code also has the same issue, so I'll leave > the unwinder warning disabled for now. > > BTW, I think we'll have more problems with generated code if/when we > move to an x86 DWARF unwinder, because it won't have any idea how to > unwind past generated code. Long term I wonder if it would make sense > to create some kind of framework for creating or registering generated > code, so we can solve these types of problems in a single place. Agreed. I think that can also help us to make the generated code RO :). Thank you, -- Masami Hiramatsu