From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A1F4FC6FD19 for ; Thu, 16 Mar 2023 15:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v2uqkCsytGJTS8sCDGsYcd4DbQGqwVbQvxEnvBpXpDA=; b=wadrW5ZNiV7S/p nqQdVpGW5ydzzDzZ78K2o70nzyw+rGiIBi835WaaE4ovdsHUU751PMBFAiUNa/BIRDD63eL0pcb5c HjcaiHaIiu8sbF8VcBCJGawXYh8RSiOC5zPDIxehTw2eqq5i6jq4mEMYEFEBjxKlzd1hSHH4daI77 hbpTOuyz1q3zHSHWz/Xs+9jk6R4YXGd+KjpzqMScCDSPKSQOcKRfygGJI3967XPqJGHUeg1X8Buas NOPEy7GIP2RJcPWHvQse8ebehdW5PkvQbILdP7D+r6CWPA84/7Oo1nuNtTfgSyJLYygh0HEVhh8zv SEIWf2YnjpAg5J4pHVTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcpnd-00GtIl-1i; Thu, 16 Mar 2023 15:45:53 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcpna-00GtHo-1i for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 15:45:52 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EE5556208D; Thu, 16 Mar 2023 15:45:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC840C433EF; Thu, 16 Mar 2023 15:45:47 +0000 (UTC) Date: Thu, 16 Mar 2023 11:45:44 -0400 From: Steven Rostedt To: Florent Revest Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org, jolsa@kernel.org, xukuohai@huaweicloud.com, lihuafei1@huawei.com Subject: Re: [PATCH v2 04/10] ftrace: Store direct called addresses in their ops Message-ID: <20230316114544.5db09039@gandalf.local.home> In-Reply-To: References: <20230207182135.2671106-1-revest@chromium.org> <20230207182135.2671106-5-revest@chromium.org> <20230315194334.58eb56ab@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230316_084550_610071_EF3B4968 X-CRM114-Status: GOOD ( 15.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 16 Mar 2023 16:40:48 +0100 Florent Revest wrote: > > > @@ -5466,6 +5467,7 @@ __modify_ftrace_direct(struct ftrace_ops *ops, unsigned long addr) > > > entry->direct = addr; > > > } > > > } > > > + WRITE_ONCE(ops->direct_call, addr); > > > > I'm curious about the use of WRITE_ONCE(). It should not go outside the > > mutex barrier. > > This WRITE_ONCE was originally suggested by Mark here: > https://lore.kernel.org/all/Y9vW99htjOphDXqY@FVFF77S0Q05N.cambridge.arm.com/#t > > My understanding is that it's not so much about avoiding re-ordering > but rather about avoiding store tearing since a ftrace_caller > trampoline could concurrently read ops->direct_call. Does that make > sense ? Yes, but a comment needs to be added: /* Prevent store tearing on some archs */ WRITE_ONCE(ops->direct_call, addr); Or something to that affect. Otherwise I can see it confusing others in the future. And probably me too, as I'll forget why it was a WRITE_ONCE() by next month. ;-) -- Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel