From patchwork Mon Jun 5 23:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 10326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3021606vqr; Mon, 5 Jun 2023 16:44:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YpBJMo1UWSK/XqI1h/wUedMBpkqfvX28rv6UgYLmVsCggeZqtRV+GoYfIe+xAm6uzL9t+ X-Received: by 2002:a17:90b:889:b0:253:38b7:682d with SMTP id bj9-20020a17090b088900b0025338b7682dmr83753pjb.18.1686008667221; Mon, 05 Jun 2023 16:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686008667; cv=none; d=google.com; s=arc-20160816; b=IjzrbMG0resJecjuekzMCwIiISRaD4gvOF4hbYTYR4Zb0/dEk6xHz+CYU1uqeSkEp3 ISVy/H47BXdZ+lxGSZYYRH7i17+WYcr9HEpjzZTnh5UH6qhk+BzcYvGcPs852WnUnboP PnfPWabx7ieRLQ6elRBqcC/jYBaXcHRKPUgcaoh9pfuVyq9+UVPGj84huTVkXZcFQti2 63RfE9Otni9BTY1qgccEkG5R/ccy5qWplHl3OGzBpsOJtw93Y7JZTLoT/gDhw7bR++in y64ZkMSTnuAifc+5tbELJc2BO1WDzTH5irRefGUrnQna2WPl7Bi23KidHmAdmDlabaGe um2w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a636e0e000000b00541bf36f2d2si6220013pgc.208.2023.06.05.16.44.14; Mon, 05 Jun 2023 16:44:27 -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 S233495AbjFEXjI (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767908224601295114?= X-GMAIL-MSGID: =?utf-8?q?1767908224601295114?= 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