From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78A8DCD13DE for ; Sat, 31 Aug 2024 17:26:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 034C68D0034; Sat, 31 Aug 2024 13:26:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F27398D0022; Sat, 31 Aug 2024 13:26:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA0276B00C9; Sat, 31 Aug 2024 13:26:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BAF1D6B00BE for ; Sat, 31 Aug 2024 13:26:07 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 46B6940EF5 for ; Sat, 31 Aug 2024 17:26:07 +0000 (UTC) X-FDA: 82513218774.04.E4F27D5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 4A93580005 for ; Sat, 31 Aug 2024 17:26:05 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=frfOTl9t; spf=pass (imf30.hostedemail.com: domain of oleg@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=oleg@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725125143; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JVfJiK+AAnah9BOiQ40UN9PtQCNI2NjuzPzjdt9OXUI=; b=gsEeOHCpXN5EMrpx2eOFkeqRYYeRhGO/4sLKQmTNdjny/RJEwhr7Iji9yCv3N79XRrAqOg Nu0nNM0lKQ1exuEOiRJ8OT2LDyy2EW6Xf0D87nh8F3PtQ0DNKlpgO/R5HdjHiMDNWr8de1 /Ljd/0ove07tf69fXviRWzt0Ch55s/s= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=frfOTl9t; spf=pass (imf30.hostedemail.com: domain of oleg@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=oleg@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725125143; a=rsa-sha256; cv=none; b=ih/BNEfNIDE9IfSMnA+7r7HwqSYhFVcgFKgICWbx+8EcpvNfaAULZYKBQl2B3JfjhjX9d6 DEepknUTloZN/ZvV2jgVkBoCexEBh39cbNYCPmxBannni6v0LHNrG0jidlceuxxhmcYkLg lJ7AgmEqWLGkJngwbPMMbo8czJJCDj4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725125164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=JVfJiK+AAnah9BOiQ40UN9PtQCNI2NjuzPzjdt9OXUI=; b=frfOTl9tIyNPDAx2eu7jI/6RsQEE/O7sEO1/kZMM5CmtrbYavScJHnf4t8cKPyO/CcusLJ SDwj2ryvq9SVTxyKdeDPCdhKaK9GzHff1VAA3cjhaCftRmIWEOod49HXwE8dyDJ8JZa9EJ afMAw2bGVEsVeU8oIwmu5EPKKox7mnk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-270-Nq0PdkgeNV2PWi72YA0zag-1; Sat, 31 Aug 2024 13:26:02 -0400 X-MC-Unique: Nq0PdkgeNV2PWi72YA0zag-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9FF661956080; Sat, 31 Aug 2024 17:25:59 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.49]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 29D041956048; Sat, 31 Aug 2024 17:25:53 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sat, 31 Aug 2024 19:25:50 +0200 (CEST) Date: Sat, 31 Aug 2024 19:25:44 +0200 From: Oleg Nesterov To: Jiri Olsa , Andrii Nakryiko Cc: Andrii Nakryiko , linux-trace-kernel@vger.kernel.org, peterz@infradead.org, rostedt@goodmis.org, mhiramat@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, paulmck@kernel.org, willy@infradead.org, surenb@google.com, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection Message-ID: <20240831172543.GB9683@redhat.com> References: <20240829183741.3331213-1-andrii@kernel.org> <20240829183741.3331213-5-andrii@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspam-User: X-Stat-Signature: fnphe7xc9asm66p7nhensz5onxmhg9rp X-Rspamd-Queue-Id: 4A93580005 X-Rspamd-Server: rspam11 X-HE-Tag: 1725125165-654087 X-HE-Meta: U2FsdGVkX185POMVb1OWoSF6i54roixUQ4IQn5J4ojIk2d6qqFVhRNFp08ql2ismoPvxoiE6q08lVm8IQeXrkEa4xfcIW3TdaA/mX3I3D2ecso3LnOzdsk16CxS3aAJDsoAClBXFMleVnChyhxKuZHTpz+suU8NPvFT2kA6ahB7LrqG98qFIDQ57ih6D0jZWdRb1nSkJtlsKlyx8Hdek750me/aiu624EdCq0mwBTHQCnqd73Vrg6FXJt6PDDtACIXVEyAPLiU/i48UHt6XRFuEWzXaawb+Df+lWx0JuGC20XUpaIGR0zfwNqE1aV494Hd50aHQ0r8YcNVEiXrZvJDfep5YdsAlBYMCW+BjbYB4oOFiFjWGcnVyIkRT0POdoJrT1yE1iHkBvs9ODEhEmKDnWbDEOnSvgSsB+LyI5htw1z3xCJlV7LXq5hvEigX0itFg9tvScMUmDkR+J5tYQyAduFnCFFtBo14U0ONncerQ54m4bFjIEUKpi8XUM2oJUjPDsjZlJOyRxesW5OJC/Qs/5BGroTWCEzK8LEegEaHcuquJSB1lcWrz6Ov6z0v88g3FO7d7bS+qCU8yGo9KY1kHWaSE1cJhFtbvid2gNoO1AlsDCLiLqvXYzZ2g+5VD4gDTSiPVJwVnq0A+QgbUvWOmqUstXaKpBgeY1P8EqPcD8R3bh3WcVa8D4PNqJ7c5vmDQruIdq2CLwxMOtt4Az9eRUKQXT4Zhy60LLNkv+9mV14i77mKdj3FodLfKqxQN86FheKTOrYf5GzfNTXdSB4qob/VZigF6/lqpYREcakb7eXaugm5P+YacrX9RN9c2Sez+lMQuDxtrpSkyR/u01rrdhHBjRWEpIEq+ZDGfDkrX3egmCfebACBacsqpMYQsh9vN7c/h3pOvmrBxih+kCh7s2QZYgUmPki9QVrUoMpGhQuYovAc+wO9vJ5uitKM4E6kVbEl35gO5kvwdJOBT TjqVYZum NVwgGLCV17MRW40lrgHEHYPvxnmTJ9N1p3RDP2CwNQ3FBZzN3ezVfuwL96CP6jpR5w2shqEJZlg4L6EzOP/EFjmeBxMKcmW1UjKhx3Jr4GFAKkss+cvmVGLVXVqau6gQLwQSDQgDu8bSASI0vHZZF9Gq23ws3h13qymCw2s98XaATb8wMjM4ZeuKJEg5Slhsd4I1sO3lC3hopf4gcVdcBgONrgk+Lm8qEXaGaLQpmeLz7Af0i/MNxPT5XZkTivLBuB9okv00UMj0cQjqR4is3t3yq7YT2wZg72TgU6ggoubeafmR+igM7NAV0AmER19yPP5DGBgNC4ewqzsWq0mXi5EN67Ii5mTUwQ2myVAlrIYdERmR+HyNbIakjI/XORC8Pfbww X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 08/30, Jiri Olsa wrote: > > with this change the probe will not get removed in the attached test, > it'll get 2 hits, without this change just 1 hit Thanks again for pointing out the subtle change in behaviour, but could you add more details for me? ;) I was going to read the test below today, but no. As I said many times I know nothing about bpf, I simply can't understand what this test-case actually do in kernel-space. According to git grep, the only in kernel user of UPROBE_HANDLER_REMOVE is uprobe_perf_func(), but if it returns UPROBE_HANDLER_REMOVE then consumer->filter == uprobe_perf_filter() should return false? So could you explay how/why exactly this changes affects your test-case? But perhaps it uses bpf_uprobe_multi_link_attach() and ->handler is uprobe_multi_link_handler() ? But uprobe_prog_run() returns zero if current->mm != link->task->mm. OTOH, otherwise it returns the error code from bpf_prog_run() and this looks confusing to me. I have no idea what prog->bpf_func(ctx, insnsi) can return in this case, but note the WARN(rc & ~UPROBE_HANDLER_MASK) in handler_chain... Hmm... looking at your test-case again, > +SEC("uprobe.multi//proc/self/exe:uprobe_multi_func_1") > +int uprobe(struct pt_regs *ctx) > +{ > + test++; > + return 1; > +} So may be this (compiled to ebpf) is what prog->bpf_func() actually executes? If yes, everything is clear. And this "proves" that the patch makes the current API less flexible, as I mentioned in my reply to Andrii. If I got it right, I'd suggest to add a comment into this code to explain that we return UPROBE_HANDLER_REMOVE after the 1st hit, for git-grep. Oleg.