Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp230733rdb; Thu, 2 Nov 2023 01:50:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPRmzurhAXCRVFG3U1nr6vPaMZHTTfIQK0JZ6pfeAkKYX2wHCgN1rkYX4bMg1bn1bFCfua X-Received: by 2002:a05:6a21:6d99:b0:f0:50c4:4c43 with SMTP id wl25-20020a056a216d9900b000f050c44c43mr11261972pzb.5.1698915027097; Thu, 02 Nov 2023 01:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698915027; cv=none; d=google.com; s=arc-20160816; b=s99/hzrEGewnEw1auQA5BQVcmXLv3z7MpAutO8gk35bim3ahGm1PuWRA26OMVMqwhN lvhENnGbHFPnUBzAHJRJFgs3VOqNoCciHTrmx/WEq2hKbsvBxrMqQNGFBWwdBngW5SWY HGsxTs+4MUVQAqxKvDqmiFJujK50KacwGwXFVXP3xpOKxaY6sz1VYzKUSAa9ekVU63SB kM8qvC3iOYPJPZCm1AURuNHiruegnqHtVf4k7OOBqIT4l+sN8PzRCSD513YUrxgt7hCo 4gladylie23gksN6pXJYL1QBBeCKScQpX52SPzf+z/y/6UyLvJh0PMjmlk5J2ghxg0rk Qfvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=yv7JujbLaP4o6hSsKOV57zb9TN8J85KbDLi3JdO3f/s=; fh=2Wsk0ngZY6Fk63x/GsU8yCyY+OK5kCxkA5Zezu9veRo=; b=TAFI1aNrpHjrBNDFBUumDjuJnQnzYWFAJpkk1Qgi7gzTDBKXPN86onchyXhXE3vsHi xMcBph6ktrcNneQiAGvWB06LxgApfh7VDfBPWMI/howzUxay4TaYi7JmOkTWuZjpP/ZJ zlLJBe5u+L4eN2orEnV5ySoO9Pay26XYWAkGuYdRdpdz2scxtVi1aNCEYuprjekYBbXi HCBbE7QTO+J/0+JQXQEi4iEu8sXyGnh6PBPLgK6Pt7Xjb65/FQY9pUqI2vzuKrMJ3H+W vTgBvllmN3CFi2sUPsM+OViJS0S3mNPsuIsfIzMPQCkmAGFd94A/vi5hDk1L3f7JJpAa d8KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EPhOH9fc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z25-20020a656119000000b00578b63123desi1438688pgu.789.2023.11.02.01.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 01:50:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EPhOH9fc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8EEBB8090E8B; Thu, 2 Nov 2023 01:50:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbjKBIuM (ORCPT + 99 others); Thu, 2 Nov 2023 04:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjKBIuL (ORCPT ); Thu, 2 Nov 2023 04:50:11 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01EC212C; Thu, 2 Nov 2023 01:50:09 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32fb190bf9bso24261f8f.1; Thu, 02 Nov 2023 01:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698915007; x=1699519807; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=yv7JujbLaP4o6hSsKOV57zb9TN8J85KbDLi3JdO3f/s=; b=EPhOH9fcusYcqopUs0R93No46bvdzgvLKTj3iVsSMPu6OOfVLkRNUFIeOfuOAJ8ro8 naql77uzAPHbc6hMUFdXdqx5RJmUtmu71qw8q/EEBdYZ88H7cZKj9PVtdctijKo7ER3O D0PDIKYgOsuDB3tsIDgYRLhEvO+VkEyOx6oZqstRMHxvhqPSZy0NKNrosQrxLU2E5fov B8j/CPlIdG5zdeDd4PCWM8CD5AJokQPZcDet55S6HTUAiLCBqXSUOJrG7wwhn8750b0q pF4MrcwoeOay+tn1ZYqhFWPdbu3BudBdi/y7QHjwARpDNKvBH+sPe+w+Y47WqFG6ZPgs b8SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698915007; x=1699519807; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yv7JujbLaP4o6hSsKOV57zb9TN8J85KbDLi3JdO3f/s=; b=A9gI6e5cgpXHxzgTirfYHjCgRC32Ovx9uLWpNdfHOq/XRHkw41/cBUDCvZcH1wIfam gbYr7h8m/rmJ3xOEEhlUA8y3m4ZzVxwwBjScJklGrIe5x8we8iRgTAK8XYpBaw4eohZ4 nd2z2FBX7qbT4tMV2UMgU20+ACMsadMGGQOrzbSo3kYtCuI3tSyWxjaCEF5nTerKwb3h K/WXypau9fm22OyQY5l4pWws21TuXhbleBrHvop7YMGNcZIwAyL4FhYBqjlw0un9ipPC +utO8My2sHkP7IEhT0RxJeQwzmpfgfk0NyxbY5vg0K0BlZXh0HmkiRYi7a/kgs8kWz3s Euag== X-Gm-Message-State: AOJu0YwmJe7wvlkh4wPWy9G72pUWKyKjTWhwVPSJHqLiSejo8j1aBzvJ 8PH7f384zRTLvssfI3+YBeI= X-Received: by 2002:a05:6000:156d:b0:32d:a366:7073 with SMTP id 13-20020a056000156d00b0032da3667073mr6805024wrz.14.1698915007132; Thu, 02 Nov 2023 01:50:07 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id o5-20020a5d4a85000000b0032fa66bda58sm1718607wrq.101.2023.11.02.01.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 01:50:06 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 2 Nov 2023 09:50:05 +0100 To: Steven Rostedt Cc: Jiri Olsa , "Masami Hiramatsu (Google)" , Florent Revest , linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [QUESTION] ftrace_test_recursion_trylock behaviour Message-ID: References: <20231101134556.5d4a46c3@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101134556.5d4a46c3@gandalf.local.home> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 02 Nov 2023 01:50:23 -0700 (PDT) On Wed, Nov 01, 2023 at 01:45:56PM -0400, Steven Rostedt wrote: > On Wed, 1 Nov 2023 18:32:14 +0100 > Jiri Olsa wrote: > > > hi, > > I'm doing some testing on top of fprobes and noticed that the > > ftrace_test_recursion_trylock allows caller from the same context > > going through twice. > > > > The change below adds extra fprobe on stack_trace_print, which is > > called within the sample_entry_handler and I can see it being executed > > with following trace output: > > > > <...>-457 [003] ...1. 32.352554: sample_entry_handler: > > Enter ip = 0xffffffff81177420 <...>-457 > > [003] ...2. 32.352578: sample_entry_handler_extra: Enter > > ip = 0xffffffff8127ae70 > > > > IOW nested ftrace_test_recursion_trylock call in the same context > > succeeded. > > > > It seems the reason is the TRACE_CTX_TRANSITION bit logic. > > > > Just making sure it's intentional.. we have kprobe_multi code on top of > > fprobe with another re-entry logic and that might behave differently based > > on ftrace_test_recursion_trylock logic. > > Yes it's intentional, as it's a work around for an issue that may be > cleared up now with Peter Zijlstra's noinstr updates. > > The use case for that TRACE_CTX_TRANSITION is when a function is traced > just after an interrupt was triggered but before the preempt count was > updated to let us know that we are in an interrupt context. > > Daniel Bristot reported a regression after the trylock was first introduced > where the interrupt entry function was traced sometimes but not always. > That's because if the interrupt happened normally, it would be traced, but > if the interrupt happened when another event was being traced, the recursion > logic would see that the trace of the interrupt was happening in the same > context as the event it interrupted and drop the interrupt trace. But after > the preempt count was updated, the other functions in the interrupt would be > seen. This led to very confusing trace output. > > The solution to that was this workaround hack, where the trace recursion > logic would allow a single recursion (the interrupt preempting another > trace before it set preempt count). > > But with noinstr, there should be no more instances of this problem and we > can drop that extra bit. But the last I checked, there were a few places > that still could be traced without the preempt_count set. I'll have to > re-investigate. I see, so I'll keep in mind that it could change in the future thanks, jirka