From patchwork Mon Oct 31 05:41:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13025394 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 A05AAFA3740 for ; Mon, 31 Oct 2022 05:41:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 419198E0001; Mon, 31 Oct 2022 01:41:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A12380007; Mon, 31 Oct 2022 01:41:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26A2A8E0006; Mon, 31 Oct 2022 01:41:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0310D8E0001 for ; Mon, 31 Oct 2022 01:41:31 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9CDB9A0BCB for ; Mon, 31 Oct 2022 05:41:31 +0000 (UTC) X-FDA: 80080147182.28.557CA58 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf08.hostedemail.com (Postfix) with ESMTP id 45BB5160011 for ; Mon, 31 Oct 2022 05:41:31 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id 4so9869155pli.0 for ; Sun, 30 Oct 2022 22:41:30 -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=4A6bhxNpojaEfPLcsnRmMeXdGP9le8JW2bwOtY/TXkw=; b=mVTml/Dy4+8p9+6rmaolR4vBzjYW7UCec/5EMJ+idSZbvLmxXWLwMeDUDy8NMfmSjx qH5MGu1oQ1A7u43SxQHdT0a+55WaYPhC5BtaEix7UtY1PUPttIA1tLy0w29dES+LR692 yWCf2+X19RD7iNSYK+TgQm6wZYQBsbJ2q97Gs= 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=4A6bhxNpojaEfPLcsnRmMeXdGP9le8JW2bwOtY/TXkw=; b=qEoE2wUg0/4ceFokIDmUUyqK9mdDjULWnlD3QYHKrRK5jGmSpG1w4BIe0E3tBrgw6j tB1BIOMX9IRUpDtofQJIJxyV+OXDMMMGvmGBIBeZ+w7xw0Cd3FdzYMNtEjOOWGsMeQyn hM8xs+CRLekk39MhHbvsU3GbvnapShIv3/treCr3gVDXGNHkOJWBegpzkXfY9P5a9ZC6 2QcA40ma7/l9kMl4S6HhzFuXkfKdo8zlITEwtnfQo2n/5pZsJkQo19iNE+I8d0EPjIMG LY5Zy9ALjp4hJB7k3SGs8dP+JuU4YLJgoEkW8X4u3aDuzSISq7mh5bIANFwJpdQZtEyQ asLA== X-Gm-Message-State: ACrzQf1z8uDG280xcu8kNJ8n8WOqcPRCkNAUBUJIbGwxwZqIwRxYYaFh WPrPfeJBrngmFzQmbhybyIsI63XpYlib7Q== X-Google-Smtp-Source: AMsMyM5/Tqjv38wC3ib39unJG1knEpYCMVX+0dvSVs/aWk6fGK7Xl5OBbYQvU4RkIQhQKqzo4LbOTQ== X-Received: by 2002:a17:90b:1e43:b0:213:1efe:9815 with SMTP id pi3-20020a17090b1e4300b002131efe9815mr13311203pjb.164.1667194890154; Sun, 30 Oct 2022 22:41:30 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:7616:afe0:ba6c:96f4]) by smtp.gmail.com with ESMTPSA id w12-20020aa79a0c000000b0056befcd7958sm3573308pfj.84.2022.10.30.22.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Oct 2022 22:41:29 -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: [PATCHv4 5/9] zram: huge size watermark cannot be global Date: Mon, 31 Oct 2022 14:41:04 +0900 Message-Id: <20221031054108.541190-6-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog In-Reply-To: <20221031054108.541190-1-senozhatsky@chromium.org> References: <20221031054108.541190-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667194891; a=rsa-sha256; cv=none; b=gWq0T7FuqOXjGx2gRFTdWcjeEEzi0EK1SehIOuMXVl3ppadO4q9ERydejS2QU9nkpym32W f07NEaH4JTcjela0yd3b2ClZ+B8A847VcNGvFSjs5TJHXWHdQEeO8TfezWQiFnoz5FnoFd RyyHcRJYX1sJkA+HycH2YhddKs5PXU8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="mVTml/Dy"; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667194891; 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=4A6bhxNpojaEfPLcsnRmMeXdGP9le8JW2bwOtY/TXkw=; b=JlDS4ace29EKoq9/DtZiG8F6RJNaIQOxYlAvd/Wt4LoK2OblvZZz9tBqdU2UPie3xtQGFm 0yZ5r+u8/vjKE7ZYDOP66WqVBiOgSo7/t9luMWr2buprsNCwMm3SO/STDbuSrPo90TOhNI Yi+1ws4CgqvyAhGf0qxg4FAXKJQdWhE= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 45BB5160011 X-Rspam-User: X-Stat-Signature: d1bbyjac85uywdtmrridt7g1ffus91aq Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="mVTml/Dy"; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.174 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-HE-Tag: 1667194891-916959 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 */