Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3157311pxk; Tue, 15 Sep 2020 11:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFiS0xBtDmmiZs6U/Lt0uZo4/Ii7V2e7QCrrb6EuGTcmhqejOWtp46ALFfsyr+3qDKI3hX X-Received: by 2002:aa7:d382:: with SMTP id x2mr24214012edq.108.1600194616283; Tue, 15 Sep 2020 11:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600194616; cv=none; d=google.com; s=arc-20160816; b=V/a12BkjBfJkNc7+72XYA7zRMIL9XkohhZ5kQVpiq1duZrbY9l74EIuz8BrR9HTMyq 7HUmmctcy+dPlBWYOC0XQcpqLIxuct8OX200fKPpqwTL62qZMqRmS2ZNuxN5LUFLLvla p6l8/KyjtKxFHg1C4JqiXKc7yliCsQERQnKBTKVIoaJdBv5VLWU3itrtpkQwzgN4Jrup yJLgoQbj7H4WreqCIqWILX/tbdBQabPaZK4vUDN7zZH49L11MJH0tnehdJlfwtPcnfqK nKeT975c/4lXjFuZLgCCP4IELlwrga+vzWwHRvdthirzbtHyC+2s2krrFnmoX9hqcaKZ co5g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=+V/gihI6IVhCmq8oIHKoVVe0UjgnCXljzyAeHnZMja4=; b=Wzb7tPN7hR7yv/tNXC5L7TxswsDODMXhOxXS85ARsSM5FnL2vogYZrXhLs1jq7MEvz 1ep6xL443bRWFab7Vh008NCxTbs8jLgTdnfeXDRwNOQ0P/WFTI1f99AYzYYl4H4tmqd2 cA2I35eTUWyZBnLV6jCqd67Cpb7sPPCDx6kTmJMW7gOvRk+PrpTSDJdg8RXFjnTcp4ei c3n1iqyMpIUuDvESnvpdlHO9uHIc0dBVtVV6/P1+/7QqU1F4mMhZNqCAkDY7s49O7q1L C8kq4BBzuPFCenQAWGpnGVev7SqJDA6Z8LZsZj1j/SsNGtpwWp8WKH6Uh5Dxc6fbmh2M HNkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=O3SyMAPT; 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 jp27si10224146ejb.668.2020.09.15.11.29.53; Tue, 15 Sep 2020 11:30:16 -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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=O3SyMAPT; 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 S1727732AbgIOSVf (ORCPT + 99 others); Tue, 15 Sep 2020 14:21:35 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:19854 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgIOSQg (ORCPT ); Tue, 15 Sep 2020 14:16:36 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600193794; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=+V/gihI6IVhCmq8oIHKoVVe0UjgnCXljzyAeHnZMja4=; b=O3SyMAPTAn5FUJq8TjG+IhM8M/vMKk1k2GNn+O2B+bAqZm7VLNXGkavXqK2H+j7MDkiW7wTP qf7rBV53iasgYeWIQ238zVJZGVkugSjQcXAOz4cybRAYEd0Ca5hwO9I+oDlNwqTe8zIuS0e/ plHdUfKs2lAOF/zSUKdcP3A5pjA= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-east-1.postgun.com with SMTP id 5f610266885efaea0ac14e5d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 15 Sep 2020 18:05:26 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 534D7C433C8; Tue, 15 Sep 2020 18:05:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.1.4] (unknown [122.175.29.203]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: gkohli) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3FC4EC433F1; Tue, 15 Sep 2020 18:05:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3FC4EC433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=gkohli@codeaurora.org Subject: Re: [PATCH] trace: Fix race in trace_open and buffer resize call To: Steven Rostedt Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <1599199797-25978-1-git-send-email-gkohli@codeaurora.org> <2fe2a843-e2b5-acf8-22e4-7231d24a9382@codeaurora.org> <20200915092353.5b805468@gandalf.local.home> From: Gaurav Kohli Message-ID: Date: Tue, 15 Sep 2020 23:35:13 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200915092353.5b805468@gandalf.local.home> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for spam, saw some failure so sending mail again. On 9/15/2020 6:53 PM, Steven Rostedt wrote: > 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()? 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 is not present in stable branches: ommit b23d7a5f4a07 ("ring-buffer: speed up buffer resets by > avoiding synchronize_rcu for each CPU") Actually i have also thought to take mutex lock in ring_buffer_reset_cpu while doing individual cpu reset, but this could cause another problem: Different cpu buffer may have different state, so i have taken lock 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 > Yes, with above patch no need to take lock in tracing_reset_online_cpus. -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.