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 52915CD37A9 for ; Tue, 3 Sep 2024 17:28:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE1468D01B2; Tue, 3 Sep 2024 13:28:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C91038D018A; Tue, 3 Sep 2024 13:28:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B334C8D01B2; Tue, 3 Sep 2024 13:28:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 93F438D018A for ; Tue, 3 Sep 2024 13:28:05 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1920F140882 for ; Tue, 3 Sep 2024 17:28:05 +0000 (UTC) X-FDA: 82524110130.16.2540E18 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf18.hostedemail.com (Postfix) with ESMTP id 3E8151C001E for ; Tue, 3 Sep 2024 17:28:03 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KhBPjPKj; spf=pass (imf18.hostedemail.com: domain of andrii.nakryiko@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=andrii.nakryiko@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725384389; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WZhURiUNTol60UwJCmuV5E8L9XzOE2w/tYB59LnQ8yk=; b=TL7A1lmlgXHQIv/Hyb3zbLGBb28r2nSdoSWutsCd/6fsw1ig1W/4HyQ/4AhCqXxomfRTB4 i0swk1Y7caqnlOwJuYmLBt1B72NTHRFGBqSMP2JNkW2g9O3/qyoFsz0wYpxucE6RxVhmpU HaYQgbKV6Q2FtwHQgzBysS12/eO22RY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725384389; a=rsa-sha256; cv=none; b=xEa1+S9C1AfFn0FzaMEufe2CoGKH3QuBKP1FEXT9tXfySupHrjb4JTHSavXuyczZh3t9db NAtdHPgZWpBjZSzDmdfI345BXKOXItrSNrSF32YN1sdGCB0fnswTjEAaMx9yHiVxaR5K9T k06gF3eLujCirFehojONNr7e5VYn4YA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KhBPjPKj; spf=pass (imf18.hostedemail.com: domain of andrii.nakryiko@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=andrii.nakryiko@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2d8a54f1250so2037153a91.0 for ; Tue, 03 Sep 2024 10:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725384482; x=1725989282; darn=kvack.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=WZhURiUNTol60UwJCmuV5E8L9XzOE2w/tYB59LnQ8yk=; b=KhBPjPKjzDN5zNc9JaK31THRktoKB82V+jSl4llC7Ey2qwbP2fJ8Q1ncfJ17Bp9T7j uYNJ1xsU676kRtr+xogOsqu0pHEVncRvqJ2s6YIXMYAdN0THNIfL2UwMDz9xfqoh0TC4 l9FiaWuqcGtCp+oQgPWy8NTyWuOgoOrpfzTT7Mh60LoGXrIc3Ruqp07VX3GRlum3I5kQ qy3EU/VWF+LES5BB1YPNCGGWoKb5AeoMmCqzkA73oX1aISVk4TYCERWkGyYENaUifJsZ xriZwclOFnQy2atrFXmZsyO2XTfYLxE08P9waHtGxmHZMT9pk3rtC7TwoPz6gyU4/OSZ 5AeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725384482; x=1725989282; 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=WZhURiUNTol60UwJCmuV5E8L9XzOE2w/tYB59LnQ8yk=; b=TKi7iuC2ehCdF8qeWbp7K6IS4AzcQvKJEIqet3+CjjwY+RTcQxRyD6FhBGcyTT9r68 Tz5d1piS0kZn9CdoFzmWed64aMJGUrCuhPIVZGR0559et6I6Q55lJVrYwbb7W4aSyhMf 7YcqVFos5lZq+mZW7tYC7qX0M7y+OTiyr1axWelQiRz3FoU6jN68bcoboUn+v/R4yPAz +VpmB8IyMCwJYmZ3bRzd6PtwrULaRaxMn+2bWemn1z1Uc/W+HlF1aSfcul6LvDiFOqo9 kmqrbll7NhGFcgWeUneDv2XncQDlrNf5W/x3jkymwfdYEMTkyFAa4FBqXr7m07Lh3p9J kgKA== X-Forwarded-Encrypted: i=1; AJvYcCXLmThXQ4E+OuYc/Z/IT8LQmG9d+ElhAoxkF0li7Ulm3y8X5bPa2GR/CWybVTLzoFHNiiVqTbFg2Q==@kvack.org X-Gm-Message-State: AOJu0YyaZeEdbJvKlbIogYjYmHc916qQGeF7S8329m3GtAc0k9sMBX96 OGabQChuwBRsiopvIkPXQ7j28ECg4VxxQvQfqL25lb0FNCACPA/ivaUSWf7Y+gH46KiWn4f+dYe QbAXjn8C4zyUG8GerflLN5aW5g/4= X-Google-Smtp-Source: AGHT+IGameP0HKRUfKRVgGXKvRTBH/w/+aYW01SyIu6o8tpRyb8OJwxrNgvkFe6WM0FBszSSEtDoJZL9LIM33M4rsg0= X-Received: by 2002:a17:90b:88f:b0:2d8:898c:3e9b with SMTP id 98e67ed59e1d1-2d890564db2mr10964977a91.25.1725384481802; Tue, 03 Sep 2024 10:28:01 -0700 (PDT) MIME-Version: 1.0 References: <20240829183741.3331213-1-andrii@kernel.org> <20240829183741.3331213-5-andrii@kernel.org> <20240830143151.GC20163@redhat.com> <20240830202050.GA7440@redhat.com> <20240831161914.GA9683@redhat.com> In-Reply-To: <20240831161914.GA9683@redhat.com> From: Andrii Nakryiko Date: Tue, 3 Sep 2024 10:27:49 -0700 Message-ID: Subject: Re: [PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection To: Oleg Nesterov Cc: Jiri Olsa , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 3E8151C001E X-Stat-Signature: g1waictuqk8jwsrjjtrnwk7hqhhn3eej X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725384483-451554 X-HE-Meta: U2FsdGVkX1+o9LDWdts0eqJvfXP3XuReTA1MXSYAzzFlz+m4UaRynUcKAaDg5PcmCBcZS1Hzs0L21IUw1XKGSBHrj+rEBmIALY0xiyxkh27oNhcjOQN/w2/v2P1rdG6tQkm3sWfm9+Dzid3X2s+7hkfEZSm5dS0iexkC3aQnqCgCbwSeM1haqcJnHPn/ZczQ/oGRiS4IblbIaFwKYqyTFDoCc6PT7cE4vcLellV7NG+tnc9S3wF2n87Hqv6eqModzHZqIHazZ1scUc/P61ghTBDxUCF9gn9SV/0rN2zA8gWNGWecY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=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sat, Aug 31, 2024 at 9:19=E2=80=AFAM Oleg Nesterov wro= te: > > On 08/30, Andrii Nakryiko wrote: > > > > On Fri, Aug 30, 2024 at 1:21=E2=80=AFPM Oleg Nesterov = wrote: > > > > > > I'll probably write another email (too late for me today), but I agre= e > > > that "avoid register_rwsem in handler_chain" is obviously a good goal= , > > > lets discuss the possible cleanups or even fixlets later, when this > > > series is already applied. > > > > > > > Sounds good. It seems like I'll need another revision due to missing > > include, so if there is any reasonably straightforward clean up we > > should do, I can just incorporate that into my series. > > I was thinking about another seq counter incremented in register(), so > that handler_chain() can detect the race with uprobe_register() and skip > unapply_uprobe() in this case. This is what Peter did in one of his serie= s. > Still changes the current behaviour, but not too much. We could do that, but then worst case, when we do detect registration race, what do we do? We still have to do the same. So instead of polluting the logic with seq counter it's best to just codify the protocol and take advantage of that. But as you said, this all can/should be addressed as a follow up discussion. You mentioned some clean ups you wanted to do, let's discuss all that as part of that? > > But see below, > > > I still think it's fine, tbh. > > and perhaps you are right, > > > Which uprobe user violates this contract > > in the kernel? > > The only in-kernel user of UPROBE_HANDLER_REMOVE is perf, and it is fine. > Well, BPF program can accidentally trigger this as well, but that's a bug, we should fix it ASAP in the bpf tree. > But there are out-of-tree users, say systemtap, I have no idea if this > change can affect them. > > And in general, this change makes the API less "flexible". it maybe makes a weird and too-flexible case a bit more work to implement. Because if consumer want to be that flexible, they can still define filter that will be coordinated between filter() and handler() implementation. > > But once again, I agree that it would be better to apply your series firs= t, > then add the fixes in (unlikely) case it breaks something. Yep, agreed, thanks! Will send a new version ASAP, so we have a common base to work on top of. > > But. Since you are going to send another version, may I ask you to add a > note into the changelog to explain that this patch assumes (and enforces) > the rule about handler/filter consistency? Yep, will do. I will also leave a comment next to the filter callback definition in uprobe_consumer about this. > > Oleg. >