From patchwork Thu May 24 09:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 10423595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13E246032C for ; Thu, 24 May 2018 09:58:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9E0129153 for ; Thu, 24 May 2018 09:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE15929343; Thu, 24 May 2018 09:58:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CFAD2932C for ; Thu, 24 May 2018 09:57:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E86866B0010; Thu, 24 May 2018 05:57:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E0F7E6B0266; Thu, 24 May 2018 05:57:58 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD8116B0269; Thu, 24 May 2018 05:57:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by kanga.kvack.org (Postfix) with ESMTP id A20C56B0010 for ; Thu, 24 May 2018 05:57:58 -0400 (EDT) Received: by mail-qt0-f200.google.com with SMTP id y7-v6so766089qtn.3 for ; Thu, 24 May 2018 02:57:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=OWTqP9a4Tspk64NIjXJAb1qHzFZzTpLN1zOrq49No6k=; b=BErHHJ5jOxpfws8V0hWWH5ou5uSwXheE37dez7QzhFjJKiqdHN026wH5VCDGNF2fnU vJiz/aj0Sh9ARmgAIlZGRjjjsSs3/7+jK20EAvFKTIZqobyRwOhZOVhJiaxLdIyecneY 2zYYNnUqCxJUg+dUdOEQYuMa4aKnc/lFvqFBYPOajKajE6YxNO07zEqbb0zYbW0xV4Z/ 2Y+YtCklop2B8SVeZcvgEURsYz3bdpgkxKzJ1Dmu/mFOgTfpi9YMMrXaeDewAQrlFYzQ xyFg6kKY8ieepRKrtEdmAA+AGuOfedsybPoxXaQFwhkos60LxlLpj++ui7MbCAXHsAqM hosQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of liwang@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=liwang@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: ALKqPwfGDhyurDE5HwnK0alR41i0BKB8MlvXX0HYIFdmtF6x0e99ZqGT GRu/qylC2c2pEMAoeIm68x1tLQ9UW9+nQKG0nACBxwB2nOLOVOQwAS+MAsn/10nI+I0w9ltY34z hVjadjYiUpimklDj7vArAFGYbhPwbxd0NuSzx3/cWNkhqE2x6YQQtigaqQalVHJvf/g== X-Received: by 2002:a37:cc8e:: with SMTP id n14-v6mr479418qkl.420.1527155878386; Thu, 24 May 2018 02:57:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLQ6zICNxQYeNaR/qP5NuXvnXNZnqB36TmB2rww/H5Ad7guyY3y4bYBid+r0cGMjGcVNqxe X-Received: by 2002:a37:cc8e:: with SMTP id n14-v6mr479385qkl.420.1527155877695; Thu, 24 May 2018 02:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155877; cv=none; d=google.com; s=arc-20160816; b=mJsk60981l/dq8Q1MeyBNfR1rAAHtvLH4A4AXA8CPXaw+WnGQRLqwWMh4asr9sxjJY 3cOzQu/bC5IFozfkWuHPlsVJkfX9DYV5enzePRVzEE0BzwI/ilMYfBGZRKe30llSSE/8 33Y8p9sSQiyVvFV3p0/msNmIiTySF7As//8uR9Juz26nCaQRuAsdw8rcFxOBl04YE8IQ rsPeJXuMe8qB4eR35q5sUI1Ys1sG41W9KSRCeS7nQIwfwztqZpBc0SGLgveidzhbHJsm 4CTk2GISpE/Xdw80HhWMNQaWPQMLey7+UvjF4joq7ceEQBwnnLSNIpve6AxrPDqI7k72 OWeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=OWTqP9a4Tspk64NIjXJAb1qHzFZzTpLN1zOrq49No6k=; b=ev8E+sSnRwkbsdFuMv7xJrNprp/RssaUhJINKKv3sV/e2uiBSTRLP87u1UkU99mkor CoSqvuTYJbW2VriJaJJj8FRmJtINGzWBWojboTSpMGQqrzqO6MpjklqsYTgO/NaNrqOl xcN1oJsJQbkxggAAX6KJrxUPdMHNDus6JOGOzQadW3s0a4e3wKya0YKw5NXpwnZbKmli plLhKxKyZLf3TS3A1LvxE89o3YewyWhQyFaB606LUIWn/97+Xkq/fzqh7ClB9V0Hdp41 FsaBkMYjeiR56mRlh0vmOUsPFu+6xwSU4eJWr050DnGcfeinatRHkEbumOmjIjn6ZFAs 6oPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of liwang@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=liwang@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id x76-v6si8316258qkb.259.2018.05.24.02.57.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:57:57 -0700 (PDT) Received-SPF: pass (google.com: domain of liwang@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of liwang@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=liwang@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32C8A40201A5; Thu, 24 May 2018 09:57:57 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (unknown [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id B296F10EE6C1; Thu, 24 May 2018 09:57:54 +0000 (UTC) From: Li Wang To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Seth Jennings , Dan Streetman , Huang Ying , Yu Zhao Subject: [PATCH RFC] zswap: reject to compress/store page if zswap_max_pool_percent is 0 Date: Thu, 24 May 2018 17:57:51 +0800 Message-Id: <20180524095752.17770-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 24 May 2018 09:57:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 24 May 2018 09:57:57 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'liwang@redhat.com' RCPT:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The '/sys/../zswap/stored_pages:' keep raising in zswap test with "zswap.max_pool_percent=0" parameter. But theoretically, it should not compress or store pages any more since there is no space for compressed pool. Reproduce steps: 1. Boot kernel with "zswap.enabled=1 zswap.max_pool_percent=17" 2. Set the max_pool_percent to 0 # echo 0 > /sys/module/zswap/parameters/max_pool_percent Confirm this parameter works fine # cat /sys/kernel/debug/zswap/pool_total_size 0 3. Do memory stress test to see if some pages have been compressed # stress --vm 1 --vm-bytes $mem_available"M" --timeout 60s Watching the 'stored_pages' numbers increasing or not The root cause is: When the zswap_max_pool_percent is set to 0 via kernel parameter, the zswap_is_full() will always return true to shrink the pool size by zswap_shrink(). If the pool size has been shrinked a little success, zswap will do compress/store pages again. Then we get fails on that as above. Signed-off-by: Li Wang Cc: Seth Jennings Cc: Dan Streetman Cc: Huang Ying Cc: Yu Zhao --- mm/zswap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c index 61a5c41..2b537bb 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1007,6 +1007,11 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, u8 *src, *dst; struct zswap_header zhdr = { .swpentry = swp_entry(type, offset) }; + if (!zswap_max_pool_percent) { + ret = -ENOMEM; + goto reject; + } + /* THP isn't supported */ if (PageTransHuge(page)) { ret = -EINVAL;