From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbdJDOCE (ORCPT ); Wed, 4 Oct 2017 10:02:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbdJDOCD (ORCPT ); Wed, 4 Oct 2017 10:02:03 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF4AE218F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Wed, 4 Oct 2017 23:01:58 +0900 From: Masami Hiramatsu To: Steven Rostedt 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: <20171004230158.44dc05a8c9f08e66e62a1fc2@kernel.org> In-Reply-To: <20171003195722.69954d2c@gandalf.local.home> References: <150581509713.32348.1905525476438163954.stgit@devbox> <150581537997.32348.14125457458719053753.stgit@devbox> <20170928072220.iv5subwl4u4zcqcp@gmail.com> <20170929002938.64cb852d6d921ec013d7f052@kernel.org> <20171003195722.69954d2c@gandalf.local.home> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-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 Tue, 3 Oct 2017 19:57:22 -0400 Steven Rostedt wrote: > > 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. Ah, now I got it. Yes, interrupt itself is not preempted... Thank you! > > -- Steve -- Masami Hiramatsu