Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1823893imm; Mon, 3 Sep 2018 10:22:21 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda7LdAAXXkFS0l4G6MS7o4N0hVDcKXbVViZgugt7KDVqj8xGeTbV/5X/ULdNoqHGylAfbt2 X-Received: by 2002:a17:902:bccb:: with SMTP id o11-v6mr27141929pls.167.1535995341816; Mon, 03 Sep 2018 10:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995341; cv=none; d=google.com; s=arc-20160816; b=j+Cv8RLYB1vxxvwQ1zhCD3Ed2BNjWVyXM3BbiDVYYaVQ4Nvdgq3qr4eYDJSSxLJTRB JgRMYapne4UiDVeue5xH55e7IMVYjd8FB0Wq49rgJGc2X3OozKDKcudftzfNyReJdQpe qcrsYG6mIdHhXhUCg12iMXES/L3/pxHh6uAmhz4wuul1Eo99g+EKyaJBFxiifVZY08zM syFHLl0JEGJch8gjNEqqj521A3KrnfDEf3FBigYicZPKzLwy+quYF6EVu00n69KtY9jO jeHciKbypd3H4G183ta0kDhgig2ess9FxvPvfJKiL0BTla9avUWDbW+fvHLRrqDDhG2F 1WYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=X8AZcnDm9E8A7jozY5JPKmtL7YiQj0e8xYXXZOl8wh4=; b=kGpOtV1NeKSkrNsf4+G5Y8/ydYxaK3CeEkVeTsgJfvwclEtNyZGHYx2raIhYFQrXmF HxNs1XEIa4SObNgZIS5liNn5LJTQ6IrVzGID6b9wRk0piveW73wxTOhBxh421BkEK+1g mGXZ1dpSUnwP0XjZ2B61RXXKxuYHf1XLxr9D46SxMchbUvOoHEs9SZwfltqZ14rZRGPP Ul7iPWFsX8fIBLfgSBiTaEQqj7uK0kv5rKpaDB32XCxFCUuwVn18hcbRLXLd/ccDnayP 8/3gFlzaugnvkak/EgCYIZjBBUHoi01KsuR46PbA99wB0XCGqqkMH63mU0+jTCf47Vxw fz3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a84-v6si19308449pfj.300.2018.09.03.10.22.07; Mon, 03 Sep 2018 10:22:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730359AbeICVjj (ORCPT + 99 others); Mon, 3 Sep 2018 17:39:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43072 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728036AbeICVjj (ORCPT ); Mon, 3 Sep 2018 17:39:39 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3A0D9D14; Mon, 3 Sep 2018 17:18:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Wang , Dan Streetman , Seth Jennings , Huang Ying , Yu Zhao , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 057/165] zswap: re-check zswap_is_full() after do zswap_shrink() Date: Mon, 3 Sep 2018 18:55:43 +0200 Message-Id: <20180903165657.985743003@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li Wang [ Upstream commit 16e536ef47f567289a5699abee9ff7bb304bc12d ] /sys/../zswap/stored_pages keeps rising in a zswap test with "zswap.max_pool_percent=0" parameter. But it should not compress or store pages any more since there is no space in the compressed pool. Reproduce steps: 1. Boot kernel with "zswap.enabled=1" 2. Set the max_pool_percent to 0 # echo 0 > /sys/module/zswap/parameters/max_pool_percent 3. Do memory stress test to see if some pages have been compressed # stress --vm 1 --vm-bytes $mem_available"M" --timeout 60s 4. Watching the 'stored_pages' number increasing or not The root cause is: When zswap_max_pool_percent is set to 0 via kernel parameter, zswap_is_full() will always return true due to zswap_shrink(). But if the shinking is able to reclain a page successfully the code then proceeds to compressing/storing another page, so the value of stored_pages will keep changing. To solve the issue, this patch adds a zswap_is_full() check again after zswap_shrink() to make sure it's now under the max_pool_percent, and to not compress/store if we reached the limit. Link: http://lkml.kernel.org/r/20180530103936.17812-1-liwang@redhat.com Signed-off-by: Li Wang Acked-by: Dan Streetman Cc: Seth Jennings Cc: Huang Ying Cc: Yu Zhao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- mm/zswap.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/mm/zswap.c +++ b/mm/zswap.c @@ -989,6 +989,15 @@ static int zswap_frontswap_store(unsigne ret = -ENOMEM; goto reject; } + + /* A second zswap_is_full() check after + * zswap_shrink() to make sure it's now + * under the max_pool_percent + */ + if (zswap_is_full()) { + ret = -ENOMEM; + goto reject; + } } /* allocate entry */