Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1806623imm; Mon, 3 Sep 2018 09:56:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZXBLoqpUXaTR6A64V/ZhaHPwq3nqDC+mDagrNnlEwdG+STZJTfix8Pimcawd0clB5dNZQ7 X-Received: by 2002:a63:a619:: with SMTP id t25-v6mr26825776pge.288.1535993802469; Mon, 03 Sep 2018 09:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535993802; cv=none; d=google.com; s=arc-20160816; b=LIyoHuzthSvHGORJE2dZwbPribJWIPxXpj0NltuLmbO1fzsPuNIp+8I+txhKo7VeVn PZ/nUDpRlT3yXusX8HcZT3y+TYKJ7oNDKWXlesmxEqjMywKete81iyJUCmyUrpDSomfu xzguOY4n0BOBP3lQZnnS/VSKJlxq8qixNZrLEs3ZtdxomzlliocCeSH4qfJwcXkR5u+1 e0KQrNRsZwDd3Hp0LBCO0t1R+gNo8xSBEuNmkp2ZO5FH4fD+ZDmALFms3XUA5vbVvlf6 IDDv5iXi8kdzavAf4/XQMsTB87G0oDfVku96eKMrMarNs2IBo3MUhkySfKtWfZD3hck4 nOnA== 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=41fjz+mB9cUKFEwygLk7IEPoZCdBjN03LwBMtngj+uw=; b=xwWZM83kjZEcfhdmBtMtZ3iD32w97k2trIQ0WGWfrY5Tulezyr7lctRFDq7VCCezld 78PDKbG/TzO6+/TAbjiDLDN8gdG4aP2f7E0cACuHpJHD55b3U72QdVFxbRpFjOz54FBm idzSc0MefECEDP+mz/OLAD4/BPh7RRoP1goNizXYWiG3P+XRrTktK+uV4hSLvzB8Z/GV yVKgcGC2e1o9IKnyeqPNrpRIWiXeoZ0bxkmJVE5Qy4sRpuSLTIi5JNtV9VGZvE3g2wuh th8A1/ysJKblgzuoS3E+z3xhz+NEhmiuwpD188pBH4C+BEgKlnP1NCylU32oj/tAPFZ4 JfqQ== 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 e10-v6si18839490pfc.51.2018.09.03.09.56.27; Mon, 03 Sep 2018 09:56:42 -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 S1729053AbeICVPT (ORCPT + 99 others); Mon, 3 Sep 2018 17:15:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38322 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729026AbeICVPS (ORCPT ); Mon, 3 Sep 2018 17:15:18 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 02A0DCFB; Mon, 3 Sep 2018 16:54:21 +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.4 31/80] zswap: re-check zswap_is_full() after do zswap_shrink() Date: Mon, 3 Sep 2018 18:49:09 +0200 Message-Id: <20180903164935.397528680@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903164934.171677301@linuxfoundation.org> References: <20180903164934.171677301@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.4-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 @@ -1018,6 +1018,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 */