From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751527AbdJCX51 (ORCPT ); Tue, 3 Oct 2017 19:57:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:51032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbdJCX50 (ORCPT ); Tue, 3 Oct 2017 19:57:26 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F1A9214E0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Tue, 3 Oct 2017 19:57:22 -0400 From: Steven Rostedt To: Masami Hiramatsu Cc: Ingo Molnar , mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ananth N Mavinakayanahalli , Thomas Gleixner , "H . Peter Anvin" , "Paul E . McKenney" , Alexei Starovoitov , Alexei Starovoitov Subject: Re: [PATCH -tip v3 7/7] kprobes: Use synchronize_rcu_tasks() for optprobe with CONFIG_PREEMPT Message-ID: <20171003195722.69954d2c@gandalf.local.home> In-Reply-To: <20170929002938.64cb852d6d921ec013d7f052@kernel.org> References: <150581509713.32348.1905525476438163954.stgit@devbox> <150581537997.32348.14125457458719053753.stgit@devbox> <20170928072220.iv5subwl4u4zcqcp@gmail.com> <20170929002938.64cb852d6d921ec013d7f052@kernel.org> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; 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 Sorry for the late reply. Coming back from Kernel Recipes, I fell way behind in email. On Fri, 29 Sep 2017 00:29:38 -0700 Masami Hiramatsu wrote: > > > + * are done. Because optprobe may modify multiple instructions, > > > + * there is a chance that the Nth instruction is interrupted. In that > > > + * case, running interrupt can return to the Nth byte of jump > > > + * instruction. This can be avoided by waiting for returning of > > > + * such interrupts, since (until here) the first byte of the optimized > > > + * probe is already replaced with normal kprobe (sw breakpoint) and > > > + * all threads which reach to the probed address will hit it and > > > + * bypass the copied instructions (instead of executing the original.) > > > + * With CONFIG_PREEMPT, such interrupts can be preepmted. To wait > > > + * for such thread, we will use synchronize_rcu_tasks() which ensures > > > + * all preeempted tasks are scheduled normally (not preempted). > > > + * So we can ensure there is no threads preempted at probed address. > > > > What? Interrupts cannot be preempted. > > Steve, could you correct me if I'm wrong. I thought if the kernel is > compiled with CONFIG_PREEMPT=y, even in the kernel, it can be preempted > suddenly. It means timer interrupt occurs at kernel path and it yield > to new task (=preempt.) Do I miss something? The above sounds correct. I believe Ingo was pointing out the line that states "With CONFIG_PREEMPT, such interrupts can be preempted", which is not true. I think you meant that interrupts can preempt the kernel and cause it to schedule out. The line above sounds like you meant the interrupt was preempted, which can't happen. -- Steve