From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28406383336 for ; Tue, 12 May 2026 16:55:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778604928; cv=none; b=cLI9shfn+WQf1J3kEA50pJHwDkoobM3zVngoV+/KNI6UDPemKsk/8WWAaelgU/S+rCgDAycwnxbzGTBDDfagigRf8UCxKhHZDe3lktocT+vBgxLuhFLFugkGeyKcCIz2gk188qiyjvZ2eXD3Jn1MRCKCEQ0OHuykAvYLcbXJUqA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778604928; c=relaxed/simple; bh=r4tcxZgp1ybNmJ8uVRiys9e2bDqTumapDYWpMrxS4Mg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WQGGA3F0wBP/UIlKR19cyu6VusL/ae9KqqgL2ww2Zv530U/BOJ0XqNKEFfwAew5sfP8liA/4fApPGV01VSdl08anthk/6+1Mz+zh0RkQtwMq3YL5bylAWKnNsMfmnSjowf6O6HLKokr2DLTGYp1Pl5/lov1InJjiVmdyEMNw5ns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=vdATVuB7; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="vdATVuB7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=X0dN4DlT6Bj4xL0vyul4uKH/KmeQHvtJzrS4IxisTag=; b=vdATVuB7XZuJfgFexUCjgdf3Er ubnpFFDU209Jzy7e80hwVXdOrjR6fagWVWzT1XjQ7M3vCdKSHlCINuvCz4aSfj+q3xICY88wajRjA 0FRx8Ne6bBTtNMhHlAWMfuawZVqvHfE8no3jgjzgYt2JSAQfpmzq3LuZbi/rksGSwhKEy5VIcw8iS eOGuY7QcEjYpTuc6V3u213rFP9CT5TaCvfhiPcLSH/X4IfxsFOY8GHXPyB7Zq2frDRIYjdUOH6ywE LDcT3zPl+cyIXQkMNKWda61fSFte8AAte3oKIUux1gPHDE7BBv8hHUYw6Q4x3iwKF/53QK2lQeSrB QJ6S8QOQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMqO4-0000000A1xT-2BEk; Tue, 12 May 2026 16:55:16 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 2FB10302F8E; Tue, 12 May 2026 18:55:15 +0200 (CEST) Date: Tue, 12 May 2026 18:55:14 +0200 From: Peter Zijlstra To: Dmitry Ilvokhin Cc: Christian Brauner , Dan Williams , Dave Jiang , Marco Elver , "H. Peter Anvin" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2] cleanup: Remove NULL check from unconditional guards Message-ID: <20260512165514.GC2677887@noisy.programming.kicks-ass.net> References: <20260512071510.92451-1-d@ilvokhin.com> <20260512124557.GD1889694@noisy.programming.kicks-ass.net> 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: On Tue, May 12, 2026 at 02:37:25PM +0000, Dmitry Ilvokhin wrote: > On Tue, May 12, 2026 at 02:45:57PM +0200, Peter Zijlstra wrote: > > > > What about class_irqdesc_lock_constructor() ? AFAICT > > __irq_get_desc_lock() can return NULL. > > Thanks for taking a look, Peter. Yes, that is actually a very good > catch. > > For some reason I naively thought __DEFINE_UNLOCK_GUARD() wouldn't be > used outside of include/linux/cleanup.h, but this is obviously wrong > assumption. There are cases, where DEFINE_LOCK_GUARD_1() doesn't fit > callers needs, so __DEFINE_UNLOCK_GUARD() is used directly. > > - kernel/irq/internals.h: the case you pointed out. Can be fixed by > moving the NULL check into the irqdesc_lock unlock expression > directly. > > - include/linux/tty_port.h: similar use case. NULL check can be moved > into tty_port_tty as well, similar to previous case. > > - kernel/sched/sched.h: lock and lock2 shouldn't be NULL at destructor > time, since they are dereferenced unconditionally at constructor. > > Below is example how this will look like. Does this look reasonable to > you, or would you prefer a different approach? Yeah, I don't mind changing things here, but like I said before, only after a full audit of every single user ;-) And yeah, fixing up those things shouldn't be hard, but it needs be done.