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: 11202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp205868wru; Wed, 26 Oct 2022 04:32:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7N2N8rMtUx8oXJ5BXuqpumGXjrnSgnD6MlyUmiCNa1LAsjrcv+tC54mfrWNZCJTvhcwPt5 X-Received: by 2002:a17:907:16a7:b0:79e:9eed:8f6 with SMTP id hc39-20020a17090716a700b0079e9eed08f6mr22103293ejc.731.1666783943725; Wed, 26 Oct 2022 04:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666783943; cv=none; d=google.com; s=arc-20160816; b=KYoJ6TuTtSw1PwRPuUaWq2evuf5f1tIBW7XhoFu+HfX2ziCqj1SPwFfnSDCPyBDTxd Ppkxdck/64dm7UDyn7E/+a9/SVe8K0g7GEWC+Q4u4U3wiKSUsqsJLV1LrS+uWBhbm95b 2PIUsFy4TGMQlMb2no70BTWtmxGmZK8VqlqAidg5gNXYiOzR+dM6ZAq3SF3bNv+Bg+0X Ptxiel4iBCshPCQW9YNgcpx/9T11NsSl4A01sDF2HUPoJj9fS0SbOzENH1zqvYtJLQvX myHe7XrC4ArxbAo/DdNYU4By7rUB+lpe6+5V4u87MyX3x9nHmx2XOgwqaTOtSUNHhTWW CbYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J+4diO4tSVOFVgnXFSt8zIWx9H1y7/ENZOnwMcOSb2Q=; b=GvBy++yQPW0xnhy29pFwMkZ9qq3Beps6kTn/K/KmhBSfYjSb9+l8yRZIr3F4iVen4Q boS0DLmTHVlGBYIuaAFo4U6iNS5mJ9zWLRK6bFHAvVXESrMYCVwJTTFGA5sC9wQ7k3Fb LvTtweNoIzm5emQwfvarRsOVZDUz0TUzNv4/sogEW/BmS/yvJSjT6Ux1EgJElYW0HWDt Q9cDz9hDGt+MiKmIcgteveExwxLvIeEvwGxqVdzg7CMEQEIFOuEYK8X62qpJ1dyb3pCZ 2OAN0rqFpeHwYmWHcx7OLp5tkvtVHdlIO/k9P7ABAHk/AQDkVQH0jPkm9iAYNULQ/XUl KQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UhmWDT9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a1709062ac100b0078b8bc456dcsi4857267eje.315.2022.10.26.04.31.58; Wed, 26 Oct 2022 04:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UhmWDT9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233482AbiJZLas (ORCPT + 99 others); Wed, 26 Oct 2022 07:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233330AbiJZLaa (ORCPT ); Wed, 26 Oct 2022 07:30:30 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BBFF2FC03 for ; Wed, 26 Oct 2022 04:30:23 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id h14so13706979pjv.4 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=3XlO7Iw61o4sGA0McC6GCctvtu6C8407LNMLU3rlDVDyslCHBDyRtxaUWOO8+pFKdA ZPt8ldp/soGQUpOg0Nl90pxcFqFS1GeN2RpMO3zJAiz1YBeSOVJOG0T2HcFuTagykw6B ZYBgLAFPaEpSeb6DzAORIqt3N6IrP5HuV9RqQ0Luk5WxELGOe66SyfCqBMW744qAFrYy QbSYTNVP7uLz/M1WLQMKH3Ku8aWBfNeHiwuGiz+I3+LVYjH/6mlVKN1zwSeNhUkF+3mx RZHC1BYDenYXoxgnLXmx9jjxfUs40x89iXFr3kx57SJ4txF7GdPWd4OlI96G4g23ld/z B09g== X-Gm-Message-State: ACrzQf3uHhfIoVqH1OJhi6FtaK46newe0YnjbCGLAosWs/yY4+9VGxV8 QJvoNPdGqkKYF27O5sR1BtlHJg== 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 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747749640915205974?= X-GMAIL-MSGID: =?utf-8?q?1747749640915205974?= 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 */