Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp539096rdb; Thu, 8 Feb 2024 13:16:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUSZUEszFac6NVpg9lvq9/MjKHIW2NvC0bzWA4erGLKfulJREbKWhFHCD4tFNT9R4qCapmb3/aq1R7YOm1owUqcdR3CqL35FQBE2jHdqQ== X-Google-Smtp-Source: AGHT+IG46Q/XKFpyN5mCPWJmeUFEnetmZdz8TioT9CqtrYD+ggZxPmC4h1M3c5RSqDaQkzqiDHKB X-Received: by 2002:a2e:a16b:0:b0:2d0:d802:858c with SMTP id u11-20020a2ea16b000000b002d0d802858cmr293650ljl.28.1707426979502; Thu, 08 Feb 2024 13:16:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707426979; cv=pass; d=google.com; s=arc-20160816; b=tCZdXJOSYfR8SPhM0SZgrzD0Q8VtVhuJAhx9F1Unp9AdAKzpS7gf//rTsqMh6WtNbP kP/Vv527Ayg4QhDJzTjBrHYy29ZxN56WG3sz1JhSQUbpxIJOeNkc9TYCtN5wPgQUVBbM iwVijLLVPy45bOs5o2S9p+VMvcfx5gG3EsY1y81zO675AWtjcZNRnIygPc06Ndyg82N7 apuSQ3vfuE2oLRo5wi5OJMP5WIYg7PPDUdZeffJY8/MY5bBUDkTk1hwxCClVajDkcOs+ v6mhxzkgAAbcegbPkHcgVjgDywnEnJkRah5Vq3Q27nax10HDXbNlF5W0SkQqtyfCt09X YNHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=dFS64PqgkaWAB+Cp9oN8EVdVWhUxC0PapzNwidWAjP8=; fh=qLppm4IuHZPaLnBR/ew9RwYoHEqKZs/Uf0Ny1jaTKJ0=; b=LH2JY9x2WjqW2SbXjOo0UUlVDrJhGM9OWeiDxkU9NHZPODQ+P+NqKz1igd1LcW36IO jHMs9ZEGg0WLmacOni0hroV/lFN65Wag1bMMbpj96q0yf3EsmmyEUFRMB8g6JS60JA4R eE8ThSVQlewXs+KJP3z9HQvLL44XGp4K9KJLx1XghDrFcrm4yE3dL1a9UTHonFAQ5xcT AfQ646NqHqsosHRvq0RlUe5jT2jbJoKGaeaSLhffmj1XcsRrKJKXmhgl7LKOpbJng4hC +ws1RtHbNZTg08Ir/TZw6NMghACIOQiAPsz3bUDkApWKOeIEjgqWxIQ6ax4qZAcVYeJK GDJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=StiCQOKO; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-58700-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58700-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUAF5PCN829SVaMux9cd3fLpMI60IanvQEHQM1xewmeGOIrcNE3ToXCoyARiGmXHpb94QUBOjcEmVqgSnka6izA3V9SDrNaMw+j0wagHw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y14-20020aa7d50e000000b00557ddbec291si113849edq.46.2024.02.08.13.16.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 13:16:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58700-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=@linux-foundation.org header.s=korg header.b=StiCQOKO; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-58700-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58700-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 D115D1F2F972 for ; Thu, 8 Feb 2024 21:10:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D921E4C3BC; Thu, 8 Feb 2024 21:09:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="StiCQOKO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EEA544F1E7; Thu, 8 Feb 2024 21:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707426594; cv=none; b=RNPZDFOHv4gzw3nmRLv4GpIJHcGvP2oDvEOXiEII/RsqMEwC+pvCU+vYW8k1X/mXXTqsDBLzSNN7SthqpRGfwSCgNzioavl01IxRt/8QKgC4X+VPUfqEoprUaTrHY+gSMuB+ZQiJEOCINrUWi85VWhwI4hZZIP2ktoONFEGmwws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707426594; c=relaxed/simple; bh=DzXm9EVWYa8b4QDNaxkkfMISiO9pdEx+UCn6OYF1Vkc=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=XHaJEN7ziiq5GkdJqsu1NBaqLzavXx2nmG2BSLTvqiPSkkTJfuZaMe8q4KB9g1Am+u6Ey+BsPwJv/ZjkX7SI6WsNB8KQTye03fZmU3DRIC8LQPMKL29F2GdOdnBNIK4EAMUqkP3n9XN1nL/yXi/B+edyZaWcY6KPczudd5H5QKk= 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=StiCQOKO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4719DC433C7; Thu, 8 Feb 2024 21:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1707426593; bh=DzXm9EVWYa8b4QDNaxkkfMISiO9pdEx+UCn6OYF1Vkc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=StiCQOKOn60o/hlia5zK56EIrwA/08GbVDilfw8paaGnCUWd7s6fLX7o2bi5C4lwH IT8lICT/7m64Q7XCw+lopOe2dxBk3nRTjDItlFUWTCod6j9av40zjc8sIGWvi5X9fi FBH5qknjdGVA8W2N7qsxz/z+L8gQcR7AYpJ5qOpM= Date: Thu, 8 Feb 2024 13:09:52 -0800 From: Andrew Morton To: chengming.zhou@linux.dev Cc: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou , stable@vger.kernel.org Subject: Re: [PATCH mm-hotfixes-unstable] mm/zswap: invalidate duplicate entry when !zswap_enabled Message-Id: <20240208130952.b2696eaf6a27eef9866723d4@linux-foundation.org> In-Reply-To: <20240208023254.3873823-1-chengming.zhou@linux.dev> References: <20240207154308.bc275f3e72ec1c1fd06cf5a2@linux-foundation.org> <20240208023254.3873823-1-chengming.zhou@linux.dev> 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 Thu, 8 Feb 2024 02:32:54 +0000 chengming.zhou@linux.dev wrote: > From: Chengming Zhou > > We have to invalidate any duplicate entry even when !zswap_enabled > since zswap can be disabled anytime. If the folio store success before, > then got dirtied again but zswap disabled, we won't invalidate the old > duplicate entry in the zswap_store(). So later lru writeback may > overwrite the new data in swapfile. > > ... > > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -1516,7 +1516,7 @@ bool zswap_store(struct folio *folio) > if (folio_test_large(folio)) > return false; > > - if (!zswap_enabled || !tree) > + if (!tree) > return false; > > /* > @@ -1531,6 +1531,10 @@ bool zswap_store(struct folio *folio) > zswap_invalidate_entry(tree, dupentry); > } > spin_unlock(&tree->lock); > + > + if (!zswap_enabled) > + return false; > + > objcg = get_obj_cgroup_from_folio(folio); > if (objcg && !obj_cgroup_may_zswap(objcg)) { > memcg = get_mem_cgroup_from_objcg(objcg); OK, thanks. I saw only one reject from mm-unstable patches. Your patch "mm/zswap: make sure each swapfile always have zswap rb-tree" now does --- a/mm/zswap.c~mm-zswap-make-sure-each-swapfile-always-have-zswap-rb-tree +++ a/mm/zswap.c @@ -1518,9 +1518,6 @@ bool zswap_store(struct folio *folio) if (folio_test_large(folio)) return false; - if (!tree) - return false; - /* * If this is a duplicate, it must be removed before attempting to store * it, otherwise, if the store fails the old page won't be removed from