From patchwork Fri Feb 23 14:18:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp614021dyb; Fri, 23 Feb 2024 06:19:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTD//p3S2AhWhDkkGr3EnEm0lLyAaOMXuF408qwfcqyL6qiD0qCayrkhWa2Ks4rGZ4ge90hUJnthO3OHzNL0Ba6xL2+g== X-Google-Smtp-Source: AGHT+IFPkH/t5fFMmwXA1ciVskRd6zVGVqIy5aUaiVN2+ezZEDSYSm0syNNtjNLLCQjtuqup5mR7 X-Received: by 2002:a17:907:11c5:b0:a3f:899e:d3ac with SMTP id va5-20020a17090711c500b00a3f899ed3acmr1718128ejb.35.1708697976992; Fri, 23 Feb 2024 06:19:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697976; cv=pass; d=google.com; s=arc-20160816; b=NftdQ1fSYmBGi5hxOoAhqIcpETQpIwqLe1QhFzxELEePrVwPlM7QMTznW92k2GZg4k V0iHvd4qUfRgL5ox0K0ckNLUSk/e7xA6SnxcCZ3shF2TbNmJJtfQjWBI0GcHnMS/gxiI gFTIZsDjI4QkX+4gsbPWcln2yM6RLwITpG3T4kD0iBOJLaBUcimW0BNeYjOB+PVpx2VI BK3emgnt+0g1Ng3iw+Z3CmpVsJaslMLJNKlXUM+UgxQSsmFefOTc8aDvWUlX2tKL4PnQ kMWFBGEgp6EyyWIWBGVJZK8bclltuuau5XLte/qWMo4q64IuSIWZzKpLFCRk1xW9VyI+ iJyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=Avh3Zc7WmUFnbevKbWbs7HS2av1/iPL8wft2PicSXI8=; fh=5BBsyHlB8a39iZRylNlRwq68Y8N1HTURv9NhE+MQefE=; b=m+cH9ho9YiuZGZty8rUTGkfjEnT8MV8HX6E4k0+U1rcBm8M8poZ399VgVNtzaxnuhp s5EkymDGnYAprcqthCuCi7vFuHECXGlLP2xKX+4KbeGO8GPLMhBgwBrlNBFCDveawsBc JPhwYUmDZ0oTNZd82XjVNTQWPCJhV0OUjY8CXIcXBW+pAzJogprUMceGQhLaSF6SlG/Y Ier/mfyofJf5BKFJJBWaNlIZBk9ESzB6BMbZbPQlo6JUm9RlL8M8Fyo+eAgdPez+80MO c4V4T/9A02KX6f6r/JSMAv95skZPyI39U7opMpI/VldjSWgJVpbitpJHtiZj91ffTkXS k4vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r8-20020a170906548800b00a3ee04c0addsi3719248ejo.945.2024.02.23.06.19.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78466-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9ADC01F241EA for ; Fri, 23 Feb 2024 14:19:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98FF08662B; Fri, 23 Feb 2024 14:17:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB59482868 for ; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; cv=none; b=DJR9dZsa2lDZT1wLEcfyYY4yTjELp0mgF4FUxiZTfCPUWtFRV+ndr9/Uzw+opFa1US3OU5zwGtVsImOcw2imt4vwY+JfsQSa1+V7Ufeq31eNZ/W9g1ZPkiukEAIbHsVN85CJliDANw7I5sVwwIxVgiw2bVWb/P175gZilM80Btg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697830; c=relaxed/simple; bh=ZgqLTdRoUVgbCvGQljZzqd+I5mUdqZPv5Wp0Z7wOMSk=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=j8JK/MMNZsoItuD/rdXWUCWL5FSyKo0hqV9mEgaOXXpfDxRm1cEeDPfhUcesPjXPVeKwKdhyUHwGk/7rj0z5w06p6DWvGEg4ulgwtqldZUKad2MIjWddL07khjvVPPgXHyJi9bW7LcjRl9JQ6DehQ1htYtT+CAQc0cCX6RNAyrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A65B5C43390; Fri, 23 Feb 2024 14:17:10 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdWOF-000000077RA-2jRW; Fri, 23 Feb 2024 09:19:03 -0500 Message-ID: <20240223141903.512514224@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 23 Feb 2024 09:18:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-next][PATCH 13/13] tracing: Decrement the snapshot if the snapshot trigger fails to register References: <20240223141838.985298316@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791699690226442675 X-GMAIL-MSGID: 1791699690226442675 From: "Steven Rostedt (Google)" Running the ftrace selftests caused the ring buffer mapping test to fail. Investigating, I found that the snapshot counter would be incremented every time a snapshot trigger was added, even if that snapshot trigger failed. # cd /sys/kernel/tracing # echo "snapshot" > events/sched/sched_process_fork/trigger # echo "snapshot" > events/sched/sched_process_fork/trigger -bash: echo: write error: File exists That second one that fails increments the snapshot counter but doesn't decrement it. It needs to be decremented when the snapshot fails. Link: https://lore.kernel.org/linux-trace-kernel/20240223013344.729055907@goodmis.org Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Vincent Donnefort Fixes: 16f7e48ffc53a ("tracing: Add snapshot refcount") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_trigger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index 62e4f58b8671..4bec043c8690 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1491,7 +1491,10 @@ register_snapshot_trigger(char *glob, if (ret < 0) return ret; - return register_trigger(glob, data, file); + ret = register_trigger(glob, data, file); + if (ret < 0) + tracing_disarm_snapshot(file->tr); + return ret; } static void unregister_snapshot_trigger(char *glob,