Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp521218lqt; Thu, 6 Jun 2024 10:04:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRmb5GVSD4W3NauOuJmndpSmfOIdAnAgHUiINRVfeI/7rIWZKNDHff5rHIjnb/QVuDlElM5b763pwzPLSWu1s6OtVc1/vDBUuROs0KPw== X-Google-Smtp-Source: AGHT+IGQbML5Sh4uSLo0+hvsIynme/FgRjgUzF1KqEMvkJCEQtZRUAS/JFC2gfzZRClYHv2HT0WN X-Received: by 2002:a05:6402:2153:b0:578:973d:4fc6 with SMTP id 4fb4d7f45d1cf-57a8b67712emr3535377a12.6.1717693450490; Thu, 06 Jun 2024 10:04:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717693450; cv=pass; d=google.com; s=arc-20160816; b=ip/A9apn4IApWJFfWDxpZBjO8Lm7cMpzFS3ajlTuAnIeO5sAz7VEUW59sxGQQKgLkq jXI9NySShPLs2chJ9/1g9Xgcfr+FDbKxaSVbqdZpJK1Obs9qT2aYOtGQKI2zqC72nt5X In+EICuRx7VozACTcXGI4qG1lXFLWS8yXtcfa89rVmrRZ8ys78NACDtYxUIwQfBqgUFV tFsX4e0HJ55B+LzhSdFnIVbSUO3lVpm7enl0CdNgw9iOdgx5khWRAvGOvMAGbK2SVe9g 59433B0khCERxAAFc9e96V9gDTy/i5tbE72pE3Rnst1xASxEZmXNRzOepPju6kDC++Yz +Npg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=En8ByHgq5/JBTLUzMheK1+qjcQIGlXPibjicoZGW6BE=; fh=f5dksfX4tbdH4/OzhSmPVzq9Cq8wSmqTvr2fBNr3jFw=; b=Gn7ndZRAh3TQKCRuJwyRYuNT1BT4Smmd2N44s3KnS5tOcdk+LY7ytfmh4sjvI9h47P n0xIaMt85+4gNNi27D2mqtYgdX7yYHLBgLtUQsbL3bAfR3B30wiApB7hNevgFvzqe4rt pL/NLUbm3ZvnC8sjZNxYl0AVkPDUiVhn4roZlAYeSpT5wJDETEVja5HkABs5BhMJNHPY j09N/l9MhUwSHnOa0ltN/yKALaDdZXJauG2e9almHr4b0H7hJx7crIu8mz8vHJ1KcuPY npcT1JrE1T7GcEImfnXHGSokm69rj5jhz/tbkYNhgB0QB/qIJUl7d3g/LSw7M5npwcuE u/vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=awbEH11T; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-204740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204740-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. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae0fc05bsi883237a12.197.2024.06.06.10.04.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:04:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=awbEH11T; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-204740-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204740-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 C44161F29625 for ; Thu, 6 Jun 2024 16:53:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 483791990D0; Thu, 6 Jun 2024 16:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="awbEH11T" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 0EEB71990A6; Thu, 6 Jun 2024 16:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692773; cv=none; b=XS3LLR6Uhh2DJkwgygo1loqMqO2G5rKH+hsQuViaA0/Gqh0RzI5xyb82mv8b71AinP5OI6tfSqM6otfanL9pjUxceGyUxqyHk3FLQ2UOmFbNNp92KOJJCGmPs6isvDzi6m3gLpzxhq/jN8+BPHdWP3zx37J99SCbJjg5RhiRte4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717692773; c=relaxed/simple; bh=Z489YCatSICp2CYkRv/f1IFzE668yX8OtUM+wlNOmgU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sP0LFT/bTxtNgGklslTCjjjgJBO3+y0cHKsHDpSOIERJFEyijt71uv/blqUdR00oyVlvE6002Fc/6BqSt3zoMwBdty6Q7Nl2cH8oTT2Mx9gqsBSU9wTN3eqvF+hSAsJX+BGukjdbsArRmnRTnK/2lOD1cCIiAQxcAiFihu5KaeE= 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=awbEH11T; arc=none smtp.client-ip=209.85.216.45 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-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2c1b94dab63so977358a91.0; Thu, 06 Jun 2024 09:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717692771; x=1718297571; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=En8ByHgq5/JBTLUzMheK1+qjcQIGlXPibjicoZGW6BE=; b=awbEH11ToG12JIJYNIJngXm4TXa097gs+2tBqDv+NCYFYhaOBmIjPSrVtfrvpFyUbl YJCBZG/CXVkqRgzHTGytFYKBupDtmX5wf1qihgIAfuMXKoxwxapkuzvFi7x5JBcVslft FhlPBV/EtLvWYtTcQlGPIilN6O1zJxuWmWM3t8UxNpO+lE/caNVWsXKLW2PpmH+PfYpQ K14V1Qe3cXr9JzgA7k0f98E05gv/Gw1gGtM38EwU0kORa1onOzL5iECd0nRNbMkH/2Nm gmWWJjXbviK+r73tjZrT23ZjLvsSFl1rukGizqfNrX/29GLCziADudjQy/BqymV2pnyU 6+zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717692771; x=1718297571; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=En8ByHgq5/JBTLUzMheK1+qjcQIGlXPibjicoZGW6BE=; b=W+FI+xhB8n33EpnZ1RL5tuYy1ZgaBUqp2ho9zuYLTT5wQ4g7DKQ49TktbVT30bHipp rTxeWa5vkGbEl3JoB6JEuZ8hY8lnUPpG+X3cw8nDBh8IDjZ4861XBegqh5qIC8ggIbVY nblACsMuf42/iqG4CkznoGjenuCyKicUYdPHfOChxe2bePq7OAxQPugskJWZIoAQNnku 8q76OGCvQNiIoiOP1+Lvexek/34SMA7eLHCSvYxtW31muqUNwcIKd8lwuk8tJcWWlTC1 mJutNmWexfrOZJPP8kX6zEiwNUu01J4s/KRWKIuTqVu42japtCB02d5NCsYRaO75lY9T 4Qmw== X-Forwarded-Encrypted: i=1; AJvYcCWRR6/9eglT2klwf0j+m7V9DpamNwZCSTnkzh3kyKA3ZVyrb8XTdnp30E511uvQDP0h38MLD9kpOzaW6xpucVl25BYqM0pv5JCy6VQgF1co7wcErx/5GDPMi1j8pKRzurvIpb5aqBa8NS681eaUt1chLMxJ37a6FA2vCC528BYIfkSyzuIm X-Gm-Message-State: AOJu0YwPthqQAW58YnGPhdTot+xdFHLkOvyVQIKNe3jBrPbsMcsAINiS f87ALpMxIpuBv0rZLf5BGHYgDKoPAhcg1zaELTCl7Atx64LjgkmjcPgDIO33udM+lbYAQCU30WG TNAzMZZNyPL+JnT6PrLFRUI+oBiQ= X-Received: by 2002:a17:90b:30d8:b0:2c2:b625:ee9b with SMTP id 98e67ed59e1d1-2c2bc9bb6edmr91541a91.4.1717692771270; Thu, 06 Jun 2024 09:52:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240604200221.377848-1-jolsa@kernel.org> <20240604200221.377848-2-jolsa@kernel.org> <20240605175619.GH25006@redhat.com> In-Reply-To: From: Andrii Nakryiko Date: Thu, 6 Jun 2024 09:52:39 -0700 Message-ID: Subject: Re: [RFC bpf-next 01/10] uprobe: Add session callbacks to uprobe_consumer To: Jiri Olsa Cc: Oleg Nesterov , Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 6, 2024 at 9:46=E2=80=AFAM Jiri Olsa wrote= : > > On Wed, Jun 05, 2024 at 10:50:11PM +0200, Jiri Olsa wrote: > > On Wed, Jun 05, 2024 at 07:56:19PM +0200, Oleg Nesterov wrote: > > > On 06/05, Andrii Nakryiko wrote: > > > > > > > > so any such > > > > limitations will cause problems, issue reports, investigation, etc. > > > > > > Agreed... > > > > > > > As one possible solution, what if we do > > > > > > > > struct return_instance { > > > > ... > > > > u64 session_cookies[]; > > > > }; > > > > > > > > and allocate sizeof(struct return_instance) + 8 * > > > > and then at runtime pass > > > > &session_cookies[i] as data pointer to session-aware callbacks? > > > > > > I too thought about this, but I guess it is not that simple. > > > > > > Just for example. Suppose we have 2 session-consumers C1 and C2. > > > What if uprobe_unregister(C1) comes before the probed function > > > returns? > > > > > > We need something like map_cookie_to_consumer(). > > > > I guess we could have hash table in return_instance that gets 'consumer= -> cookie' ? > > ok, hash table is probably too big for this.. I guess some solution that > would iterate consumers and cookies made sure it matches would be fine > Yes, I was hoping to avoid hash tables for this, and in the common case have no added overhead. > jirka > > > > > return instance is freed after the consumers' return handlers are execu= ted, > > so there's no leak if some consumer gets unregistered before that > > > > > > > > > > + /* The handler_session callback return value controls exe= cution of > > > > > + * the return uprobe and ret_handler_session callback. > > > > > + * 0 on success > > > > > + * 1 on failure, DO NOT install/execute the return uprob= e > > > > > + * console warning for anything else > > > > > + */ > > > > > + int (*handler_session)(struct uprobe_consumer *self, stru= ct pt_regs *regs, > > > > > + unsigned long *data); > > > > > + int (*ret_handler_session)(struct uprobe_consumer *self, = unsigned long func, > > > > > + struct pt_regs *regs, unsigned= long *data); > > > > > + > > > > > > > > We should try to avoid an alternative set of callbacks, IMO. Let's > > > > extend existing ones with `unsigned long *data`, > > > > > > Oh yes, agreed. > > > > > > And the comment about the return value looks confusing too. I mean, t= he > > > logic doesn't differ from the ret-code from ->handler(). > > > > > > "DO NOT install/execute the return uprobe" is not true if another > > > non-session-consumer returns 0. > > > > well they are meant to be exclusive, so there'd be no other non-session= -consumer > > > > jirka