From patchwork Wed Oct 26 11:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13020479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE67EC433FE for ; Wed, 26 Oct 2022 11:30:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 984CC8E0008; Wed, 26 Oct 2022 07:30:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 935C78E0001; Wed, 26 Oct 2022 07:30:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7624C8E0008; Wed, 26 Oct 2022 07:30:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 683CF8E0001 for ; Wed, 26 Oct 2022 07:30:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4692580EEB for ; Wed, 26 Oct 2022 11:30:24 +0000 (UTC) X-FDA: 80062882368.29.650008A Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf07.hostedemail.com (Postfix) with ESMTP id C473840014 for ; Wed, 26 Oct 2022 11:30:23 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id m2so9736096pjr.3 for ; Wed, 26 Oct 2022 04:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J+4diO4tSVOFVgnXFSt8zIWx9H1y7/ENZOnwMcOSb2Q=; b=UhmWDT9HljW7EHf2zAiyG8JgQe7wk9UfSK5DQ4WKQj8lJCL54kE3BAxWAgbPKzQFIL HZoXAao6/7PEazMZaa7GuDGAO2fDdNUFp6cC9sO4EzNM2ElwowD4ogmxuSLKQGagkIyW fWWevm0IvTQ66rBTBe0CehdXd6v8W+5W3xvX0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+4diO4tSVOFVgnXFSt8zIWx9H1y7/ENZOnwMcOSb2Q=; b=lxrNcNwGyma39jdb3HHzOpVLiOVBTgSfiqNH5P8RoZ8wKG/lPj3cTfu9QpeSNAufjx W40Vs57KXrei9R270e41z/1O5XxuTLx2zToErK40xKWNgzibv/jlhEFpsLciMkhOb8Y4 dpyd+yVlKZl4513q+nlIK4LWK0rMZNVx7mVInudfjlRCp3iHkJmsPkFmMQqGpjE3dwEr PN4jvNLntdz9Gl7gM3OnFZIa9QHTOyiRk4LRyn1V//rGjnvmz+Ljn+QTAKmVL5NBq56Y 0Mcsf7kU79oA2E/Ogf4szgFkz3vHk/9EReOmphtZHKYJ1O/8ZPh7w1KjAsjberjUU0wr p+Bg== X-Gm-Message-State: ACrzQf2iD2mQHI0NBy8X89eY7Rke2U5Bb2X23RVotoeJXcYQ2FzpiXc/ 2zTdZeQKlR4d9RH+lXd1/XZPsA== X-Google-Smtp-Source: AMsMyM4WtybC2TUGdBn1FJrVP/+bFGZM03VW492KsOHrY9HrIhGNwTkrWcVk1jbevrKEZMYsKmTP7g== X-Received: by 2002:a17:902:e545:b0:184:2f27:b34 with SMTP id n5-20020a170902e54500b001842f270b34mr42927894plf.15.1666783822754; Wed, 26 Oct 2022 04:30:22 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:749c:f7f5:1a8e:d0be]) by smtp.gmail.com with ESMTPSA id x127-20020a626385000000b005627868e27esm2814919pfb.127.2022.10.26.04.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 04:30:22 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 5/9] zram: huge size watermark cannot be global Date: Wed, 26 Oct 2022 20:29:29 +0900 Message-Id: <20221026112933.4122957-6-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221026112933.4122957-1-senozhatsky@chromium.org> References: <20221026112933.4122957-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666783823; a=rsa-sha256; cv=none; b=u0SlUr/jTKa22bUKWYrrcYmfB+bM5A3yhbkLFuFkzAmaC9mUefgNQS8SPupOTkG6RiyAHt Jyr5/S5XO8c22ChJXYyHC5fdQd7N8y+NVF7Pvq4v9SeuclV3Fhvs9bokL//PazDjSJ4NXU Y8lspwZ6djglI4SDmpxlAICoerV0WVQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=UhmWDT9H; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf07.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.52 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666783823; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=J+4diO4tSVOFVgnXFSt8zIWx9H1y7/ENZOnwMcOSb2Q=; b=VWzPseuHvFQpAjz7D2aFmeLADbLlFzYdT1+BExPJoxU5BL6pYnbzAbBwhz20W06vYxAv7k 2IsTSLz0KpfAxa+rsXJsDJaa9KvZcpEJcC1tdM+GaZ1qS+rioDUzYHckCnjwXZFNtkLA+1 MRgPoFbPaIvBJzM+6j6zVM2Tc0KJ9B4= X-Stat-Signature: p1xajgs1s7t34o6mkzqs4qse7bn6up4r X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C473840014 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=UhmWDT9H; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf07.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.52 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-HE-Tag: 1666783823-62212 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: ZRAM will pass pool specific limit on number of pages per-zspages which will affect pool's characteristics. Namely huge size class watermark value. Move huge_class_size to struct zram, because this value now can be unique to the pool (zram device). Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 13 +++---------- drivers/block/zram/zram_drv.h | 5 +++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index fd31beb6491a..90b0c66bbd5b 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -50,12 +50,6 @@ static const char *default_comp_algs[ZRAM_MAX_ZCOMPS] = { /* Module params (documentation at end) */ static unsigned int num_devices = 1; -/* - * Pages that compress to sizes equals or greater than this are stored - * uncompressed in memory. - */ -static size_t huge_class_size; - static const struct block_device_operations zram_devops; static void zram_free_page(struct zram *zram, size_t index); @@ -1259,8 +1253,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize) return false; } - if (!huge_class_size) - huge_class_size = zs_huge_class_size(zram->mem_pool); + zram->huge_class_size = zs_huge_class_size(zram->mem_pool); return true; } @@ -1488,7 +1481,7 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec, return ret; } - if (comp_len >= huge_class_size) + if (comp_len >= zram->huge_class_size) comp_len = PAGE_SIZE; /* * handle allocation has 2 paths: @@ -1665,7 +1658,7 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page, * in a way that will save us memory. Mark the object so that we * don't attempt to re-compress it again (RECOMP_SKIP). */ - if (comp_len_next >= huge_class_size || + if (comp_len_next >= zram->huge_class_size || comp_len_next >= comp_len_prev || class_index_next >= class_index_prev || ret) { diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h index 09b9ceb5dfa3..9d6fcfdf7aa7 100644 --- a/drivers/block/zram/zram_drv.h +++ b/drivers/block/zram/zram_drv.h @@ -120,6 +120,11 @@ struct zram { */ u64 disksize; /* bytes */ const char *comp_algs[ZRAM_MAX_ZCOMPS]; + /* + * Pages that compress to sizes equal or greater than this are stored + * uncompressed in memory. + */ + size_t huge_class_size; /* * zram is claimed so open request will be failed */