From patchwork Wed May 30 10:39:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 10438371 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 0CF6B602CC for ; Wed, 30 May 2018 10:39:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F241D2874F for ; Wed, 30 May 2018 10:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E566E287C8; Wed, 30 May 2018 10:39:45 +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 620522874F for ; Wed, 30 May 2018 10:39:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5AC6B02A2; Wed, 30 May 2018 06:39:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 25BA06B02A3; Wed, 30 May 2018 06:39:44 -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 125656B02A4; Wed, 30 May 2018 06:39:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id D72546B02A2 for ; Wed, 30 May 2018 06:39:43 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id 5-v6so16458546qke.19 for ; Wed, 30 May 2018 03:39:43 -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=LKXNzw+dWD2Iz/36/hJhMHml+migFukGUxLy+H/WWsM=; b=XV9oetaJy2e7SJuBELpw/A52ptyuytTTKvqui6/ffQglLHH77Ds5oJv9hu6aWtbKbW CKvJFhSw/yTacEBrvi3nJp6W4pd5lkEuIonhTZJS44HndIk/7+TP6yW2V4ulosZI113i CSHi2NgKKyH1GKxB6OhoBsPbJG+KEq8edLbjZY/9C1DXghE2BwgcO2XSIjypQoWDVT5Z Enjw5gGnDKSwIQjtmfB97yv0hP09GQrFmcRRUXVQVOlSiUaRXkyXw6ifnmLWgKS5phkZ XqdfjJa24h4qs4XyIeXVKqJJW1pL1e8O9Y6+LW3xmJ8XWBothcmYo46K7S9P08MCw54+ vb2g== 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: APt69E3wzP+IUrEkWHa5pYYiBpD/I1yFpSpuuth43Y0Kwjob91xa0SUJ ziPjkbsIR6GFKbM3+3191xyuWM7J+Tn2qkt+9170LrDU76gPOwTEypQWDnAEeWfu4/rUIaoUhCi bqhbHpNGXlHl3mkB30d2vZQ/F808O0PWNfTcr0OH3zeD/K6dHtCumCAvgYl9pjkPzfQ== X-Received: by 2002:a0c:99df:: with SMTP id y31-v6mr1872068qve.156.1527676783651; Wed, 30 May 2018 03:39:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJZpTpzxxHRsToJ8nsYdYZulnXjS6vVh7ZyeY58hPDZo9ErqB/hV5DczQhPUxvNdjbcIxTD X-Received: by 2002:a0c:99df:: with SMTP id y31-v6mr1872044qve.156.1527676783074; Wed, 30 May 2018 03:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527676783; cv=none; d=google.com; s=arc-20160816; b=zuzuub6BrTmTLR84kUiz6w56+Fyr++HXKZtT0fE9U0hrc5kYh6OmEumE16dLys+R6X vtKT4PW7pxNvIVQRVOycuEL4HZpDZUQFNDVhBS9EbEsAs0z7XE7zLHJ6Qo37Ixut6Ovs u8TMpWX1nIlIb6B3Ot8W+QD7VZ9y/KSRw20b3wjHI8acpVEgyFLhfNLKW+S8fEMSrWY/ Uc0mYklYEcSRqg3RxLk1fqLiYIkN6dqVHIC0H0iS9KEhpiT4Ef1G5g/AJYVw0GkFtWwQ +49tOWuAbMqQfZRkrllcNwDwQq6VkPJ0kXacmWhXgOBAu1lDUN5sdvd8ZIUiOUnGpSPK IgHw== 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=LKXNzw+dWD2Iz/36/hJhMHml+migFukGUxLy+H/WWsM=; b=Gj/G6R75l8sj+h1XOAVakJ4gb2hH13XFj7QuDw/PANEvV3jpQ+7+niqEaxMKjNLz0R SDVxVKQPGm9mt3+F5vpIBtke02WBsmuThewvDySk6joeEjCeGnJMG60ohc4kB0uPZahy d9GMSS8dkHfYxdEviPpro72dN59VlC35T6PF0Zx2YjdZ6zI55rOD/iZFLnSYWqBtLULT SersSFrQ0z74wsRY0wT9IqQoRowhyOPw5fIhS+t4a9WKWnGZgl5AYOwlIAocrmaC+MKX qiOYpA6SaG+8x097UjVxa9wg8xZ6cui6VUT+3PxV9LZsrmAUjqFlJHidFrZAY9luJw36 oHnA== 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 d10-v6si661849qvd.227.2018.05.30.03.39.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 03:39:43 -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 9885540201A0; Wed, 30 May 2018 10:39:42 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (dhcp-12-102.nay.redhat.com [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2227410F1C13; Wed, 30 May 2018 10:39:39 +0000 (UTC) From: Li Wang To: ddstreet@ieee.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Seth Jennings , Huang Ying , Yu Zhao Subject: [PATCH v2] zswap: re-check zswap_is_full after do zswap_shrink Date: Wed, 30 May 2018 18:39:36 +0800 Message-Id: <20180530103936.17812-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]); Wed, 30 May 2018 10:39:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 30 May 2018 10:39:42 +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 in 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 setting to 0 via kernel parameter, the zswap_is_full() will always return true to do zswap_shrink(). But if the shinking is able to reclain a page successful, then proceeds to compress/store another page, so the value of stored_pages will keep changing. To solve the issue, this patch adds zswap_is_full() check again after zswap_shrink() to make sure it's now under the max_pool_percent, and not to compress/store if reach its limitaion. Signed-off-by: Li Wang Cc: Seth Jennings Cc: Dan Streetman Cc: Huang Ying Cc: Yu Zhao Acked-by: Dan Streetman --- mm/zswap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c index 61a5c41..fd320c3 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1026,6 +1026,15 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, 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 */