From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) (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 7AE4F2D77EA for ; Sat, 17 Jan 2026 02:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768617015; cv=none; b=h+EJdPAKzqW064ZVYAC/anJpFKgwGTgDLNKvMBT2TRU4qKh/ddJS3aa85YaJgVumjMt7Dcsft0nq4eCj3boX4Y0DJtcnRrnfbsr1vatGZ+8LmjWd0VFG9onanTXqc51hoRNAeFVZci4wxjFXech2lSneX7PI4RGkzK4+QIlnKcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768617015; c=relaxed/simple; bh=0bZnyq+Ml97kOU4TUsgrr0iIUUHrsIknfLGbXt8rddg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NFUW2XdwAnFvTBNcQza2w7CzORCvdZxe1NWZhpTVwcDOWs5Q2U3f8cWLU4JGi0FYw7Xhefc8MVmketyIu83cE0zNxoqrmDUGoSxv7UVh+YnHm4xhfFS5I/RFYQOfTw9yUdYGm1DEOZzu4tFiL6x62ch0jLr8+ZGFyDEcooO/+9c= 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=RUDCfwkX; arc=none smtp.client-ip=209.85.219.68 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RUDCfwkX" Received: by mail-qv1-f68.google.com with SMTP id 6a1803df08f44-88a35a00502so25547616d6.0 for ; Fri, 16 Jan 2026 18:30:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768617010; x=1769221810; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=e7v6jVLBvVKWoS0dmG0nNndXtomcaAtap7nM7qINq/8=; b=RUDCfwkXPe/Oa890cHZLIJXEfYFGN+mJUSOWgz7gbZKdANPWR6g0W+R3MZjKmOTu3H D/32aqT8a5dpYF9AbYvfPL1XJZOLwxJvnnQMfra7qYqknHHmh1rR1TbTPI5lCTXvD+/t m8BSDYfhz88v9cpn81cy23dc9bhzwJKs2toE41CNb+/pKvF8CIqD34uGkKfJlMOTAQuc KDB72/9JIRZrgnKSbhafjaYyg5qR1OaxjaXuAf6+v1sz83YVZz+WBKRpferNHdXCWoqc ZxuJSEhrqjY7kQntoIDj3JRMpqwEylGlXTZYC6maA3VvpYgPmsdWwRYUQrk7w/fiw7RU InIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768617010; x=1769221810; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e7v6jVLBvVKWoS0dmG0nNndXtomcaAtap7nM7qINq/8=; b=d6Qoo5+dC5aiQiSyAt6tWuBmD7CTeKEL8VRB3WFFuwPJB6807LW/JXn91kTzZvcD2d OjlDsc0JDoYpgXMRH2m5wgkTh2hr7ekDotZsmKcmZlIHOrVaZA+XUiGJP45tmGqGs2R2 N099iJlHmdMOrO4L5LuVc11p3cvRyuC/d/lC+sq3cLe21FFSJ/HvfA0318TJAZ7S1ar7 hJJzsQJW8zM2uH/1DvHOotHjrcbtsBvAKROZ38RTknYkQ7+Ce+oholeNj4Ury/xg5P7s /O+JUJMz7aoFds3/9DF49LQ5UrFbLCj3oGcecErqQ7KjgtdAXOCpUI4EFovU8lkcsLF9 y7pQ== X-Forwarded-Encrypted: i=1; AJvYcCVNGndJJ+oM5HuFDhpqcPqbFKYq++Fu7zGcUGZkEDC6P39F7csC3rt0bGu+Megywq8Nt4ryKn3/Afr7b/4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyv83GsXKFNcrPB4AOntl1PgFpwId94rzmaRVkg6SUZfbVV2T+V HWgm7bb8gihN11XYFUIzGTFJXO9+fBeLdfy9JGSMn0QlCcHaf8peAPzY X-Gm-Gg: AY/fxX4SGuKWEAuBPLXNYDrA5so7gnANmJ667ORgyGHpmiyYxJI+TVwAVerm2iLx9q/ Rx9rcvqOOH6sH6//11BB7FHca1yuqyWDiQxPzgOHSuOT2fFpZNKGUOlXIokjiQsJYPMbZ4WQ5WU Y9d2hVrN4RogbOe0OMwtY5UxgXA05ant9cty72XGnAEnvlDck9mp5QIbGATWMVKL1gECsLbBDjC +XCCaA/bhxTOp4a6aza1rgpqeXXY0ZcZrRXTdJw+Sg2/1nEGyE5SY9li6RzJrCwJQQNWmIIM8xt 10SnKyq2EEHEFwFj8GDPsjkdk6UXQ5GeZc3xijqHK7fMU3tRvU68QJz+sPEBhFOeFKfOsMGwB4X Nfg4JGi4B8mex+AgSXXCue83oSd0VTM5vO/IqkULvYGB5bgk67jrXkgddsTuPEVg8q+Xjldxqp9 AGYrwIbc3MyTaUu4ML3B/L+jw1UhE8hlyug5vy5sv5Dz6EJA1CQecwyIEvjExApndZlueGy0PnO XZjRY6Di+xcJVwQ5I2oDccVlg== X-Received: by 2002:a05:6214:2261:b0:880:5193:10fb with SMTP id 6a1803df08f44-8942e4b8ff5mr68519416d6.54.1768617010378; Fri, 16 Jan 2026 18:30:10 -0800 (PST) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8942e6d87b1sm35532246d6.53.2026.01.16.18.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jan 2026 18:30:09 -0800 (PST) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 156CCF40068; Fri, 16 Jan 2026 21:30:09 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Fri, 16 Jan 2026 21:30:09 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddufedtieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueevieduffei vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvgdpnhgspghrtghpthhtohepvddupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehlohhrvghniihordhsthhorghkvghssehorhgrtghlvgdrtghomhdprhgtph htthhopegsihhgvggrshihsehlihhnuhhtrhhonhhigidruggvpdhrtghpthhtohepphgv thgvrhiisehinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheprghkphhmsehlihhnuh igqdhfohhunhgurghtihhonhdrohhrghdprhgtphhtthhopegurghvihgusehkvghrnhgv lhdrohhrghdprhgtphhtthhopehlihgrmhdrhhhofihlvghtthesohhrrggtlhgvrdgtoh hmpdhrtghpthhtohepvhgsrggskhgrsehsuhhsvgdrtgiipdhrtghpthhtoheprhhpphht sehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsuhhrvghnsgesghhoohhglhgvrdgtoh hm X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Jan 2026 21:30:08 -0500 (EST) Date: Sat, 17 Jan 2026 10:30:06 +0800 From: Boqun Feng To: Lorenzo Stoakes Cc: Sebastian Andrzej Siewior , Peter Zijlstra , Andrew Morton , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shakeel Butt , Jann Horn , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Ingo Molnar , Will Deacon , Waiman Long , Clark Williams , Steven Rostedt Subject: Re: [PATCH RESEND 1/3] locking: add rwsem_is_write_locked(), update non-lockdep asserts Message-ID: References: <8e343ccb9319433364f5949a69519f1bb521fc8a.1768569863.git.lorenzo.stoakes@oracle.com> <20260116151215.GH831050@noisy.programming.kicks-ass.net> <99818e30-9f88-4751-af82-0bed019156eb@lucifer.local> <20260116155743.AuMKcTAO@linutronix.de> <5ca7b2a2-1e9d-4d90-8459-1aa35b30b49c@lucifer.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ca7b2a2-1e9d-4d90-8459-1aa35b30b49c@lucifer.local> On Fri, Jan 16, 2026 at 04:21:29PM +0000, Lorenzo Stoakes wrote: > On Fri, Jan 16, 2026 at 04:57:43PM +0100, Sebastian Andrzej Siewior wrote: > > On 2026-01-16 15:50:24 [+0000], Lorenzo Stoakes wrote: > > > No, but we need to be able to assert that one of two locks are held and we > > > don't want the failure of one being held to cause an assert when the other > > > isn't. > > > > But why don't you use the lockdep based check? That assert only ensures > > Not sure what you mean, the checks I'm adding don't exist yet. > > > that it is locked at the time you did the check. This does not mean you > > are owner - it could be owned by another task which is unrelated to your > > cause. > > Yup I'm aware that lockdep tests more than a simple assert. > > I wasn't aware this was possible with the lockdep primitives, mea culpa. > > Also this came out of a previous discussion where I added a similar > predicate vma_is_detached() and Suren suggested similar for the locks. > > Anyway, I went and looked and yes I see there's lockdep_is_held() for > instance. > > However, I'd STILL need to do what I'm doing here to account for > CONFIG_DEBUG_VM && !CONFIG_LOCKDEP configurations right? > There is an idea about a light weight lockdep where we only remain tracking the held locks in a per-task stack and skip the whole dependency checking, that would provide lock holding information without the full cost of LOCKDEP, but that requires some work and I'm not sure whether it fulfills what you need for DEBUG_VM tests (each task_struct would have some extra space and lock/unlock would do extra book-keeping). > So I'll respin later with if (IS_ENABLED(CONFIG_LOCKDEP)) ... > And sprinkle with some lockdep_is_held() and see how that works. > Yeah, for LOCKDEP=y cases, please do use lockdep_is_held() or lockdep_is_held_type(), those would provide the accurate information. > I mean rwsem_is_locked() is already specified, so naming is going to be a > thing now but I guess: > > static inline bool rwsem_is_locked_nolockdep(const struct rw_semaphore *sem) > { > return rw_base_is_locked(&sem->rwbase); > } > > static inline bool rwsem_is_locked(const struct rw_semaphore *sem) > { > if (IS_ENABLED(CONFIG_LOCKDEP)) > return lockdep_is_held(sem); > > return rwsem_is_locked_nolockdep(sem); > } > > And obviously equivalent for the write case is what's necessary now right? > Assuming we want CONFIG_LOCKDEP=n cases to work without extra book-keeping, I think we could use rwsem_owner() for write cases, and name the function as rwsem_is_write_held(), which tells you whether the current thread is the owner of the write lock (we are lucky here because rwsem is one of those locks remember their owners ;-)). This would cover the use case of MM without introducing another is_locked() function. Peter & Sebastian, how do you like (or not hate ;-)) that idea? Regards, Boqun > Or am I misunderstanding you? > > > > > Sebastian > > Thanks, Lorenzo