Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2616745rbb; Wed, 28 Feb 2024 07:24:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW5z/HqsXZKq+3djjtLAJzbZkBGcOYbxOmMGLb7TW6v4vm30jRjSLlE64yVDDjPsVCdUefp8MpLPDM+BtrF3xCH5yTevDXmwTFYLTtzcA== X-Google-Smtp-Source: AGHT+IHUHOJl/oc3kkQJqThZPTFRii0o/sby8qvEN9km5zVXDRHUuMsNeCyhGUkDOgI8UiCgridK X-Received: by 2002:a17:906:ce33:b0:a44:1fcf:9b97 with SMTP id sd19-20020a170906ce3300b00a441fcf9b97mr24482ejb.24.1709133857686; Wed, 28 Feb 2024 07:24:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709133857; cv=pass; d=google.com; s=arc-20160816; b=CTd5mq9kuBJ/P0+UmE+whfTSK5vgczrDGdwaebTDrlYsf0if2/iNLWq2e/XX3JQSBW kQW5pDLqmPNInqEN8ddZ0QlTgzt0dxlGWe2FQ3F7fvu4MgGgqzNKTeFRzzebIYoTC/kb EYmWCqeofYhEcRdTtNULoELKV7KP685f2fW2Mi4SxgYdPrTiTD6a/NDmUpWN7r1uHzWu zpGPVR0TIRJMa7bZXCKsMFH0cwY9rMPb1K+r2KMSLDqXXja3Uo6g8OieAobtGjSk/RDa CU9T2eESfSSsTNxv/Z51qBEJjVhL+nPUXNtF8F4CTi4IYxFPXxhyPQtT5qchQoKeQ2yl Ebyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3ehB3JpwRymg1TYF5t3hxiEfGc+bqJjBOoTcqkFo59Q=; fh=8B1rfjOONMus2cVHZEABi4VuH18RR4Q/AbDJzzkLlYU=; b=AQgdSJGZRu6c9WgmXO8kD1X5r2RqUCVcERncXVisAVViAQc8r/t8Hl3Gog+aWeOH7/ IKr69smN2z/pqeZLCjbNbEYdKQeIkCwVT8DAk+u7QpdZKF/aYxqkG5nBP1bY3KEUpSYG dsejvLZxRa4ksIymsznD3M7y3MOi90JLW3vUa+8Tu+PRJHbGY4lo7SAQIlZ1k+xuAxaM mvogOGR9aLYI3cnB4Fg2riN5K0c7lT1IVWhZ1XrYwMCH29Cp8lyxifA+DhTIUnwz0mzh zpABNgUgOd1iyl3uxiWlZPIae37DJU7TlIURDTsTsFLDorEyhuXjsZxKA6sggRoAaHCr 50zQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ez68DcuL; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-85257-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85257-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pj7-20020a170906d78700b00a4429d64635si5506ejb.750.2024.02.28.07.24.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 07:24:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85257-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ez68DcuL; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-85257-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85257-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 580C81F2468A for ; Wed, 28 Feb 2024 15:24:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5085415B99B; Wed, 28 Feb 2024 15:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ez68DcuL" 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 4BA3D612FC for ; Wed, 28 Feb 2024 15:24:10 +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=1709133852; cv=none; b=RtLAURbfKKsesU9cnc4Z9NSGwxyK/7e7x92/ZFWryBUu65ceLBA0NvJoh/qIiRhUtrzKn79i+mPLVTZJsqBsOWbH9QnVdtOkbdttlDwrFEdE+tkJ6Ej7t97K4B6TvbAv2c9X8vLYshM85KOy3iGi1+9WbFo6nVNwaaFj8A8SAc8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709133852; c=relaxed/simple; bh=5GeP2XG7v7dx7ZFOk1hq4cxp31+uOLrX3m4TokH17kk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QKj3JVY7mjdTesY67iMD9hFlGP+hBGxCi95qfqc4wSMLlFLIh3z+EHBDE1HofQ0hg56R7xjBpnHvLtYa4cQPCLsAQEURDJPE+Yr8A2GcLVSi/qRSL7+sXphViXT+mIIkorjRYofi75Cm7Fhw+sdaGUcCpBOLVfGLlDkMYWCMCDw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (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=ez68DcuL; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=3ehB3JpwRymg1TYF5t3hxiEfGc+bqJjBOoTcqkFo59Q=; b=ez68DcuLmefJzuWkWivyBEJAlG T+NXerCLYSu7LaLTVCkpWeSllzPcbel7rYe07ifv6MR8eEWkLinnLZz0SoK2TekcY4ceGRq3cXYsF Eth1QTsN8GV1t5UOQWbl+9n6RJPRjaosfbKS6R6zv3sVQSYqsNPxM/1e1ulYXlhS3mIia+kqX5iqc +vETEsjdhYmjGC/EIV4WkH6UUSkzPMAooz210L+XSl8Dl09O3G7FgQuD34fdsru7C8cvVXUOuDoU2 BP0VE0BnLB5wHjVXh1fMD942xmZPXU4gF53uGilQFTJKJFLVtJuykOnPX0lPYirrDM5LpIA6kpfRI 47lKUfZA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfLmw-00000005WZ4-3nu3; Wed, 28 Feb 2024 15:24:06 +0000 Date: Wed, 28 Feb 2024 15:24:06 +0000 From: Matthew Wilcox To: Chengming Zhou Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH mm-unstable hotfix] mm/zswap: fix zswap_pools_lock usages after changing to percpu_ref Message-ID: References: <20240210-zswap-global-lru-v3-2-200495333595@bytedance.com> <20240228151832.2431993-1-chengming.zhou@linux.dev> 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: <20240228151832.2431993-1-chengming.zhou@linux.dev> On Wed, Feb 28, 2024 at 03:18:32PM +0000, Chengming Zhou wrote: > Now the release of zswap pool is controlled by percpu_ref, its release > callback (__zswap_pool_empty()) will be called when percpu_ref hit 0. > But this release callback may potentially be called from RCU callback > context by percpu_ref_kill(), which maybe in the interrupt context. > > So we need to use spin_lock_irqsave() and spin_unlock_irqrestore() > in the release callback: __zswap_pool_empty(). In other task context > places, spin_lock_irq() and spin_unlock_irq() are enough to avoid > potential deadlock. RCU callback context is BH, not IRQ, so it's enough to use spin_lock_bh(), no?