From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A351338A728 for ; Wed, 15 Jul 2026 03:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784085185; cv=none; b=YAcK4EFgOkm+jcJZIdjUpkDI7f0UVDZ2H/qF+D+7ou4fKKE3JJXkf3spkFKp0gy/4rjU9ym2N+Bp2gftyDZjsiwTSQNVN9TaCQbS/k8oHUt6Y/BFo7AyZsYjWXvL8W9UKA2pdGuYeDFFHzCgUONP0Q1QC8NFsmIl5r1Jub/2QxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784085185; c=relaxed/simple; bh=7e+9Wp0EE/Prg9yOvSXbuLFhvaCFKgb77Cj+Z1NHugk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=etmHhSvlUsvDHrM7MY/IgUL60OTv5B9wlZces3l4FxJo5PFyNMewat32/ZiObiYtczzToSatcUATqAzedxbvdp5G0kkhXj7+oLLAcULmNaZ92J3UhWGXKV+rxU+SDpsN/5a7BAOBhtJIPQvWqy5NAV2ppGI5MAupFyJFwPQxe5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=msuBJZM5; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="msuBJZM5" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-84a4d8fd6ecso1538756b3a.1 for ; Tue, 14 Jul 2026 20:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784085183; x=1784689983; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=7e+9Wp0EE/Prg9yOvSXbuLFhvaCFKgb77Cj+Z1NHugk=; b=msuBJZM5rQ+gE/U+lEiGH5tJFAQKqYh+bC6LQ3EmAgl4YIMylc+VMfrCNK824vAkYn XANLqRh1fvOsO2lHbLw61hjwVXXwkcsjkD+3AyO3tOz0frovp+ArQJRm7u4EZmcDh1i8 CBb7WQIC56En3NkEEpJsWJAdmMBJq+S3HnGb6fRQ3clWvG51IxJqhDUJl7mUTSI9MYrx I7ni4EBv1GoaKyoyGiErSJ7JNL2UblZHCcAZtVloIG7wzPV0d6LgwpIkc+wiPNsKh2e2 TAGZEA+VB40fB4sb3nZTB0SWBSsl30eqGwbSA155rgATHEWKz8fiebEVVtxCXEM315SE a4nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784085183; x=1784689983; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7e+9Wp0EE/Prg9yOvSXbuLFhvaCFKgb77Cj+Z1NHugk=; b=YQd3w3rIVKeOjc2XTpTlB/MV5oMofJFtmMqlhfln3rDetb4JMls37BFOfZRvPDM3/4 boSgSr9zCSRYNlQ8rcEU/5iEEvFPhiFFvkTLjCj59dwMqZrrp3PHsyzqtW5NbrZ5eywA beOIiT5QVLjsQLiuaU1r5msfnamdJXM4cbpP2HVAuxcHBtqZP9otTiQbANw9PvheRGVf hv48T3sEQNWnX7Wf0yNa4JW0mRZAjgFK1f15GUsAWFEpAfiC5FD6tMBnFO4YYLh4mgN+ XjKD+02uc4O0COjskMDpemxpEimJEzJAhfzBYfUQV2DrKUKhnLPl0SOcW1jcfcd2UIIP nRxw== X-Forwarded-Encrypted: i=1; AHgh+RrFPDw9j8fLteRexXHb8vcAFuyWBQpeC3R/nRBkEZe3GcvFcZYgwvFHAPz34StvrdmneFgliFzOn8qgIcc=@vger.kernel.org X-Gm-Message-State: AOJu0YxjoOwBZVB0I71730CB6WkLhxz/HB4hFiouqXOLKXRyEfFTswaI WD5bdxpImkAgKhnhBN5Bie/OtzoYECU72wrmkwBfPNYMWGP/ZgciHO70mNkxdQ== X-Gm-Gg: AfdE7ck6DijKtQ64zSYgKPYHKdxTS2AAAEpkEb4pfPSCfA5OIGy8VOuPNDhuZ542fQQ XuHf78PugwGn3LvmCZJAxR4yxVSdn+eUtAaCIxVxJKykKYE0ZQlWNpykiATI0JpAjSl83DqCROd Fl33RoD3myYQNptjQGhX2XCORn8Lw0WaVtCoZNZneamvuCIXFSVfit9c8ld9sS73gwlWIuI65Ux IJfzX7Psq9pmkQdiLZ7HmhRsQZXc82OZNiq5XlpvIzY+R35MnTgCCFqK7Hs/ByVVemDgkLIwDF+ 8phjVIFdOu/zQL/aWG3ALYvB8u4mBmdYsONeb1gTWtIQuLILOBeVAH1U4wgQknpEO8fZ1SUPyVl Avjfp8TxCKxzTwXQg6h6bAFXfA/zLtgwksVs4MoZImvjZwmVmnHjT6SIBGH8qXQh+PGpIJ52QgO 4CdUfE10KRrTRY3UKCiuS/oPQjfPPtIGeA12xkSxBKJYiCVMapIMth X-Received: by 2002:a05:6a00:987:b0:848:2f84:f427 with SMTP id d2e1a72fcca58-84a6736d4d0mr897505b3a.64.1784085182776; Tue, 14 Jul 2026 20:13:02 -0700 (PDT) Received: from lipengfei28-ThinkStation-P368.mioffice.cn ([2408:8607:1b00:8:d1d2:d044:5a81:884]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84a4f818eaesm2347110b3a.58.2026.07.14.20.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 20:13:02 -0700 (PDT) From: Li Pengfei X-Google-Original-From: Li Pengfei To: rostedt@goodmis.org, mhiramat@kernel.org Cc: mathieu.desnoyers@efficios.com, mark.rutland@arm.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, zhangbo56@xiaomi.com, lipengfei28@xiaomi.com Subject: Re: [RFC PATCH v4 1/3] trace: add lock-free stackmap for stack trace deduplication Date: Wed, 15 Jul 2026 11:12:45 +0800 Message-Id: <20260715031245.2571869-1-lipengfei28@xiaomi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260714171144.4537f163@gandalf.local.home> References: <20260616064119.438063-1-lipengfei28@xiaomi.com> <20260616064119.438063-2-lipengfei28@xiaomi.com> <20260714171144.4537f163@gandalf.local.home> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Pengfei Li On Tue, 14 Jul 2026 17:11:44 -0400 Steven Rostedt wrote: > smap->entries = vcalloc(smap->map_size, sizeof(*smap->entries)); > Make the error paths have: ... goto fail; ... Will switch both entries and elts to vcalloc(), and collapse the error paths into a single goto-fail ladder (freeing in reverse alloc order, including the drops percpu). > Do not add anonymous blocks in functions. Will move the cpu declaration to the top of ftrace_stackmap_reset(). > Really should have ftrace_stackmap_bin_entry have a flexible > array: u64 ips[]; Agreed - will add the u64 ips[] flexible member and use struct_size(e, ips, nr) in stackmap_bin_open(). On-disk layout is unchanged, so the bin format stays compatible. I'll also fold in two issues I found locally: a missing lock on one init failure path, and TRACE_STACK_ID not being handled in the function_graph output (it falls through to print_graph_comment() instead of being punted like TRACE_STACK). One design point I'd like your steer on before respinning: reset checks tracer_tracing_is_on() once under trace_types_lock, but traceon triggers (ftrace_traceon / traceon_trigger) can re-enable tracing without that lock during reset's clear phase. As far as I can tell this is a semantic-contract issue, not a memory-safety one: the map is protected by the resetting flag (get_id bails with -EINVAL and synchronize_rcu() drains in-flight callers), and the ring buffer pages aren't freed by reset, so the worst case is a non-empty / inconsistent buffer after reset rather than corruption. So I'm leaning toward documenting reset as best-effort ("stop tracing, including traceon triggers, before reset") rather than adding machinery to block the window. Does that match your view, or is there a ring-buffer-state hazard I'm missing that would justify blocking it explicitly? On the element pool: your `-l '*lock*'` run is a good illustration - the ~326K-line stack_map dump is the 16K-entry pool (bits=14) filling up quickly under broad function tracing. I'm leaning toward keeping eager allocation for v5 (it keeps the hot path free of an allocation-failure path), but I'm happy to switch to lazy allocation on the first 'echo 1 > options/stackmap' if you'd rather not pay the ~8MB resident cost when the option is never enabled. I'd keep the stack_map_bin interface as-is. Thanks, Pengfei