Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5712825imw; Wed, 20 Jul 2022 10:55:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQUSJmf3UYPxu+JJxpyx7XAZ4R9SonHgjjkHXSJv8+CN0XgeV/dBLanNUvySdGKgOoTzQl X-Received: by 2002:a17:902:d890:b0:16c:abb4:94d0 with SMTP id b16-20020a170902d89000b0016cabb494d0mr35605782plz.50.1658339710096; Wed, 20 Jul 2022 10:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658339710; cv=none; d=google.com; s=arc-20160816; b=GGHrhCCnEQikPLKSFRKNyxgD/Prejto+aKNGAv/4Lo0WF1YgdVrnFMonQQlWbUmbYX n5RmdMA98Gpc4BsRJGE9R5HBIl7bFic16xf3Pbk7zJMc3ujPl8u8cqWxh0vKFHPi+3+S i2eIm/45z6NNCaERoLM/Wv78dnkwymqNP5ZrI3rj5yR165SZ4vyb6S9moqnBGOp1iCA5 V9eLfKFv/1oJEc/UPqsspnnKzhXwZ12ofAqVA2m7m3nmxzR4vySGP9pbSclx3/lUrbJ1 OeN25TUkYN9XWInw1/vAU30fmonFxshFMvTkoDeV48k0G28HKPD0rHEIdKkFGuTmCNvk y01w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=XJubqCGD9gK/VYr+oz8ViElPBy9ThtV4pYY4vzLfzsI=; b=KQ6rG5xVD3G7JiZT64c6zkR88LJnR3rQppCHkKw0Z0aHu6HWVGM11UYJuU+jApWbwh neD8kBzer8p+wH8qJkhXeHAdyKndQMZ+374K+P4XAJRpmCJDWKnLtHpAZ+h6wlD8BM5X N72kw6/v4chZpxGWAwH4vo50ByPGYE1/QIUWaS0bETtgoQc9KJTUOABfTkgtyWHAs/SN k8N7xI3k+elAvg++d70wW9IuWizOKJXksxfYEG2BfLIknFFByo5+kzI4gyJ8uyy1szL4 FVJE9KqxVXzlYhx1LsleT4EilTZKU/ai3dw9P5GkOsAfOP+k4R7+M4vbZseu+RL4fm/j FnKA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a170903234500b0016d26dc4eaesi2306864plh.450.2022.07.20.10.54.54; Wed, 20 Jul 2022 10:55:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbiGTRCS (ORCPT + 99 others); Wed, 20 Jul 2022 13:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbiGTRCR (ORCPT ); Wed, 20 Jul 2022 13:02:17 -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 560C96A9D6; Wed, 20 Jul 2022 10:02:16 -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 E5815B81FBC; Wed, 20 Jul 2022 17:02:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F86CC3411E; Wed, 20 Jul 2022 17:02:11 +0000 (UTC) Date: Wed, 20 Jul 2022 13:02:09 -0400 From: Steven Rostedt To: Daniel Bristot de Oliveira 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 Subject: Re: [PATCH V6 02/16] rv: Add runtime reactors interface Message-ID: <20220720130209.65f501b1@gandalf.local.home> In-Reply-To: References: <4b5f93e3186b067073c1692d4c2b50d0b42101d5.1658244826.git.bristot@kernel.org> <20220720124133.3cdd2c44@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 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. -- Steve