Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1870861ybi; Mon, 1 Jul 2019 01:51:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCVs9l5y7juTS9QuqEvgxOZDFnc00oYMQDp+QNbZo1GqQMmgLDug7GAkNUcbGVsnpkJApM X-Received: by 2002:a17:902:704c:: with SMTP id h12mr28024954plt.214.1561971117660; Mon, 01 Jul 2019 01:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561971117; cv=none; d=google.com; s=arc-20160816; b=ijmCIdhiZtb+Kz1wjfkiJWoafRft1q20ILi12o20uOT+0RjNY3X5qaeqjm0kc+zl7o OVhT51JxvzM7qq5e0Ryxdreqv1HRZgzN9LDxroYSoirtC9awjHbaOMUQx0lgh2xkW27O yHlPozsC7uYEILzzsC0VCJvjK5+QAP/fTAElharcCbATHHc10hcTjn/hJeTKOwM+oLwX f1MukyYDYpKn9DjvfJ69JZdJzSg6soAnyNZnHUKbgjZgQJ8cY8QzuCJSrqKSvxXt4IFA CN5lX0FFkN/NYrRaYeslM5LfLSqSyKeD/7MO3+bQHYeTUPbdkd8b83B8G/xh2DnBJGhL R3ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:user-agent:in-reply-to:references:cc:to:subject:from :date; bh=TPNPSyDTBMiANP0Tc+hkbiqkJ6x466c7Ca3E5WEd+rQ=; b=eqX2QjdH4qXHBlqEQP0HMhxS/fuCkqRItu8ntL7ZEOVe9TGUV23Y+8KbCesmcXwTxb M4X8or/9v2txqNBjgGHjsY3vgw+UO22YJFiAF1xtX1gbd5sTadOwrEQ0IHI6UAeTFtFB cOPta9YrDas/qRQGITrvNISFvrq+2XLvSYx/sM40XnBHUcEmkqgBlCFQM8uwMQlXzHrm o8mSQNE0XLh/G3HCAkpviI3c+N8n/AKzu1ViNXmV7pWbZwu9Y6H0LZMI3czT9Ji6NP0Z 38uHU7+xySFP1H9MeL4x6pvCKAA/V+AqRI4+/uqtGmYX7Vl9ahedWb94RIR0UJAgKXdt 3BXQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si9743737plm.94.2019.07.01.01.51.41; Mon, 01 Jul 2019 01:51:57 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728087AbfGAIva convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Jul 2019 04:51:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38144 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbfGAIva (ORCPT ); Mon, 1 Jul 2019 04:51:30 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x618m94I050596 for ; Mon, 1 Jul 2019 04:51:29 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tfem5s561-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Jul 2019 04:51:28 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 1 Jul 2019 09:51:25 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 1 Jul 2019 09:51:20 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x618pJ1I50266294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Jul 2019 08:51:20 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD34042042; Mon, 1 Jul 2019 08:51:19 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E56F42041; Mon, 1 Jul 2019 08:51:19 +0000 (GMT) Received: from localhost (unknown [9.124.35.147]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Jul 2019 08:51:19 +0000 (GMT) Date: Mon, 01 Jul 2019 14:21:17 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH v2 4/7] powerpc/ftrace: Additionally nop out the preceding mflr with -mprofile-kernel To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Masami Hiramatsu , Ingo Molnar , Michael Ellerman , Nicholas Piggin References: <841386feda429a1f0d4b7442c3ede1ed91466f92.1561634177.git.naveen.n.rao@linux.vnet.ibm.com> <20190627110819.4892780f@gandalf.local.home> <1561648598.uvetvkj39x.naveen@linux.ibm.com> <20190627121344.25b5449a@gandalf.local.home> In-Reply-To: <20190627121344.25b5449a@gandalf.local.home> User-Agent: astroid/0.14.0 (https://github.com/astroidmail/astroid) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 19070108-0020-0000-0000-0000034F14D6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070108-0021-0000-0000-000021A29D96 Message-Id: <1561970917.6b4f6qppo3.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-01_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=930 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907010110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Steven Rostedt wrote: > On Thu, 27 Jun 2019 20:58:20 +0530 > "Naveen N. Rao" wrote: > >> >> > But interesting, I don't see a synchronize_rcu_tasks() call >> > there. >> >> We felt we don't need it in this case. We patch the branch to ftrace >> with a nop first. Other cpus should see that first. But, now that I >> think about it, should we add a memory barrier to ensure the writes get >> ordered properly? > > Do you send an ipi to the other CPUs. I would just to be safe. > >> >> We are handling this through ftrace_replace_code() and >> __ftrace_make_call_prep() below. For FTRACE_UPDATE_MAKE_CALL, we patch >> in the mflr, followed by smp_call_function(isync) and >> synchronize_rcu_tasks() before we proceed to patch the branch to ftrace. >> >> I don't see any other scenario where we end up in >> __ftrace_make_nop_kernel() without going through ftrace_replace_code(). >> For kernel modules, this can happen during module load/init and so, I >> patch out both instructions in __ftrace_make_call() above without any >> synchronization. >> >> Am I missing anything? >> > > No, I think I got confused ;-), it's the patch out that I was worried > about, but when I was going through the scenario, I somehow turned it > into the patching in (which I already audited :-p). I was going to > reply with just the top part of this email, but then the confusion > started :-/ > > OK, yes, patching out should be fine, and you already covered the > patching in. Sorry for the noise. > > Just to confirm and totally remove the confusion, the patch does: > > : > mflr r0 <-- preempt here > bl _mcount > > : > mflr r0 > nop > > And this is fine regardless. > > OK, Reviewed-by: Steven Rostedt (VMware) Thanks for confirming! We do need an IPI to be sure, as you pointed out above. I will have the patching out take the same path to simplify things. - Naveen