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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 598FAC77B75 for ; Mon, 15 May 2023 21:38:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245313AbjEOVi3 (ORCPT ); Mon, 15 May 2023 17:38:29 -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 Precedence: bulk List-ID: X-Mailing-List: linux-trace-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