Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1085083rdb; Fri, 1 Dec 2023 06:46:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1yy/gz7XFM7OoGh0QFu0Of/lJBSpRQsusujLo85E6T0Rbx6p/5oXQZ+/iGSs5MnKH7NYK X-Received: by 2002:a17:90b:3e8d:b0:285:93d4:16c with SMTP id rj13-20020a17090b3e8d00b0028593d4016cmr33590655pjb.20.1701441990217; Fri, 01 Dec 2023 06:46:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701441990; cv=none; d=google.com; s=arc-20160816; b=JOWRAkthMzL0BZ0EGZbnIUavdo/Nf34BUziJW6/RVvmKsPwKBcKJsNs8TFLY9PjiFN LiXTlTNa9TzkSln+8WIeS4VvCIUZNmX67WaTkozpQ2P2ev8de/Q3PGUnaHzVY+EOf2I2 RwZGLzkJapF6zJSV0nPC/2v8ItifY/KhNGGe3g6vzzqsP8j2uG05shLjETrlLY0v5SB3 bx3VkPs+508VUEyU3orrBQR2xErIvqokdTtMgf8b8zG1xmFFcoGeAW9BZk7gMryXDze1 1Pigl4p5by9ZKzUVwaF+RPQgjL6G5tRY+Z1JVajiYWoXTE3bZxUQxKA9JjYyhEQOBeSI R1Ww== 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=LWOJlJghd171aOiO3vnDASfsNBatPbzBKDkHHUgBAKQ=; fh=Y3gvkCYGIKm1p3xKiYKKjdPJzz3c7vS/1kHLUuaMIOs=; b=rLOnxY4jzM/CWL/JODzzMIBbUEXYFjIN769spV3AQymyOuZUGj6ASvL+EyZDxAIWxP +P7SNJPxTm+HksTaUP6U6wX5h5wu/i0uIC75jtTv11LFs6i+Mck2FdFT80IqtmO+qArA xOr7W42O/WGIzth54s36m7IikMBFDEyHSTA/QCkACcRf2qKxZ0gxXYumHAWPxEBIslcw fp3YuEJvOo9vCcEP/0xNHzPAGTQOHJSet4UVjJfL7Wk29D6/+fA8MK3V5EV4jDu5zoKw s9tTnc29PlNWmgHp38nCcZpu4CtlvxlXJM6T70FE0G0MOFDTh/qo4wtdLDA4WQ85BWgI DdIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u11-20020a170902e5cb00b001d0087bbf19si811799plf.440.2023.12.01.06.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 06:46:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6EBB18266486; Fri, 1 Dec 2023 06:46:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379227AbjLAOqM (ORCPT + 99 others); Fri, 1 Dec 2023 09:46:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379221AbjLAOqK (ORCPT ); Fri, 1 Dec 2023 09:46:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A37D6C for ; Fri, 1 Dec 2023 06:46:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA937C433C7; Fri, 1 Dec 2023 14:46:14 +0000 (UTC) Date: Fri, 1 Dec 2023 09:46:39 -0500 From: Steven Rostedt To: Petr Pavlu Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com, zhengyejian1@huawei.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] tracing: Simplify and fix "buffered event" synchronization Message-ID: <20231201094639.03a1913c@gandalf.local.home> In-Reply-To: References: <20231127151248.7232-1-petr.pavlu@suse.com> <20231127151248.7232-2-petr.pavlu@suse.com> <20231127124130.1041ffd4@gandalf.local.home> <77037ca1-8116-4bc6-b286-67059db0848e@suse.com> <20231128102748.23328618@gandalf.local.home> <20231129095826.1aec6381@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (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=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 01 Dec 2023 06:46:27 -0800 (PST) On Fri, 1 Dec 2023 15:17:35 +0100 Petr Pavlu wrote: > Ok, keeping the current approach, my plan for v2 is to prepare the > following patches: > > * Fix for the missing increment+decrement of trace_buffered_event_cnt > on the current CPU in trace_buffered_event_disable(). > > Replace smp_call_function_many() with on_each_cpu_mask() in > trace_buffered_event_disable(). The on_each_cpu_mask() function has > also an advantage that it itself disables preemption so doing that can > be then removed from trace_buffered_event_disable(). OK. > > * Fix the potential race between trace_buffered_event_enable() and > trace_event_buffer_lock_reserve() where the latter might already see > a valid trace_buffered_event pointer but not all initialization yet. > > I think this might be actually best to address by using the same > maintenance exclusion as is implemented in > trace_buffered_event_disable(). It would make both maintenance > operations consistent but for the cost of making the enable operation > somewhat slower. I wouldn't do them the same just to make them consistent. I think the smp_wmb() is sufficient. Don't you think? > > * Fix the WARN_ON_ONCE(!trace_buffered_event_ref) issued in > trace_buffered_event_disable() when trace_buffered_event_enable() > previously fails. > > Add a variable/flag tracking whether trace_buffered_event is currently > allocated and use that for driving if a new allocation needs to be > done when trace_buffered_event_enable() is called, or the buffers > should be really freed when trace_buffered_event_disable() is invoked. > > Not sure if the mentioned alternative of leaving trace_buffered_event > partially initialized on failure is preferred instead. I do not really have a preference for either solution. They both are bad if it happens ;-) > > * Fix the potential race between trace_buffered_event_disable() and > trace_event_buffer_lock_reserve() where the latter might still grab > a pointer from trace_buffered_event that is being freed. > > Replace smp_wmb() with synchronize_rcu() in > trace_buffered_event_disable(). Sounds good. Thanks! -- Steve