Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1944rdb; Wed, 7 Feb 2024 18:33:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWN1fIDrKxYjb8zXTj0FzEWJmjqR/VomJ23F3EVWPaUDGfHdkUOve2UWSR1ZtTmSYZujzdj1irU0pnH+UvL14tXe7A4uReAflulSCqCXA== X-Google-Smtp-Source: AGHT+IHYMyIM+IdpVpKYQ51mZ/kfqNz+bQ9yjBn2uWkENcnEfThiZId+G08VGhR9LAKCaaC/nbdp X-Received: by 2002:a17:907:392:b0:a31:616c:7a7 with SMTP id ss18-20020a170907039200b00a31616c07a7mr5658282ejb.16.1707359610231; Wed, 07 Feb 2024 18:33:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707359610; cv=pass; d=google.com; s=arc-20160816; b=1HyfkwgINH1qMyQlmewwZJQIx53CAni/+KtTLsdikyzaTr1TnIS7R+RVes2bziN9cQ Zd0oEc1JvVmZ/K3XUzHadYcc8YYgBCDQDjIZLz9CeUpMWvgCUK+eouUBb0z+3PaJCd55 2j8H+fZclV//25Y7ISvF7aRuAo3YMGzsaG3ANYeIIBVa2TVLphf6Mxe6aOfx4OtECFX+ sfoJ/PecI+j+TJX64CoU3Fxnh+Z5bfqIuHgcKZRWrsuYpOk0JtrMwzv6gNcjl+giIAvR xZdYLdBL2DPdw+zNtrYE51u9d6hdYWQckQ0rerySt5XvmmBC4ILGilA4SEljdKh/2JSo WVIw== 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 :date:subject:cc:to:from:dkim-signature; bh=YCEnBpcFOe2C77Vjk6R5fbEVUxas4awh0L6SVKgqthY=; fh=QevaYAzDEohNApFQLEop3qrEGhT+Yb/RJn5k8RG4hFU=; b=O/mTAiGkyv1kHbpZ9cuRr9G+RtscMVA+YrH3JKuPdyvYzA5k9C7SVwUq0a8YmRe79H n1Y6Sgw+mdEgAseLbF6iVNHFUz8lhh+90X0euu7eKUFvVqgL4XeJMBtM/Yo8Mj5oHQhz 2ncBjl4ZIl26JLRDMPKN3RdC80ZC/wP+JTwn38Nwk3TKlBEAtU8N2E+0wBMMdxJzgbRy VtGLP5cYCkovjU+i+GVr8ZQ3SGXLjhNicMllDkHXjQE104C4iyD4kaEduaUWbPSntBRh bGw29AvW6eD+dKYutklYU9qLaujUqOxE/1krb/Gn1zkERGtbFx3s8t/r6DJXJzTTdPOp tvlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=weZui6S4; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-57389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCWIEV5k8KiiFcGKhhwYXMNW5K+pbxCablPiVupCNYwr5x1UK85A1igSJH0CaA11KzxpMzAS2TMXNDw/9jPq+KlZhdDEOCH972R9szmlQQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v1-20020a1709060b4100b00a3684349371si1643423ejg.356.2024.02.07.18.33.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 18:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=weZui6S4; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-57389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 DCFC01F22F29 for ; Thu, 8 Feb 2024 02:33:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 517E618EA1; Thu, 8 Feb 2024 02:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="weZui6S4" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (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 1F7461D525 for ; Thu, 8 Feb 2024 02:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707359600; cv=none; b=P3o3XDNwYrXvuZiakyCjMU/5h4xuCPHT0oDTK4XHsnB9i4An6GCQmr9ToaBVFU7BYMa73r1M0WH6/CFNFHiH0zCIYuCsayrTOfYn3E4J8FKTyGa+OBT1Gi4niR+GhZMy4KBUo8+3sWUWo71I7GD/n25DuMxm7N4LadKRliLd8Cc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707359600; c=relaxed/simple; bh=vtpZ0m9AT8C+oeZBqgjv+QOJtFQz8dCFsvLGUGtbHRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pbLeIqoa6GdGIEmjGiHvipN0QDfNLOd4rx9dc5EqcvydVEOBpf8MHgOMXogrT5pUJB3b6NhGp7CqjOr79k+Mv7inaOoYEu8DQkJ+mNtklM3Qsb9GoTGNRHP3RfceY4mW0ILBcwL509VvtLfk6oHS5tRepeUze9nt5KhX2r3cNIU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=weZui6S4; arc=none smtp.client-ip=91.218.175.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707359594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YCEnBpcFOe2C77Vjk6R5fbEVUxas4awh0L6SVKgqthY=; b=weZui6S4T5IvHb+TGoDKMyuF0wqgoxEl+MwiUCXhxT0Byj4eY3WO+9hTkCOHADRHRPdAVB UAuJ7a1R632aAgbm3fe4L57GphGBpIK2/1FzbA8KfdBeE/MTAMk568fpswQFaDvDEjISCH VGiR5eGWY7km86874ZBREE9N2wQx8rw= From: chengming.zhou@linux.dev To: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, chengming.zhou@linux.dev, Chengming Zhou , stable@vger.kernel.org Subject: [PATCH mm-hotfixes-unstable] mm/zswap: invalidate duplicate entry when !zswap_enabled Date: Thu, 8 Feb 2024 02:32:54 +0000 Message-Id: <20240208023254.3873823-1-chengming.zhou@linux.dev> In-Reply-To: <20240207154308.bc275f3e72ec1c1fd06cf5a2@linux-foundation.org> References: <20240207154308.bc275f3e72ec1c1fd06cf5a2@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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. Fixes: 42c06a0e8ebe ("mm: kill frontswap") Cc: Signed-off-by: Chengming Zhou --- mm/zswap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index fe7ee2640c69..32633d0597dc 100644 --- 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); -- 2.40.1