From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 7C91C348C54 for ; Tue, 28 Jul 2026 06:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785220805; cv=none; b=f6hUPqp+GVDGkm3M8uCD+WLMEgVr7TUXE9zeXekxsGsw9LTul54ffKV+TbpnqiDwmIm8D8Kw3h8LoaYTtp/eCFfnn6Qzrd1cDvZd9oglzKBSrae+e1dqi8jQj2j2VdqJC+v4EkfBuD+WBrMuRLUWakPjkMxffAJBZukdDZygK68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785220805; c=relaxed/simple; bh=qIwzK5VTd0T/iG7bML/dQaDfE/4cLSN0m2Q8kQST6aw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TkYOKfUFz2Wqg6e2PVmSjT2KJUZ0eYQmicJZI4uqieYXF+xWcBvPXOsBL+taUrxJPCmWQ3vrbYoZMw+T5afkGxNj1p0x+hbeXgmWrHv4aJzfP/xMunRqQaDsvZyrDjgCuUiuhN91ZFo7oetZYEg8k4C3C4+cQcRpu8w5S7UL9eA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=PWD1XzjC; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PWD1XzjC" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-8484f229529so2385274b3a.2 for ; Mon, 27 Jul 2026 23:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1785220804; x=1785825604; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=O5vL8K7elVixiyioHzvpuSpD8hwQ+IAvP7Z0RgBWZFo=; b=PWD1XzjCI7jCk5P9XEuWBNyDhD41DAyJf4QcHIq3H2fAu3yHk1XsbLiGDFpTlF2Eve aUmD6bh43qgrdfmCuB1EzChUaNwpvFVjwqpgq/3gyTWzUx5RCtwL8cDjpBCOGlQvEkja 4kthFb1kpT6ar+ZlMWSuUyJ/5WSHpoygCK0JY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785220804; x=1785825604; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=O5vL8K7elVixiyioHzvpuSpD8hwQ+IAvP7Z0RgBWZFo=; b=PTrhVrRCYsQBH69dZNfYP+ybA6iX6NNgoBe+O6Iuln6KDmMPrqCYobQ3geYMrDqalH Wfkb/twHQvwdIF9wHhRbeMi2ULUXOPyHHVOb66BzLGhZ4Xe5Q0nZTtJaRfYQISJRfz5s 7A4/LyT4cSxTblq859HCX/b82RIS2B01KW0e4xH0b5Y15JDTnQ5/odSc0zreHU6YQK4J kSMqBWjws356G7/s5NtUMg+2HOi4z1f5Lqn+6suHgOUriFovkfrJpiaVw2LhWlzCkcRo aHUctPTw87/2gbLMDo2fb7wbLBBeTlsOxVvgFxNo+FbBrdvW6Jxl7mMeardtTOSrXM6p 7+bg== X-Forwarded-Encrypted: i=1; AHgh+RpqF/+eQHv9AO8induTJ023BJlDgDDxb7QjkMDcugp3cHtsHtzQqY19WhlejYHaG5G38aYmSObCyuVU76E=@vger.kernel.org X-Gm-Message-State: AOJu0YzN0yiNDAew5dQcsi1WBOgy4/+JJbEY+g3AWZLR0WXTFVo3JgxC 9PumP9Dn1+xRqKsAvqzvpkQS/fsZLOPTjuKC+uPZA1Sl4ZJNQFstEE98f8NtLIglWw== X-Gm-Gg: AR+sD12vQ2yWys7CQBlExMPPDGaavAdjCM9Cpn+r2GY+3IEbpqbTcMNV1va7AkoIeMH NC71JYhb/PUIRKViehchQR+f5tB+jFXsQTTiB9AzYla9nG7Jzutq+2U83qUHTP088HBcOepVcFV ykonLeZ+1hujpf8TK8mpDNJte9xp/ZJJBtAyDTgxxRtANumMjW1ZvSCfuie2Nb/c4fqfTZtPOH5 UYdv8pzqxHm8ZYhNdU5LA2rgFCBttkipnacBkNizK60sTzexM0CfDf1NBAqmQgRni09XtKpM2ab 2ylc2SbDfq6g/eHwzKSK8UBV5lsA1FEdVKe4ccwMLUmGEt/I5JWK40yvcynV7xxG+T6NzB8MtrU RdXam2b6rC91mrZZ7qJjy9MQal9GUQMasOQVPtmEEZOe4tZU0+58zdfd2Tfr1XN9ej/JHDZ4XEe ufDsLGwDl0mP1KKssDCL3UwI3dLOJcgPB0lQkU5HiqSiY/FHZVILyJckrWFUA2tRrLPdWQortTa VeiuOgnleP4yE47VHYF70S7/EtM X-Received: by 2002:a05:6a00:3992:b0:845:e8b5:8c49 with SMTP id d2e1a72fcca58-84e932c585bmr1091894b3a.10.1785220803771; Mon, 27 Jul 2026 23:40:03 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:f891:e0e8:e2c3:fb20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84e532ad0f2sm3878806b3a.25.2026.07.27.23.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 23:40:03 -0700 (PDT) Date: Tue, 28 Jul 2026 15:39:59 +0900 From: Sergey Senozhatsky To: Andrew Morton , 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: References: <20260728055333.421080-1-richardycc@google.com> 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: <20260728055333.421080-1-richardycc@google.com> On (26/07/28 05:53), 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. > > Signed-off-by: Richard Chang Reviewed-by: Sergey Senozhatsky Tested-by: Sergey Senozhatsky