From patchwork Tue Mar 4 09:21:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 14000268 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 D763720298D for ; Tue, 4 Mar 2025 09:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741080355; cv=none; b=p81ewU7GD7yRfEYIw6yfWs8HmgYP2NYya87ERgbzyxF295nXuUk7gQTGCKxQ80pQ6WBAjQQD+mu3rkOb2Xz/0ROaMQ5V3rhi6NUfHvVwwcmXrjVJBa/mNEudK7zd8/p1Z0u4PMjfn12t+zgtCtZOelDPWYIVV6S69KIiXUm9LTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741080355; c=relaxed/simple; bh=PiALtBw0DYxsKuBO8J1H1AaY1cU3EmQ3QqFWUaJ2ULI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=frkJgB2+mr6Ox7/K6HAwRquKTbYueI+XjUdUXfy2jexhTzEpIUVjFZfsT3Rf0Hnhgv+q2f5FSd6pSdtOp74HaZOeyyZqRsA6yKQ7Lr8+MJALqPdrhGPQdLqNvAy6r4I4WYDpv3ze6ZnsXtm8OLuQ/SoTmW8YFRBgsKWCLdAgIF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--elver.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xseS9zns; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--elver.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xseS9zns" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4394c747c72so21150685e9.1 for ; Tue, 04 Mar 2025 01:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741080352; x=1741685152; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cDlOE/N8Ae1M5H+4yLEwuBDz/LRLExYZEp/cosJZ8Bg=; b=xseS9znsQ87t34sYX/gUp0g2hQZ/UNonxdPqn5B7LJMZ2/n7mRqN7ey1N4I8/VvGVt wcqf61xpLrOaUgfB5G5XrT8rOSZRNnLb2FSitfzM+H6koewUYHd0S6p6SgDDtZFjjw2v ga4SWEVQifSr2qCCjU0KUdxhurb8xDPE+OxbN7/QDf4dVDhNGp6o7JXxe8nDqH0SGobz lNlVgFk5sBuAoTqrKl1j8X+4hLptwTCAuGatsEJ28qbXzZ9wbk1D4H56dU0F19rDETHD 8tyMll8rxrEUkc51aH24J2tE+Ah6qHHSVyCVRdLZXRhZsxTzKw3L2W5RpkrxNf8Tprgs WjJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741080352; x=1741685152; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cDlOE/N8Ae1M5H+4yLEwuBDz/LRLExYZEp/cosJZ8Bg=; b=jGe5M5Y3pTHU/qWtALM3gPe0QDGErWDTXeYBjMsznXZt+DNbwsUTAxRbep/s/DzEEa 7nse51Kz5ESAxY557WLhZuPBFGqO174LpNBAbSbEIyKctGrFS7wW5+xaqjXZxu6K0jJW VsOjshin3PYe3pDEus4JkNBFhg5Yv8bsajGdYQUD+80lTlRcelHzAus3YPlmxYEbuaUQ 55piqGkFk4QNYLoeYeJuNXFu2HEoDdAaoVc4TsPfs1QjvFGHCP9X9QHYwV4RjjpR8uaY S/sqiUMD98E8BNpaSYr2NL4gbtln4Vhbwp4X3T7SjmSBgR7gTUzSd8w0s+TyTRnryrbN x4BA== X-Forwarded-Encrypted: i=1; AJvYcCV0KVINGJ5qBhoeB22avSlcUZ+5HzqFgGJiWlA1sQ3j6DetyzWl2uvhZLqVzv2TroLmEi8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz52ixKaXY7LKjx5KaEX/MAFMZ9M7BSfJlLJ5Uq/2e4dmiNExta d3OtzenZosfcVOj/emWby+/ETfU3orYTcmcdDIrCNd+kwtIR5a1DyTawghWEmZvgUWEdSOwFuA= = X-Google-Smtp-Source: AGHT+IHedqiVSmrcvr28lGY8V3DB1o4f03/YwjOgy/3VYsVwJNq1WARMZql7ViymW31VHT1lz95raXYaUw== X-Received: from wmqa13.prod.google.com ([2002:a05:600c:348d:b0:439:64f9:d801]) (user=elver job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:190a:b0:434:a4b3:5ebe with SMTP id 5b1f17b1804b1-43ba675830emr110121215e9.24.1741080352374; Tue, 04 Mar 2025 01:25:52 -0800 (PST) Date: Tue, 4 Mar 2025 10:21:15 +0100 In-Reply-To: <20250304092417.2873893-1-elver@google.com> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250304092417.2873893-1-elver@google.com> X-Mailer: git-send-email 2.48.1.711.g2feabab25a-goog Message-ID: <20250304092417.2873893-17-elver@google.com> Subject: [PATCH v2 16/34] kref: Add capability-analysis annotations From: Marco Elver To: elver@google.com Cc: "David S. Miller" , Luc Van Oostenryck , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , Bart Van Assche , Bill Wendling , Boqun Feng , Dmitry Vyukov , Eric Dumazet , Frederic Weisbecker , Greg Kroah-Hartman , Herbert Xu , Ingo Molnar , Jann Horn , Jiri Slaby , Joel Fernandes , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Kentaro Takeda , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Peter Zijlstra , Steven Rostedt , Tetsuo Handa , Thomas Gleixner , Uladzislau Rezki , Waiman Long , Will Deacon , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org, linux-crypto@vger.kernel.org, linux-serial@vger.kernel.org Mark functions that conditionally acquire the passed lock. Signed-off-by: Marco Elver --- include/linux/kref.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/kref.h b/include/linux/kref.h index 88e82ab1367c..9bc6abe57572 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -81,6 +81,7 @@ static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref) static inline int kref_put_mutex(struct kref *kref, void (*release)(struct kref *kref), struct mutex *mutex) + __cond_acquires(true, mutex) { if (refcount_dec_and_mutex_lock(&kref->refcount, mutex)) { release(kref); @@ -102,6 +103,7 @@ static inline int kref_put_mutex(struct kref *kref, static inline int kref_put_lock(struct kref *kref, void (*release)(struct kref *kref), spinlock_t *lock) + __cond_acquires(true, lock) { if (refcount_dec_and_lock(&kref->refcount, lock)) { release(kref);