Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2577569rwb; Wed, 30 Nov 2022 08:15:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5uS//8vnoTezAG1AIXU65Rzrkvs2okcQ4SKNJNeVP3nb3j/qbsvWX9R7pN/GazCGAZOBfN X-Received: by 2002:a17:90a:ea8f:b0:219:2e8c:d1d0 with SMTP id h15-20020a17090aea8f00b002192e8cd1d0mr18795834pjz.57.1669824928621; Wed, 30 Nov 2022 08:15:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669824928; cv=none; d=google.com; s=arc-20160816; b=Rtn+6Zewh7aSuU+VAxNAwnSYa4uRF1tiLI7WnglaZsce6BJ/fBcH6ph7vgv4xjG6wb HEd+FeHYPgJU02bw5VKYEx79BpxzDZ5zTN3WgEaZklOxWi925y2k9x+A+cHW/EnN91OZ yQMI5rF5ZqV8qHvnDkHTA7eXVW9YBpBeZZIIgMvhaqcEfdzaBYAdpGO+F3C50VhdT4Uh XUM8qhtnAghpp0Ggz54pfoJs1649Og3skw0iqf79Y1KOYc8YnwztlW0b1YNnuOc6/F/R cG3KOGZVP1TYCERt0ZKOwPfRol5UnleSe9srxtjvC2f2T83w8g7FUDywaHktSWVa0VCz 99qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zIfYbKWP31Ga45fjpIdNczqovaQe7oeD4QgHaBD92PY=; b=ZDh2tRUV518yXF4w384niIp9tqw65i4cYOd5KNjcNApbKJTDK6QOFOXrzG+0wz8aur fazL/C3jnKEEF94OF545Hlq7hAYiwOMj/H334/+UdDM82luNB8THLwhMn1ysLn4IWWrW IpQO3gKECWLiu2dAZVbbJTQNkwTg+XgKxu8d6NCf9YcMwulcWGZ8SG/KVEx1MoqRm8fd CxR1GuZ79Jt1hRwx924bDagos8v//ZlXM6OoFno70UCyU63RrmStawUIRVKdn1Gor9SC hFGUdq7KVc/ZH+QoUao5hMjfRuP3QXcZzCCx51qJMUL0dRqw8Y06r2zWxyltHGr68Vpz 6gzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g098uW20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t79-20020a635f52000000b0046ec3bdd048si1652807pgb.484.2022.11.30.08.15.16; Wed, 30 Nov 2022 08:15:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g098uW20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbiK3Pri (ORCPT + 83 others); Wed, 30 Nov 2022 10:47:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbiK3Prh (ORCPT ); Wed, 30 Nov 2022 10:47:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31AF11170; Wed, 30 Nov 2022 07:47:35 -0800 (PST) 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 C65EA617C3; Wed, 30 Nov 2022 15:47:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9687FC433C1; Wed, 30 Nov 2022 15:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669823254; bh=Ms6zG9bes1a4dywnpkOvtzh48RrPOPi6LWLATgEHGV0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=g098uW20SxRasYSkI8fyvQx47YyB9NUE3mdEQYw5JBwdboQoEnYgB7mxaHSGyNW+m LaDFTnSeyKqNNRx8+hzTf9BjF4uLiVFb7oX4W3jS3GhFVuxlzWz3y0gjUFYvx12Hcg o4o9C4r+mHR2nLIWw1YVjY/dl0CVMfSf2GtuqvfDzNA/GzCcR7T7FvjGd4f4zuJ0Pv G7KWKje8TNoZ/KUlAHgmXkJVaoKdg2SVq/e41IxMjPuSXRw36QXrhGluzt4rsHxuxB mJBQboNgAb4EDD4h0xIQs2KJnCkVK9HzMkMezecZpoQTlbXliYr18pLibLFsS+1eB3 VmCcRJuRJzE5w== Message-ID: <700e7f91-00a9-d625-741d-122b9b1e1e1c@kernel.org> Date: Wed, 30 Nov 2022 16:47:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH V3 2/3] tracing/osnoise: Add preempt/irq disable options Content-Language: en-US To: Steven Rostedt Cc: Masami Hiramatsu , Jonathan Corbet , Juri Lelli , Clark Williams , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <03d4a8522792fa3a51920c79f8a5074933a2fcb3.1669409262.git.bristot@kernel.org> <20221128153919.33c008d1@gandalf.local.home> From: Daniel Bristot de Oliveira In-Reply-To: <20221128153919.33c008d1@gandalf.local.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/28/22 21:39, Steven Rostedt wrote: > On Fri, 25 Nov 2022 22:20:23 +0100 > Daniel Bristot de Oliveira wrote: > >> @@ -1308,6 +1315,8 @@ static void notify_new_max_latency(u64 latency) >> */ >> static int run_osnoise(void) >> { >> + bool preempt_disable = test_bit(OSN_PREEMPT_DISABLE, &osnoise_options); >> + bool irq_disable = test_bit(OSN_IRQ_DISABLE, &osnoise_options); > > bool irq_disable = test_bit(OSN_IRQ_DISABLE, &osnoise_options); > bool preempt_disable = IS_ENABLED(CONFIG_PREEMPT) && > !irq_disable && test_bit(OSN_PREEMPT_DISABLE, &osnoise_options); Ooops again, that is not exactly what I wanted, because... >> struct osnoise_variables *osn_var = this_cpu_osn_var(); >> u64 start, sample, last_sample; >> u64 last_int_count, int_count; >> @@ -1335,6 +1344,14 @@ static int run_osnoise(void) >> */ >> threshold = tracing_thresh ? : 5000; >> >> + /* >> + * IRQ disable also implies in preempt disable. >> + */ >> + if (irq_disable) >> + local_irq_disable(); > > if (preempt_disable) >> + preempt_disable(); >> + >> /* >> * Make sure NMIs see sampling first >> */ >> @@ -1422,16 +1439,21 @@ static int run_osnoise(void) >> * cond_resched() >> */ >> if (IS_ENABLED(CONFIG_PREEMPT_RCU)) { >> - local_irq_disable(); >> + if (!irq_disable) >> + local_irq_disable(); >> + >> rcu_momentary_dyntick_idle(); >> - local_irq_enable(); >> + >> + if (!irq_disable) >> + local_irq_enable(); >> } >> >> /* >> * For the non-preemptive kernel config: let threads runs, if >> - * they so wish. >> + * they so wish, unless set not do to so. >> */ Then I end up cond_resched'ing here in the non-preemptive kernel. >> - cond_resched(); >> + if (!irq_disable && !preempt_disable) >> + cond_resched(); But I also want to avoid this cond_resched if preempt_disable is set. So, I will merge both things: - change the preempt_disable assignment to check !irq_disabled, like: /* * Disabling preemption is only required if IRQs are enabled, and the options is set on. */ preempt_disable = !irq_disable && test_bit(OSN_PREEMPT_DISABLE, &osnoise_options); - change the preempt disabled if to if (IS_ENABLED(CONFIG_PREEMPT) && preempt_disabled) preempt_disable(); I tested with both preemption models (preemptive and not preemptive) and it works fine. am I missing something? -- Daniel >> last_sample = sample; >> last_int_count = int_count; >> @@ -1450,6 +1472,14 @@ static int run_osnoise(void) >> */ >> barrier(); >> >> + /* >> + * Return to the preemptive state. >> + */ > > if (preempt_disable) >> + preempt_enable(); >> + > >> + if (irq_disable) >> + local_irq_enable(); > > -- Steve > >> /* >> * Save noise info. >> */