Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6310047rwd; Mon, 5 Jun 2023 16:44:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77axXLaog1r99foGJ7Yi7i+FQJFPyzCd5aS2TTphHNqwrNm+y2Tn/F92QZut+be1x9SDt5 X-Received: by 2002:aca:1a16:0:b0:399:6025:e285 with SMTP id a22-20020aca1a16000000b003996025e285mr196070oia.15.1686008666773; Mon, 05 Jun 2023 16:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686008666; cv=none; d=google.com; s=arc-20160816; b=byiGD1ORhGr6yMqvhKMsGL4CXKL1NE6KatV3H+pdAtdHWjV88tZcSV3IgYjGGNNk57 bvXB9Mw63CnOt9g1it2Pb9x0jCvsnw97ltfLAZ17PDcB9y9qT1k2SyDZySErY+At/DDY gmWZ02V+zpPABg+o371PMICE1P4KNWrQbHhXIqDNLZUFd5wUdIGpkTnsHUThbdRHyKEZ qUZpHUpm7nUVhmnpP7WGCKXO7yVOgxiQNRbKm5vLue2iQdKNQI/fAYjsZtjHXwCcA/YF lGXXbSttRlPHloivNGvbo30NzwsqbFlGuLPai+ch90amS8unuD0A6rZ85AlM40WcoA+P q8KA== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=XzX7ITQkM5lWu0oiVxpi9qKnO2wt1KN1RLZR3+vQCBE=; b=xh3Zj7xHaGV/IBNOmuvvNLSaxAYMX1CuA8T4fOwLSfmGnAFWLww57wY90hr7Xf8aCd 5GuR+MN5JGKGjuNF+eEcI/jeVon8at3cB82aY0EmS/7ImNTPNPA6uu/4bgvQ2R+EJMQ1 4uh5F/R9C63z7B09T+g3jTsHg3fW9mxjfH9Wi+IrnRp8udg4XnajGa7H+NNFaKShPMS3 +YYTcgGDdzqQwb6PYNH0EbZSiOh2gRuNr3D8cyLMVj1uALC6T8RhnVKwMk3mqVQZfnys YqI9DmfkvNa3p1PLQLVaLuAsN6n0vJbz8bVB7AGt8XPwnEj1a9A+mtolt63iT3/RcADp 5jyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cogwOR14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv128-20020a632e86000000b0050fb1a00d3dsi6188923pgb.46.2023.06.05.16.44.14; Mon, 05 Jun 2023 16:44:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cogwOR14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233491AbjFEXjI (ORCPT + 99 others); Mon, 5 Jun 2023 19:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231521AbjFEXjH (ORCPT ); Mon, 5 Jun 2023 19:39:07 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2BF4EEC; Mon, 5 Jun 2023 16:39:06 -0700 (PDT) Received: from W11-BEAU-MD.localdomain (unknown [76.135.27.212]) by linux.microsoft.com (Postfix) with ESMTPSA id 805D920BCFCC; Mon, 5 Jun 2023 16:39:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 805D920BCFCC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1686008345; bh=XzX7ITQkM5lWu0oiVxpi9qKnO2wt1KN1RLZR3+vQCBE=; h=From:To:Cc:Subject:Date:From; b=cogwOR14b8hXXIbEZpXxHcFvlr5T3j3pGMnzlfrb6PPpKbKRvSY4bmJwvaGq9HBtr SRG2hymw2RwFrZEZ73P1mrVt286Niz6a8Nji9YRJe6omdCLP1ieOrx4UHUW5ngRmRZ CboSKcovydaXyjYuHPQnfftQato3yM9l5gGjLrXM= From: Beau Belgrave To: rostedt@goodmis.org, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ast@kernel.org, dcook@linux.microsoft.com Subject: [PATCH v2 0/5] tracing/user_events: Add auto cleanup and a flag to persist events Date: Mon, 5 Jun 2023 16:38:55 -0700 Message-Id: <20230605233900.2838-1-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 As part of the discussions for user_events aligning to be used with eBPF it became clear [1] we needed a way to delete events without having to rely upon the delete IOCTL. Steven suggested that we simply have an owner for the event, however, the event can be held by more than just the first register FD, such as perf/ftrace or additional registers. In order to handle all those cases, we must only delete after all references are gone from both user and kernel space. This series adds a new register flag, USER_EVENT_REG_PERSIST, which causes the event to not delete itself upon the last put reference. We cannot fully drop the delete IOCTL, since we still want to enable events to be registered early via dynamic_events and persist. Events that do not use this new flag are auto-cleaned up upon no longer being used. NOTE: I'll need to merge this work once we take these [2] [3] patches into for-next. I'm happy to do so once they land there. 1: https://lore.kernel.org/linux-trace-kernel/20230518093600.3f119d68@rorschach.local.home/ 2: https://lore.kernel.org/linux-trace-kernel/20230529032100.286534-1-sunliming@kylinos.cn/ 3: https://lore.kernel.org/linux-trace-kernel/20230519230741.669-1-beaub@linux.microsoft.com/ Change history v2: Renamed series to "Add auto cleanup and a flag to persist events" Changed auto-delete to be default behavior, with new flag to persist events Beau Belgrave (5): tracing/user_events: Store register flags on events tracing/user_events: Track refcount consistently via put/get tracing/user_events: Add auto cleanup and a flag to persist events tracing/user_events: Add self-test for persist flag tracing/user_events: Add persist flag documentation Documentation/trace/user_events.rst | 21 +- include/uapi/linux/user_events.h | 10 +- kernel/trace/trace_events_user.c | 184 ++++++++++++++---- .../testing/selftests/user_events/abi_test.c | 144 +++++++++++++- .../selftests/user_events/ftrace_test.c | 1 + 5 files changed, 309 insertions(+), 51 deletions(-) base-commit: 3862f86c1529fa0016de6344eb974877b4cd3838 -- 2.25.1