From patchwork Mon Nov 27 15:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Pavlu X-Patchwork-Id: 170223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3200572vqx; Mon, 27 Nov 2023 07:13:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfVo/TpoixpDANwvvnixAmVZIW+td0bJIwTHaHJlBiXvalaIMN82Th+eHXMn+qz9/tfZUQ X-Received: by 2002:a05:6870:6122:b0:1f9:34a6:4e3a with SMTP id s34-20020a056870612200b001f934a64e3amr13455292oae.43.1701098001596; Mon, 27 Nov 2023 07:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701098001; cv=none; d=google.com; s=arc-20160816; b=yKX5Xhfbo/cVRUeVbGkoRFMFEkM8uJBbFogjJ/idVlRCztmF/LN5EYwr3GkmIDiTzE shVYFPVa63wgnfGXIbkngWN628gikjXhcFiSIT/FA8cIiZYb2fBMUlcx2z3fY481lMXJ 5otDsdZCF8KDY6wjVwZq37R1+K3T1f1LJ97/rO+fD++xXjvEn5UyaHZ1djup89oUEOsl kbfMENKlVwa2CSdKTqbb8GwoG71sh7QblBCRRRmeaVMVHIx9RFSSwChqiGDsMjNSAkRP oFEG7Ss/E0s7yaCWUm+kIAaxToghhwDr+bshdineX5UXrnjuZimZ9vAJTq+vjRzZxFy1 iD7Q== 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:date:subject:cc:to:from; bh=CXyOdoLaM0cNkr48/3X3wBWfZcujNhtVPgm/7hewXHQ=; fh=j8Hw7lilfJM9L0BwDk5YbNksoIL60jpocmP7dOg/RPw=; b=GgN7rDgJX85XHiuo8NNdHwbrQ/6Vc/0P3QlVnTxQdgsK73knwK1Uc/GwH2mod/FR3J DKr4pS+g5zQSmTI6ODEcX5Bl0GnVDqe+eJvh1opBzl5t+6iz4GLJQLtnpyocPSBFzwR6 M8iXIcOL/YxzawXs4tQPJXG4ChjLOiQFZxzSIBU4jOEroQcvYKufwB8pPyYAfjtKaQda ch+svJAqmIUWXIgj7ADAMOFWBn8GIUJZRxbuuEDoIOkqJWqhiSv1WtA2N+GzL36iB22f x80GGnYd6EvASoK48QLXfOpeWdIcYLL9bH+CCRgbMQsnwlfolk/qBuC1q+oIiVDrleOa uChw== 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:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cv20-20020a056870c69400b001d66918a314si3857813oab.2.2023.11.27.07.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 07:13:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8DB9B80A054F; Mon, 27 Nov 2023 07:13:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233899AbjK0PNI (ORCPT + 99 others); Mon, 27 Nov 2023 10:13:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjK0PNE (ORCPT ); Mon, 27 Nov 2023 10:13:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 753B8BB; Mon, 27 Nov 2023 07:13:10 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 15E121FBDB; Mon, 27 Nov 2023 15:13:09 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E312C1367B; Mon, 27 Nov 2023 15:13:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id +IZ3NgSyZGXEPgAAD6G6ig (envelope-from ); Mon, 27 Nov 2023 15:13:08 +0000 From: Petr Pavlu To: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Cc: zhengyejian1@huawei.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH 2/2] tracing: Disable events in reverse order of their enable operation Date: Mon, 27 Nov 2023 16:12:48 +0100 Message-Id: <20231127151248.7232-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231127151248.7232-1-petr.pavlu@suse.com> References: <20231127151248.7232-1-petr.pavlu@suse.com> MIME-Version: 1.0 X-Spamd-Bar: +++++++++++++++ X-Spam-Score: 15.00 X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out2.suse.de; dkim=none; spf=fail (smtp-out2.suse.de: domain of petr.pavlu@suse.com does not designate 2a07:de40:b281:104:10:150:64:97 as permitted sender) smtp.mailfrom=petr.pavlu@suse.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=suse.com (policy=quarantine) X-Rspamd-Queue-Id: 15E121FBDB X-Spamd-Result: default: False [15.00 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.19)[-0.948]; RCPT_COUNT_SEVEN(0.00)[7]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; R_SPF_FAIL(1.00)[-all]; FROM_HAS_DN(0.00)[]; DMARC_POLICY_QUARANTINE(1.50)[suse.com : No valid SPF, No valid DKIM,quarantine]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam: Yes X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 27 Nov 2023 07:13:20 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783730538004921520 X-GMAIL-MSGID: 1783730538004921520 Make the disable operation in __ftrace_event_enable_disable() use the reverse order of the respective enable operation. This has two minor benefits: * Disabling of buffered events via trace_buffered_event_disable() is done after unregistering the trace event. It closes a small window where an event would be still registered and could be hit, but would unnecessarily go directly to a ring buffer. * The SOFT_DISABLED flag is now consistently set only when SOFT_MODE is also set. Signed-off-by: Petr Pavlu --- kernel/trace/trace_events.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index f29e815ca5b2..5f14d68a0ced 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -633,9 +633,6 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file, if (atomic_dec_return(&file->sm_ref) > 0) break; disable = file->flags & EVENT_FILE_FL_SOFT_DISABLED; - clear_bit(EVENT_FILE_FL_SOFT_MODE_BIT, &file->flags); - /* Disable use of trace_buffered_event */ - trace_buffered_event_disable(); } else disable = !(file->flags & EVENT_FILE_FL_SOFT_MODE); @@ -653,11 +650,17 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file, call->class->reg(call, TRACE_REG_UNREGISTER, file); } - /* If in SOFT_MODE, just set the SOFT_DISABLE_BIT, else clear it */ - if (file->flags & EVENT_FILE_FL_SOFT_MODE) - set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags); - else + + if (soft_disable) { + /* Complete going out of SOFT_MODE */ clear_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags); + clear_bit(EVENT_FILE_FL_SOFT_MODE_BIT, &file->flags); + /* Disable use of trace_buffered_event */ + trace_buffered_event_disable(); + } else if (file->flags & EVENT_FILE_FL_SOFT_MODE) { + /* If in SOFT_MODE, just set the SOFT_DISABLE_BIT */ + set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags); + } break; case 1: /*