Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3956581pxk; Tue, 22 Sep 2020 07:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGW+QWKDhJwYn05Mo0O1/uSIOJo5fEkeQw6UQ2ptBwYuY3UPqjZ/7xN2hVYVVjrAG8TCuX X-Received: by 2002:a17:906:3759:: with SMTP id e25mr4966196ejc.281.1600783388975; Tue, 22 Sep 2020 07:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600783388; cv=none; d=google.com; s=arc-20160816; b=R4pQiMa1PgyrapKT8PUDBHC0s6Kw6JvxW1g3FXGO7LCiWpnAZg8gq+gi7HAxXMsvA0 S392QbVGHCNqXz4953YsHDXMdA2aYkVMGoKkFoutnU1h0JDYZMtVqDbdMjJLzlKUBBsi sDO63JW4AsOVbQFpTFrLjSmLwwX9RmXbmOdUDdr6DzKssNvWwK4a2zelAl/syCv2pNE2 GR7xAgr0I7TtMtxRl+SLJz0fm5zlJx6XAN72uhLkhmtZutLq+ZnkYQtcOmWwH8xzV7IT 17Nxyb84cMkvw2OswjRWx/JjmOrVgNphlBmVSS7ya6qW/nV/ol3kM9LTiIU8HNw9yo7X Lpjw== 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=vC/zz58DTwojXk54i0uscO++Fw7Knq3SBGPFjdK5caM=; b=jCK6zPsdYOtSHHCUjSbgg9tq+Fl57OHDpQytBR016RxFpt7gWydkE+G107WWmM3VzQ HEMFKsE5LRpoIrsbrwmTm0DHBljTQ1FGZ67Bn1s+hG0EkAEkDE3CXYuxR/2V4MyEYGWn COJPMFmMiwrTl07lhX6aW7YH7u9VT5H0KCbCvMbkd/oLeCQA4oEqV7dn003EDlmoPtk1 wVeA4opOovI2RaeQt+8UIB8lLDkG0JxodtVq1GSBp209loOnX9ZVM7GKVaWZETvCXGe/ +9YY1yEDwtl3FbxpOj5Re/uXUkoK87ZVPOfaTGs3PSQZ32hrr6Fd7ayDkGkX5EvCQJKv xJ7w== 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 d21si10492570edn.173.2020.09.22.07.02.44; Tue, 22 Sep 2020 07:03:08 -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 S1726753AbgIVOA2 (ORCPT + 99 others); Tue, 22 Sep 2020 10:00:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:47306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbgIVOA1 (ORCPT ); Tue, 22 Sep 2020 10:00:27 -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 D8A2C20719; Tue, 22 Sep 2020 14:00:26 +0000 (UTC) Date: Tue, 22 Sep 2020 10:00:25 -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: <20200922100025.5c57f490@gandalf.local.home> In-Reply-To: <17b53f76-fa90-0086-8a9e-de166b789e60@codeaurora.org> References: <1599199797-25978-1-git-send-email-gkohli@codeaurora.org> <2fe2a843-e2b5-acf8-22e4-7231d24a9382@codeaurora.org> <20200915092353.5b805468@gandalf.local.home> <08d6f338-3be3-c5a2-ba4b-0116de9672c2@codeaurora.org> <20200915141304.41fa7c30@gandalf.local.home> <17b53f76-fa90-0086-8a9e-de166b789e60@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for not replying sooner, my email is still rather full from my 10 day vacation, and I'm still in "skimming" mode at looking at it. On Wed, 16 Sep 2020 12:02:46 +0530 Gaurav Kohli wrote: > >> Yes, got your point. then we can avoid export. Actually we are seeing > >> issue in older kernel like 4.19/4.14/5.4 and there below patch was not > >> present in stable branches: > >> > >> ommit b23d7a5f4a07 ("ring-buffer: speed up buffer resets by > >> > avoiding synchronize_rcu for each CPU") > > > > If you mark this patch for stable, you can add: > > > > Depends-on: b23d7a5f4a07 ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU") > > > > Thanks Steven, Yes this needs to be back ported. I have tried this in > 5.4 but this need more patches like > 13292494379f92f532de71b31a54018336adc589 > tracing: Make struct ring_buffer less ambiguous No, that is not needed. That's just a trivial renaming of structures. Use the old structure. Dependency is if the algorithm depends on the change. Not cosmetic. > > Instead of protecting all reset, can we do it individually like below: > > > +++ b/kernel/trace/ring_buffer.c > @@ -4838,7 +4838,9 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer) > static void reset_disabled_cpu_buffer(struct ring_buffer_per_cpu > *cpu_buffer) > { > unsigned long flags; > + struct trace_buffer *buffer = cpu_buffer->buffer; > > + mutex_lock(&buffer->mutex); > raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); > > if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing))) > @@ -4852,6 +4854,7 @@ static void reset_disabled_cpu_buffer(struct > ring_buffer_per_cpu *cpu_buffer) > > out: > raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); > + mutex_unlock(&buffer->mutex); > } > > Please let me know, if above looks good, we will do testing with this. > And this we can directly use in older kernel as well in > ring_buffer_reset_cpu. No that will not work. You need the lock around the disabling of the buffers and the synchronizing with RCU. -- Steve