Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp55831pxk; Tue, 15 Sep 2020 17:39:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrXFfBzZH8WKPD8fTr4yGd7+6P4DRYmuN0NrAk5cAN5XngiIozVcfyo1KI1PFj47a3skyn X-Received: by 2002:a17:906:7695:: with SMTP id o21mr19771738ejm.176.1600216763196; Tue, 15 Sep 2020 17:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600216763; cv=none; d=google.com; s=arc-20160816; b=pNI/iugm2ole4rKgKnSXC9RdfngwrVBdFx3eHQKCDdKJO7Wx6nTD/LHYPGwruZlGPI BiIQSLlZ/bZXK3Fvl76D3oSq7wqpnzkFEwfI0fBltg0U8RgCW+dldFuO0kXsWzwQEsuP qPeq+z0KbEzUzhdRNIlHS0FDSrrpDU8U+LAz1MwX2JH7n8lIxhKm6XNBhrUMqY0S+BFb fwgpL+o/z9M9HLoeTIbtX50mRUxzbTBXFwnMGsPBd1bj2eVzx8+jFWIbTue70DU7LeDJ TxOvXHp5h1vyLojU3twNxnIxVpE+sLPen+saYDLd4KprD5ajEyYun7dMDVKUlRIYrncH D0cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=wQxZ8KoNX+3q9wTqF1TFTmbGuJgQqagfXAJf6Kx40MY=; b=gfk7mZDd2/nD5UAXBu/tHMS+jrFnYJZkThSTcMFwI2Y6uAVowgME7/ZZKdbjcNfa7Y w8HI0F1fHFNAo17vXWpULyIhBAP0uUzJ92plbEspWnutL/G3QM3RrbTFUqXyXaBfgYAu 3mJJxGjSaBmCI0+Azuf/ZdW329cE+a7tR/o5e1Te8KC6q2gU31Qi55pxlFpfFhe8GEXP 4ip1A2FFjiIkBz/UnI1oHHCJKtWxnmmkJSZ7Jma211RKtW7kZk8fbLlGhg3mbzZzD6K3 Mxk5YjWnWSDTbWf7fq0itVj+PGhm+2s243YmKCrJg1p3tMMBviROyVK/aULFh/2Wwf4b G8gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jo4si10419264ejb.681.2020.09.15.17.39.00; Tue, 15 Sep 2020 17:39:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbgIPAhD (ORCPT + 99 others); Tue, 15 Sep 2020 20:37:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:40200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbgIONY7 (ORCPT ); Tue, 15 Sep 2020 09:24:59 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E37020684; Tue, 15 Sep 2020 13:23:54 +0000 (UTC) Date: Tue, 15 Sep 2020 09:23:53 -0400 From: Steven Rostedt To: Gaurav Kohli Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH] trace: Fix race in trace_open and buffer resize call Message-ID: <20200915092353.5b805468@gandalf.local.home> In-Reply-To: <2fe2a843-e2b5-acf8-22e4-7231d24a9382@codeaurora.org> References: <1599199797-25978-1-git-send-email-gkohli@codeaurora.org> <2fe2a843-e2b5-acf8-22e4-7231d24a9382@codeaurora.org> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Sep 2020 10:38:03 +0530 Gaurav Kohli wrote: > > >>> +void ring_buffer_mutex_release(struct trace_buffer *buffer) > >>> +{ > >>> + mutex_unlock(&buffer->mutex); > >>> +} > >>> +EXPORT_SYMBOL_GPL(ring_buffer_mutex_release); > > > > I really do not like to export these. > > > > Actually available reader lock is not helping > here(&cpu_buffer->reader_lock), So i took ring buffer mutex lock to > resolve this(this came on 4.19/5.4), in latest tip it is trace buffer > lock. Due to this i have exported api. I'm saying, why don't you take the buffer->mutex in the ring_buffer_reset_online_cpus() function? And remove all the protection in tracing_reset_online_cpus()? void tracing_reset_online_cpus(struct array_buffer *buf) { struct trace_buffer *buffer = buf->buffer; if (!buffer) return; buf->time_start = buffer_ftrace_now(buf, buf->cpu); ring_buffer_reset_online_cpus(buffer); } The reset_online_cpus() is already doing the synchronization, we don't need to do it twice. I believe commit b23d7a5f4a07 ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU") made the synchronization in tracing_reset_online_cpus() obsolete. -- Steve