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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27E5CC433EF for ; Mon, 3 Jan 2022 09:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbiACJbG (ORCPT ); Mon, 3 Jan 2022 04:31:06 -0500 Received: from gateway24.websitewelcome.com ([192.185.51.162]:30745 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbiACJbE (ORCPT ); Mon, 3 Jan 2022 04:31:04 -0500 X-Greylist: delayed 1449 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Jan 2022 04:31:04 EST Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway24.websitewelcome.com (Postfix) with ESMTP id B68D5364A3 for ; Mon, 3 Jan 2022 03:06:54 -0600 (CST) Received: from gator4132.hostgator.com ([192.185.4.144]) by cmsmtp with SMTP id 4JIsnhXv9Rnrr4JIsnB4a2; Mon, 03 Jan 2022 03:06:54 -0600 X-Authority-Reason: nr=8 Received: from host-79-52-207-139.retail.telecomitalia.it ([79.52.207.139]:57842 helo=[10.0.0.65]) by gator4132.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n4JIs-003Y07-39; Mon, 03 Jan 2022 03:06:54 -0600 Message-ID: Date: Mon, 3 Jan 2022 10:06:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] trace/osnoise: fix event unhooking Content-Language: en-US To: Nikita Yushchenko Cc: linux-kernel@vger.kernel.org, kernel@openvz.org, Steven Rostedt , Ingo Molnar References: <20211228140727.2467771-1-nikita.yushchenko@virtuozzo.com> From: Daniel Bristot de Oliveira In-Reply-To: <20211228140727.2467771-1-nikita.yushchenko@virtuozzo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4132.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - kernel.org X-BWhitelist: no X-Source-IP: 79.52.207.139 X-Source-L: No X-Exim-ID: 1n4JIs-003Y07-39 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: host-79-52-207-139.retail.telecomitalia.it ([10.0.0.65]) [79.52.207.139]:57842 X-Source-Auth: kernel@bristot.me X-Email-Count: 4 X-Source-Cap: YnJpc3RvdG1lO2JyaXN0b3RtZTtnYXRvcjQxMzIuaG9zdGdhdG9yLmNvbQ== X-Local-Domain: no Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikita On 12/28/21 15:07, Nikita Yushchenko wrote: > If start_per_cpu_kthreads() called from osnoise_workload_start() returns > error, event hooks are left in broken state: unhook_irq_events() called > but unhook_thread_events() and unhook_softirq_events() not called, and > trace_osnoise_callback_enabled flag not cleared. > > On the next tracer enable, hooks get not installed due to > trace_osnoise_callback_enabled flag. > > And on the further tracer disable an attempt to remove non-installed > hooks happened, hitting a WARN_ON_ONCE() in tracepoint_remove_func(). > > Fix the error path by adding the missing part of cleanup. Regarding the subject: - use tracing/ as subsystem (yeah, I also made this mistake in the original osnoise series). - use a capital after the "tracing/osnoise:" Using your subject as example, it should be: tracing/osnoise: Fix event unhooking Anyway, I suggest using something more precise, like: tracing/osnoise: Properly unhook events if start_per_cpu_kthreads() fails or something like that. > While at this, introduce osnoise_unhook_events() to avoid code > duplication between this error path and notmal tracer disable. s/notmal/normal/ > > Fixes: bce29ac9ce0b ("trace: Add osnoise tracer") > Signed-off-by: Nikita Yushchenko > --- > kernel/trace/trace_osnoise.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c > index 7520d43aed55..aa6f26612ccc 100644 > --- a/kernel/trace/trace_osnoise.c > +++ b/kernel/trace/trace_osnoise.c > @@ -2123,6 +2123,13 @@ static int osnoise_hook_events(void) > return -EINVAL; > } > > +static void osnoise_unhook_events(void) > +{ > + unhook_thread_events(); > + unhook_softirq_events(); > + unhook_irq_events(); > +} > + > /* > * osnoise_workload_start - start the workload and hook to events > */ > @@ -2155,7 +2162,8 @@ static int osnoise_workload_start(void) > > retval = start_per_cpu_kthreads(); > if (retval) { > - unhook_irq_events(); > + trace_osnoise_callback_enabled = false; we need a barrier here, like: /* * Make sure that ftrace_nmi_enter/exit() see * trace_osnoise_callback_enabled as false before continuing. */ barrier(); > + osnoise_unhook_events(); > return retval; > } > Thanks! -- Daniel