From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97801C4332F for ; Wed, 9 Nov 2022 04:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230207AbiKIEEk (ORCPT ); Tue, 8 Nov 2022 23:04:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbiKIEE1 (ORCPT ); Tue, 8 Nov 2022 23:04:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99FD1E3EE for ; Tue, 8 Nov 2022 20:04:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3932B81C77 for ; Wed, 9 Nov 2022 04:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D095C433D7; Wed, 9 Nov 2022 04:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1667966663; bh=B52C2lYWHolxTgXot3meqU3nXs8/do3+hH/BtNOSxu0=; h=Date:To:From:Subject:From; b=G3HL4CXQ9Ibf9bP4i+RQUVhgeFEARc5tbJuNvE/I/ZIg1giybRf6ECokkRuXIVcTN aes1bkjuC4AkjMeQR0o/0DqW1GEHs91eXtrQeXXp3CN9t8bW7OIDcA+UttsA4xye/M v9Qx2up2IzFI5nV2faHkEpJBEs/aeLtjdR0ZxVAg= Date: Tue, 08 Nov 2022 20:04:22 -0800 To: mm-commits@vger.kernel.org, ngupta@vflare.org, minchan@kernel.org, senozhatsky@chromium.org, akpm@linux-foundation.org From: Andrew Morton Subject: [to-be-updated] zram-factor-out-wb-and-non-wb-zram-read-functions.patch removed from -mm tree Message-Id: <20221109040423.8D095C433D7@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: zram: factor out WB and non-WB zram read functions has been removed from the -mm tree. Its filename was zram-factor-out-wb-and-non-wb-zram-read-functions.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Sergey Senozhatsky Subject: zram: factor out WB and non-WB zram read functions Date: Tue, 18 Oct 2022 13:55:27 +0900 We will use non-WB variant in ZRAM page recompression path. Link: https://lkml.kernel.org/r/20221018045533.2396670-4-senozhatsky@chromium.org Signed-off-by: Sergey Senozhatsky Cc: Minchan Kim Cc: Nitin Gupta Signed-off-by: Andrew Morton --- drivers/block/zram/zram_drv.c | 73 +++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 23 deletions(-) --- a/drivers/block/zram/zram_drv.c~zram-factor-out-wb-and-non-wb-zram-read-functions +++ a/drivers/block/zram/zram_drv.c @@ -1311,8 +1311,30 @@ out: ~(1UL << ZRAM_LOCK | 1UL << ZRAM_UNDER_WB)); } -static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, - struct bio *bio, bool partial_io) +/* + * Reads a page from the writeback devices. Corresponding ZRAM slot + * should be unlocked. + */ +static int zram_read_from_writeback(struct zram *zram, struct page *page, + u32 index, struct bio *bio, + bool partial_io) +{ + struct bio_vec bvec; + + bvec.bv_page = page; + bvec.bv_len = PAGE_SIZE; + bvec.bv_offset = 0; + return read_from_bdev(zram, &bvec, + zram_get_element(zram, index), + bio, partial_io); +} + +/* + * Reads (decompresses if needed) a page from zspool (zsmalloc). + * Corresponding ZRAM slot should be locked. + */ +static int zram_read_from_zspool(struct zram *zram, struct page *page, + u32 index) { struct zcomp_strm *zstrm; unsigned long handle; @@ -1320,23 +1342,6 @@ static int __zram_bvec_read(struct zram void *src, *dst; int ret; - zram_slot_lock(zram, index); - if (zram_test_flag(zram, index, ZRAM_WB)) { - struct bio_vec bvec; - - zram_slot_unlock(zram, index); - /* A null bio means rw_page was used, we must fallback to bio */ - if (!bio) - return -EOPNOTSUPP; - - bvec.bv_page = page; - bvec.bv_len = PAGE_SIZE; - bvec.bv_offset = 0; - return read_from_bdev(zram, &bvec, - zram_get_element(zram, index), - bio, partial_io); - } - handle = zram_get_handle(zram, index); if (!handle || zram_test_flag(zram, index, ZRAM_SAME)) { unsigned long value; @@ -1346,7 +1351,6 @@ static int __zram_bvec_read(struct zram mem = kmap_atomic(page); zram_fill_page(mem, PAGE_SIZE, value); kunmap_atomic(mem); - zram_slot_unlock(zram, index); return 0; } @@ -1368,17 +1372,40 @@ static int __zram_bvec_read(struct zram zcomp_stream_put(zram->comps[ZRAM_PRIMARY_ZCOMP]); } zs_unmap_object(zram->mem_pool, handle); - zram_slot_unlock(zram, index); + return ret; +} + +static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, + struct bio *bio, bool partial_io) +{ + int ret; + + zram_slot_lock(zram, index); + if (!zram_test_flag(zram, index, ZRAM_WB)) { + /* Slot should be locked through out the function call */ + ret = zram_read_from_zspool(zram, page, index); + zram_slot_unlock(zram, index); + } else { + /* Slot should be unlocked before the function call */ + zram_slot_unlock(zram, index); + + /* A null bio means rw_page was used, we must fallback to bio */ + if (!bio) + return -EOPNOTSUPP; + + ret = zram_read_from_writeback(zram, page, index, bio, + partial_io); + } /* Should NEVER happen. Return bio error if it does. */ - if (WARN_ON(ret)) + if (WARN_ON(ret < 0)) pr_err("Decompression failed! err=%d, page=%u\n", ret, index); return ret; } static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, - u32 index, int offset, struct bio *bio) + u32 index, int offset, struct bio *bio) { int ret; struct page *page; _ Patches currently in -mm which might be from senozhatsky@chromium.org are zram-introduce-recompress-sysfs-knob.patch documentation-add-recompression-documentation.patch zram-add-recompression-algorithm-choice-to-kconfig.patch zram-add-recompress-flag-to-read_block_state.patch zram-clarify-writeback_store-comment.patch zram-use-is_err_value-to-check-for-zs_malloc-errors.patch zsmalloc-turn-zspage-order-into-runtime-variable.patch zsmalloc-move-away-from-page-order-defines.patch zsmalloc-make-huge-class-watermark-zs_pool-member.patch zram-huge-size-watermark-cannot-be-global.patch zsmalloc-pass-limit-on-pages-per-zspage-to-zs_create_pool.patch zram-add-pages_per_pool_page-device-attribute.patch documentation-document-zram-pages_per_pool_page-attribute.patch zsmalloc-break-out-of-loop-when-found-perfect-zspage-order.patch