Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2649278rwd; Mon, 15 May 2023 14:59:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49whzF8UauT5cHJ/GiTzvU/4RyUw41FbttTdivT5VYrYqw9RHb1IGbv/+STcq08Dh+JP4A X-Received: by 2002:a05:6a20:8f13:b0:101:3fe5:8776 with SMTP id b19-20020a056a208f1300b001013fe58776mr28403090pzk.17.1684187977796; Mon, 15 May 2023 14:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684187977; cv=none; d=google.com; s=arc-20160816; b=EnvnpVbYleJ6seUynnFlD/1DC+n2TKZS8KQXCJZNmn9SpucmATGwR6y8+FYwPn0cC1 DWH/dIAZ7xzl9/l3X2lhUGHUo4vPZNPZLdcy+5TARPOarYyltp75tWgd/SEhtT+t32W4 3KH8VgyxCmR2L77xVzbOgzTLOQYVbglrgFN6PvzbcMqrS4p6wE3TMbZgpbZcAlJbNExe HlYooVPXiLhT1rwYW35L3cv3gbJkXIQPiMOVVhgfegagreK1gdriP2m7uRuwzFC8utsd 4v3bbRC9IAfuKIK9U3z0FoU6uONI94Aoy7Pe/hzfrQXS9zUVknh1+PLxhuKdLi0Mp+oP LLnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=A1gNcSvehEfyL26NtQcyvvuuIfa84AOAJAmpLkd/nk8=; b=yhqrXNLFqtl81HzWXZSIPh1cXDRbbzbOAuoroBwW9RPRURN7fDNy0HSnononsySp8D JEeOY4N55pppafZnVspWKeF4DPlGY2feNudEHTwO9MOUjPmOdmksgCQbFWDhF6Qs2ykl M7fOhRDIL4Slnua+jcJdlYi9tUcL7iYfb9cgD0VeL7s2JjjZlZRj194fUWeVyy2dQIIb PS2gm9Zb9PL6XwTcI8aIcHUY0wK5T/v43ReDvyJmrjrsKZJzSl7OJSjxY86/5UDUVaUx pxWvzxakqJeLROUNGZ45MKQ+TcQ1Ecd+BbpKYqTFE8K121dPRUhI9IdWzIYHrbnDK62l cDEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k28-20020a637b5c000000b00530b7ce3d35si6479771pgn.388.2023.05.15.14.59.23; Mon, 15 May 2023 14:59:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245460AbjEOVia (ORCPT + 99 others); Mon, 15 May 2023 17:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243399AbjEOVi3 (ORCPT ); Mon, 15 May 2023 17:38:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1731B59FF; Mon, 15 May 2023 14:38:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1ED2632C0; Mon, 15 May 2023 21:38:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8575CC433D2; Mon, 15 May 2023 21:38:25 +0000 (UTC) Date: Mon, 15 May 2023 17:38:22 -0400 From: Steven Rostedt To: Beau Belgrave Cc: Alexei Starovoitov , Masami Hiramatsu , LKML , linux-trace-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf , David Vernet , Linus Torvalds , dthaler@microsoft.com, brauner@kernel.org, hch@infradead.org Subject: Re: [PATCH] tracing/user_events: Run BPF program if attached Message-ID: <20230515173822.2e571869@gandalf.local.home> In-Reply-To: <20230515193532.GA153@W11-BEAU-MD.localdomain> References: <20230508163751.841-1-beaub@linux.microsoft.com> <20230509130111.62d587f1@rorschach.local.home> <20230509163050.127d5123@rorschach.local.home> <20230515165707.hv65ekwp2djkjj5i@MacBook-Pro-8.local> <20230515143305.4f731fa9@gandalf.local.home> <20230515193532.GA153@W11-BEAU-MD.localdomain> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 May 2023 12:35:32 -0700 Beau Belgrave wrote: > > static int user_event_mm_fault_in() > > { > > bool unlocked = false; > > > > [..] > > > > out: > > if (!unlocked) > > mmap_read_unlock(mm->mm); > > } > > > > Good catch! > > > > I don't believe that's correct. fixup_user_fault() re-acquires the > mmap lock, and when it does, it lets you know via unlocked getting set > to true. IE: Something COULD have changed in the mmap during this call, > but the lock is still held. > > See comments here: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/gup.c#n1287 Ah you're right. I thought it said "mmap_read_unlock()" before returning, but it's actually doing a "mmap_read_lock()". Note, I just got back home yesterday, so I blame jetlag ;-) OK, this is good as-is. The "unlocked" is only if you want to know if the mm_read_lock() was unlocked in the function. You need to set it if you want it to retry, but you don't need to initialize it if you don't care if it was released. Probably could use a comment there. -- Steve