Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759563AbbLCJko (ORCPT ); Thu, 3 Dec 2015 04:40:44 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:1522 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759357AbbLCJkj (ORCPT ); Thu, 3 Dec 2015 04:40:39 -0500 Subject: Re: [PATCH] arm64: ftrace: stop using kstop_machine to enable/disable tracing To: Will Deacon References: <1448697009-17211-1-git-send-email-huawei.libin@huawei.com> <20151202123654.GC4523@arm.com> <20151202131659.GA5621@arm.com> CC: , , , , , , From: libin Message-ID: <56600DEC.7050703@huawei.com> Date: Thu, 3 Dec 2015 17:39:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20151202131659.GA5621@arm.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.78] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.56600DFF.0037,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 4f96f4210b4dba10906bd49e1802b521 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2064 Lines: 57 on 2015/12/2 21:16, Will Deacon wrote: > On Wed, Dec 02, 2015 at 12:36:54PM +0000, Will Deacon wrote: >> On Sat, Nov 28, 2015 at 03:50:09PM +0800, Li Bin wrote: >>> On arm64, kstop_machine which is hugely disruptive to a running >>> system is not needed to convert nops to ftrace calls or back, >>> because that modifed code is a single 32bit instructions which >>> is impossible to cross cache (or page) boundaries, and the used str >>> instruction is single-copy atomic. >> This commit message is misleading, since the single-copy atomicity >> guarantees don't apply to the instruction-side. Instead, the architecture >> calls out a handful of safe instructions in "Concurrent modification and >> execution of instructions". >> >> Now, those safe instructions *do* include NOP, B and BL, so that should >> be sufficient for ftrace provided that we don't patch condition codes >> (and I don't think we do). > Thinking about this some more, you also need to fix the validate=1 case > in ftrace_modify_code so that it can run outside of stop_machine. We > currently rely on that to deal with concurrent modifications (e.g. > module unloading). I'm not sure it is really a problem, but on x86, which using breakpoints method, add_break() that run outside of stop_machine also has similar code. static int add_break(unsigned long ip, const char *old) { unsigned char replaced[MCOUNT_INSN_SIZE]; unsigned char brk = BREAKPOINT_INSTRUCTION; if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE)) return -EFAULT; /* Make sure it is what we expect it to be */ if (memcmp(replaced, old, MCOUNT_INSN_SIZE) != 0) return -EINVAL; return ftrace_write(ip, &brk, 1); } Or I misunderstand what you mean? Thanks, Li Bin > Will > > . > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/