Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp493904rdh; Tue, 19 Dec 2023 05:24:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMmDZ5OpMBGlKPyQh8mMhSu58jXELJetnojn3syGAzzjhZBKzSxx8Hk/n+PyhFTKK+Kjj4 X-Received: by 2002:a05:6512:2823:b0:50e:3714:b420 with SMTP id cf35-20020a056512282300b0050e3714b420mr2084717lfb.9.1702992269167; Tue, 19 Dec 2023 05:24:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702992269; cv=none; d=google.com; s=arc-20160816; b=H3sv60IgLvh5NQWBoJG12A+kDSBtJiSpBENevD6xYnkfrm8VS+jJOabveON1ePUYLj S1NVvRTZRQrLQ+6TGgNszA2yDju9ZS5M7yTxyPEjn1ls6/qSZOGlDjmnP/W3uBbsH2x9 tusW/xV6ByXmXaq05Iha3Uafxj2/PK3T6Bh+4ci9snTcChJPW4FgBDbtUkarL5gIBpSg lqTKfMyTys+vyfRv9YIHNEqIASaUj9NK8kLJlB6mbssgeLS1Nyqx5WneTYMsxL+zkMwz iPohUOE+31yLhpWJT4HM3Ry7PtAHIkjotONbGI7/gEhf/Yy+cUxxJWqVQV45lj/Lrzx5 tSRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:date:from:dkim-signature; bh=69alNgUwO4fEHcqvlE9wDHPb87XBycRiNpEU0YqP8dI=; fh=HQRt3482IbkaQ1sytQK2HaqA7bh9pX/5Nqgyt3+2xdU=; b=WESSxXU4C5RyThRWArOnHrI3LrL0FlccAlnrwsgMA/2cL+UwKC9OKd39w2vV/y/FtK IpfrPAoMwNDa3B3riwhvxHtFfEsJqaKdwEaQW4bCFKR+7XG0CTF+IMevIoxKsy8HS9Af VXkmQKtca4ydo3kKP9jahr9jhkwl8SOM7VKibPAGVA4w33gs0ZE7aCVP3yJq0nvNhtOA 6jNbEP70ArYCUeJ4c4Z9ne13isTk7rhRSAkepMqpV2jgvXgrIxyZK/ETA4Io6WH34To0 NDmKdKUC/dLF2SlF1kQcZEBp0Msuj/19UexIRm30S/0fyT3oI4l2XqPRxB/cwd0MBvCL xOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eFuN0W0h; spf=pass (google.com: domain of linux-kernel+bounces-5254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v16-20020a509550000000b0055362f400c0si1499323eda.390.2023.12.19.05.24.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:24:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eFuN0W0h; spf=pass (google.com: domain of linux-kernel+bounces-5254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E2AF91F24A5B for ; Tue, 19 Dec 2023 13:24:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E0A71B26F; Tue, 19 Dec 2023 13:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eFuN0W0h" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 3D04D18ED6; Tue, 19 Dec 2023 13:23:41 +0000 (UTC) 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 Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-55370780c74so2477463a12.1; Tue, 19 Dec 2023 05:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702992220; x=1703597020; 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=69alNgUwO4fEHcqvlE9wDHPb87XBycRiNpEU0YqP8dI=; b=eFuN0W0hlGpPbszrLgW5riCtIgRr7m9ocAWh8w/UFI6osJooFYma5j5BiO3cYxP3tg BpPzBimkv8XeTSmas1PtEYID8vLWuTEnG+oYjRIoeQ5bibskAAhAkTw9sYSRj81wbFh2 JXciVW88h5BLdC6b2RRlGwm91Jv5q0LcWzVsMVeQBfMm0c0F006ja6OWZFl9t7Cnd2OE +vcLkn0OA+8FBebv3SDZwxjHFrxa3Lo9XaGPAmCCDEBci4I30tqCp0HaHNfrev4LGWJO o2R69ykhB5eYiqXo26krQHqYsW3wBj5M85AjSCuSVIEKC8PVlwqewGEpkAH46PVRHiVZ sL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702992220; x=1703597020; 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=69alNgUwO4fEHcqvlE9wDHPb87XBycRiNpEU0YqP8dI=; b=PIlzXNpcx/5ZaZ4BjW5K0bA3NSmvZwMHh0qJtvQOBVhTXfuTgj3SWD+jYddbWh6SAS ioLCf1YVJbHINVAhsvIuNVIbebwdPf7K+gTCbHxEma9a0jDOy7PvuIYCr7b1UzKyxNHL kVYm3lBzEyeNSG7qsyHZP4EO5Kj04HmxV/cSlAle2WMKw7UuOpnqnf5ASfNFFKfuM/+/ r9vYRsD1VD+JCTMj1mYfIea+hRKBxxREW3dbHEAhxYgZ3qcrm/CTk02A3RZeEN5CaLpE js03RA5fr/CqQ+RbI9moP0MlfTCwE8Mzg+Uan7ZRU4w//0AawofUVGp2AyfRRVsFZT7G z7tw== X-Gm-Message-State: AOJu0YwumZwudBxDor3GE84pf0WkH0DwqyXP2TRNShKfp2wFKk3GT1j8 Kv1GCzA/m8Jzi9bVZIhDzLU= X-Received: by 2002:a17:906:2d6:b0:a1f:8aa3:2bd4 with SMTP id 22-20020a17090602d600b00a1f8aa32bd4mr8549477ejk.133.1702992220176; Tue, 19 Dec 2023 05:23:40 -0800 (PST) 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 ot17-20020a170906ccd100b00a235b01886dsm2285702ejb.10.2023.12.19.05.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:23:39 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 19 Dec 2023 14:23:37 +0100 To: "Masami Hiramatsu (Google)" Cc: Alexei Starovoitov , Steven Rostedt , Florent Revest , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: Re: [PATCH v5 06/34] function_graph: Allow multiple users to attach to function graph Message-ID: References: <170290509018.220107.1347127510564358608.stgit@devnote2> <170290516454.220107.14775763404510245361.stgit@devnote2> 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=us-ascii Content-Disposition: inline In-Reply-To: <170290516454.220107.14775763404510245361.stgit@devnote2> On Mon, Dec 18, 2023 at 10:12:45PM +0900, Masami Hiramatsu (Google) wrote: SNIP > /* Both enabled by default (can be cleared by function_graph tracer flags */ > static bool fgraph_sleep_time = true; > > @@ -126,9 +247,34 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, > calltime = trace_clock_local(); > > index = current->curr_ret_stack; > - RET_STACK_INC(current->curr_ret_stack); > + /* ret offset = 1 ; type = reserved */ > + current->ret_stack[index + FGRAPH_RET_INDEX] = 1; > ret_stack = RET_STACK(current, index); > + ret_stack->ret = ret; > + /* > + * The unwinders expect curr_ret_stack to point to either zero > + * or an index where to find the next ret_stack. Even though the > + * ret stack might be bogus, we want to write the ret and the > + * index to find the ret_stack before we increment the stack point. > + * If an interrupt comes in now before we increment the curr_ret_stack > + * it may blow away what we wrote. But that's fine, because the > + * index will still be correct (even though the 'ret' won't be). > + * What we worry about is the index being correct after we increment > + * the curr_ret_stack and before we update that index, as if an > + * interrupt comes in and does an unwind stack dump, it will need > + * at least a correct index! > + */ > barrier(); > + current->curr_ret_stack += FGRAPH_RET_INDEX + 1; > + /* > + * This next barrier is to ensure that an interrupt coming in > + * will not corrupt what we are about to write. > + */ > + barrier(); > + > + /* Still keep it reserved even if an interrupt came in */ > + current->ret_stack[index + FGRAPH_RET_INDEX] = 1; seems like this was set already few lines above? jirka > + > ret_stack->ret = ret; > ret_stack->func = func; > ret_stack->calltime = calltime; > @@ -159,6 +305,12 @@ int function_graph_enter(unsigned long ret, unsigned long func, > unsigned long frame_pointer, unsigned long *retp) > { > struct ftrace_graph_ent trace; > + int offset; > + int start; > + int type; > + int val; > + int cnt = 0; > + int i; > > #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS > /* SNIP