Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5744999imw; Wed, 20 Jul 2022 11:36:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2bp4tdbI6eddG1EWEAXO8VoZ94HaNjUHI2FMV75SXhqUky88JtX3WiQzMxCq092FlJ73G X-Received: by 2002:a17:907:3f27:b0:72b:838e:f104 with SMTP id hq39-20020a1709073f2700b0072b838ef104mr37018131ejc.63.1658342209939; Wed, 20 Jul 2022 11:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658342209; cv=none; d=google.com; s=arc-20160816; b=bABZof/cP9Hm4P05MojcFZUOYTb9SSd8kQ5DC8FP4i7Wzv57cXAALO611G/hIlwJAF Dau/YnoxbiwY6/PCWa2PBkGtrpLDHYVK/oV4BqDLRivGJRRcJXiwEgjpfCKCIqCDbZ5j JeVu59qTIKPtOo8yDztrfmbUs6ei1WdQGXKh3vJJDNyvdxeyDHUlL+MpyzuNx2BdZocy SulgSrlWoklf5+LvdH3NqTCq6EsNKCJcygpKi8YapuzNdd6hEEAntmVU2kPGZIVDiB8W nFExJkn8NYZF3MHh6BfLQ5qkez++NAgjC9M6O5vrkCIDNqFarphPpP0idIkxlJyf5B9f 0S7Q== 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=UjyHcNiCt6k2v8Gb63FUnpo3/fO5hHRKkSMn2ZOwF6k=; b=S9wQ3EjSP3R/21LzIN+Y+KdbzYphzV6n+nia31BX1f+CYsX+oITWRS5v+wCk5LDi0M YVH3LZ7U6uuwKqkMD5mWRoy4hFg31o2cXIel7QF1c00IFGTtWqgGxE05a67xaU5IqjzH X2fqH5BnG16XZp3dmeXKujQnJOplrw5KXozfLYm+PP3bhOlI2uy3dmovcwO9Cn9TjcMp LIlB4m3DoSimQvXyY/JW1GSX/K3uAW3tVIIhSsaxZse+tRwX9EJkiIHqQN9rxBZzHQ7z Mj3KgVWU2yVEzLDQYwwzDhPZuiJVA5Bhne9m5MfC1TRrbSOO7QsYQYKzMHSqle/LdHpU LGOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NqT2PR7n; 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 z27-20020a170906271b00b0072a87f63748si21169447ejc.908.2022.07.20.11.36.24; Wed, 20 Jul 2022 11:36:49 -0700 (PDT) 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=NqT2PR7n; 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 S230281AbiGTRiS (ORCPT + 99 others); Wed, 20 Jul 2022 13:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbiGTRiN (ORCPT ); Wed, 20 Jul 2022 13:38:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C7BA6D2C1; Wed, 20 Jul 2022 10:38:12 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 04735B82176; Wed, 20 Jul 2022 17:38:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5685C341C7; Wed, 20 Jul 2022 17:38:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658338689; bh=Yt6GU+e8Sr03z0JsEg+zp/YF2iTy0o8KRPWJe4f3nPc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NqT2PR7nQhs1Fzku2LldppT7NNpCCYa/YsLWfPZTsVov8hAKlPHwaeWeaDOuiyIJl yvDvMWLBznAlzBZqJtmMMDdRHn7cyxvhOrxI04FykBcM26h8NX7ZDYs9su12amWLuQ yIpjHl0PrEN1rYclD12UAIo0nz9WUcyZ2gegGDwlWzD8eFrQu6xTxc3IYq2O3M+DZe fMh7JW6v6GMvaQ6RCSQZQgVm+MD+qEOxHWChnj8Mc+IdjhmUOW5pbRJjaQ41GvUTwt xDcJwvBmiKQE0aBE5g8Qea+TZMzPXWc3Mqro2dvVeAfJvRUid8gQIuo8S+RDor1HZm /LAHBrLiLxMNg== Message-ID: Date: Wed, 20 Jul 2022 19:37:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V6 02/16] rv: Add runtime reactors interface Content-Language: en-US To: Steven Rostedt Cc: Wim Van Sebroeck , Guenter Roeck , Jonathan Corbet , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Will Deacon , Catalin Marinas , Marco Elver , Dmitry Vyukov , "Paul E. McKenney" , Shuah Khan , Gabriele Paoloni , Juri Lelli , Clark Williams , Tao Zhou , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org References: <4b5f93e3186b067073c1692d4c2b50d0b42101d5.1658244826.git.bristot@kernel.org> <20220720124133.3cdd2c44@gandalf.local.home> <20220720130209.65f501b1@gandalf.local.home> From: Daniel Bristot de Oliveira In-Reply-To: <20220720130209.65f501b1@gandalf.local.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.8 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 7/20/22 19:02, Steven Rostedt wrote: > On Wed, 20 Jul 2022 18:50:39 +0200 > Daniel Bristot de Oliveira wrote: > >> On 7/20/22 18:41, Steven Rostedt wrote: >>> On Tue, 19 Jul 2022 19:27:07 +0200 >>> Daniel Bristot de Oliveira wrote: >>> >>>> +/* >>>> + * reacting_on interface. >>>> + */ >>>> +static ssize_t reacting_on_read_data(struct file *filp, >>>> + char __user *user_buf, >>>> + size_t count, loff_t *ppos) >>>> +{ >>>> + char *buff; >>>> + >>>> + mutex_lock(&rv_interface_lock); >>>> + buff = reacting_on ? "1\n" : "0\n"; >>>> + mutex_unlock(&rv_interface_lock); >>> Again, no need for the locks, but perhaps just to keep things sane: >>> >>> buf = READ_ONCE(reacting_on) ? "1\n" : "0\n"; >> >> So, for all files that only read/write a single variable, use READ_ONCE/WRITE_ONCE without >> locks? (and in all usage of that variable too). > > Only if there's no races. > > That is, taking the locks here provide no benefit over a READ_ONCE(). > > If there was some logic that checks if the value is still valid or not, > then that would be a different story. > > For example: > > static int enable_monitor(struct rv_monitor_def *mdef) > { > int retval; > > if (!mdef->monitor->enabled) { > retval = mdef->monitor->enable(); > if (retval) > return retval; > } > > mdef->monitor->enabled = 1; > > return 0; > } > > That has logic that looks to require a lock to protect things from changing > from underneath. ack, so the only variable I see we can use READ_ONCE/WRITE_ONCE is the reacting_on... -- Daniel > > -- Steve