From patchwork Fri Feb 23 01:33:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 205174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp324850dyb; Thu, 22 Feb 2024 17:32:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7pQ34tKGwHa8hfKqjd5iiqoEjChfgN2983ej5C0nem2rAIpnVZ5fRKL5hR+VGcKBA0nN3hk6/h9OxxxqImfXa76PV7w== X-Google-Smtp-Source: AGHT+IFllkH5qx3367Wsv3yZ6iQwMOKgFfsgbvgHNZ2hgStuB7r70mQ2M2I66v8z/wsx4a8+qkgZ X-Received: by 2002:ae9:e407:0:b0:785:d3e7:3b2 with SMTP id q7-20020ae9e407000000b00785d3e703b2mr767597qkc.24.1708651963698; Thu, 22 Feb 2024 17:32:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708651963; cv=pass; d=google.com; s=arc-20160816; b=Paf61AMlT04nN5O7NptngobA09fGfqnlbxDRK1z1FLand/09F6NZMjrk65Ze23efZR A74fVCuwcgN/vrD1HJf9g1xe0qCTPJojaAvSrfvZypOIxgJ7TS1l7wc2fsiKApHqXJXO Q8FmLxRl+UalGhRog4Rt/KKAWV8ju0ArQUWwptIrLAnWIosmZ5EN8mxbMg5oCb1aFQ1O p2i1GDG8KdfJ69swGywMtmngjho5Zp0ai95mhsXqfrGVMgdej2v9ewxJeLn5XBLRN6Id g4+9/JkjLmSp3Ksmwf9BDP5CWxK6f6gMx/SHCI7AItUloj1u8zfwPGj/fphE3BmIev9q XrTw== 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=DgyNBhv9go7d2AQN9Qu1JPjxec4gStJBIjs3HgocguY=; fh=TdZ0M6+ZhUU2JkCc5zvDTA1ryfZXsigMobkRM04iH2Q=; b=ymsFH2QbTyWXtSaTFL8bMHvSVTYXoZrxWisb1ZvmTzOz5nrO2SxiLftOiNrUiYqdz2 Y9uVJYTIjXpeloMN7/Zhmwc5k0UNY8qA9pbwBmUrgAq57GFbz86WZfmyt445SOIuWmRC WAlD8WKojuwW7eo5NQ+7ncG4QHvToghWxqTxtYW0ZRu8UxxniSkNtBsh3QFOKODPu19w CODtynDJjX365btdFylDvHlXuqauL4Z+dgqWfTVODOhZAZvXFQQAoelGEDPLLi5PxtTZ PORQh0Wcj3JGN4I9gbodule/BqZQZs9nHiWsnvKRBfa5Be9h0YHe0aaOrot56i2AG7SU FV1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-77628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77628-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i5-20020a37c205000000b00787324e97eesi14243727qkm.661.2024.02.22.17.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:32:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-77628-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77628-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7CA6A1C21D1D for ; Fri, 23 Feb 2024 01:32:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0729BD26B; Fri, 23 Feb 2024 01:31:55 +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 7AA482C9E; Fri, 23 Feb 2024 01:31:53 +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=1708651913; cv=none; b=NVWNr7TBS7cuB1UlCsMQlKomQd+6B7uRMXdXELEmQGoLPNXHtm7p5ZbV6fQrUnVzwZ2gExHoTvr5vroW5SHuW1lOKjsm4HbN+ADiepkPZGOvNOJd2yynZzhR21OIIUzx2JdIAyJDislNxzMZIODo6r9YUBSM5g0OQ7+Ov2+rZM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708651913; c=relaxed/simple; bh=4NKBpeaolII1sBupq/IxTuoIHTKsguTYUdtlaE5KXXQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=WHPhmHMCVUaFXBdBSoW9KAK31QxLqpAQrqw1tX4C4Am8PqDxEwCEQihhBhbnS+AcPS0LBvRXtCkG//weOW7/zNEut5UDscK7K8noIptkO3mMKn0uHDoTi396D2hoStWL8qXQu+ri6rb2giGji2+fUYi6mNed/YCGK9MqG2kWvKs= 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 24CF8C43390; Fri, 23 Feb 2024 01:31:53 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rdKRc-00000006ogb-3daK; Thu, 22 Feb 2024 20:33:44 -0500 Message-ID: <20240223013344.729055907@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 22 Feb 2024 20:33:25 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [PATCH 2/2] tracing: Decrement the snapshot if the snapshot trigger fails to register References: <20240223013323.798805901@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: 1791651441218936041 X-GMAIL-MSGID: 1791651441218936041 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. 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,