From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 956313B2D39 for ; Tue, 28 Jul 2026 18:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785262511; cv=none; b=fyfz8dXpruYaFXVY8PoGa1PUuNotwtyI6sI47/4/olVLd1okvwC/xbUCh66pril/7un2VL5PR11IYZUT+1r2vCCbpJDueJGoF4S45CymiMGxy4DuaxEJmJ2+tyaXnfE9V7c9Mx1ELF8Vj22vVvwqUGF6wFuT8aPJWqLAk2p8XT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785262511; c=relaxed/simple; bh=7yo1/wxxX0avmeIn/u+tdQJiOjVaUMyL9zDGurRyvvU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ZJyIUOEmthxh2I5uKHyV6XQbJyK0zHipqCThzmNKQ34oCYWAfBrju7HKxrIAqc8qEfEsmjCUqe/iU4fjnIU+C+rc0e0g8GMgrbf+ynRvlmRuwCNqg3uuwLuUrtDnIPUdYH/t4cc4VlkYPnRlGsgnc9c61gXCVtpQdlyCfBZWo3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=tbnXTxsI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="tbnXTxsI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F31B1F000E9; Tue, 28 Jul 2026 18:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1785262510; bh=tfLF7mqnjfhVZ6mNYMfhMtjyLHsLVBucTBizJSDdT08=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=tbnXTxsIdrPeQzZZsgT1xzf8SmaRoFK8BDcv/zW6vHZKJHzEmkJAzTUD1iHFWwR+z 0UTejys414ULQoJityXlxPAvxsL5rtb/0sB9MKMoJMuo3fsXEvk/F2t+Q4mW3Y4BmO BPpwGrQLkFakBaeIDUV8PnuUJOpacAJKaJYI8JDs= Date: Tue, 28 Jul 2026 11:15:09 -0700 From: Andrew Morton To: Richard Chang Cc: Minchan Kim , Sergey Senozhatsky , Martin Liu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/zsmalloc: fix release order of locks in zs_page_migrate() Message-Id: <20260728111509.7662e385aea0b055d2066e1f@linux-foundation.org> In-Reply-To: <20260728055333.421080-1-richardycc@google.com> References: <20260728055333.421080-1-richardycc@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 28 Jul 2026 05:53:33 +0000 Richard Chang wrote: > In zs_page_migrate(), locks are acquired in the following order: > 1. write_lock(&pool->lock) > 2. spin_lock(&class->lock) > 3. zspage_write_trylock(zspage) > > However, upon successful page migration, they were being released in > forward acquisition (FIFO) order: > 1. write_unlock(&pool->lock) > 2. spin_unlock(&class->lock) > 3. zspage_write_unlock(zspage) > > Fix the unlocking order to release locks in strict reverse (LIFO) > order of acquisition: > 3. zspage_write_unlock(zspage) > 2. spin_unlock(&class->lock) > 1. write_unlock(&pool->lock) > > Releasing locks in reverse order of acquisition adheres to standard > kernel locking hygiene, prevents potential lock ordering and lockdep > inconsistencies. > Thanks. Does this actually fix a lockdep splat? If so, is a link available?