From patchwork Wed Dec 18 06:34:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13913089 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 45FEBE77187 for ; Wed, 18 Dec 2024 06:35:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBE856B0099; Wed, 18 Dec 2024 01:35:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6E846B009A; Wed, 18 Dec 2024 01:35:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0FBC6B009B; Wed, 18 Dec 2024 01:35:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 910AB6B0099 for ; Wed, 18 Dec 2024 01:35:46 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 45DE580C1E for ; Wed, 18 Dec 2024 06:35:46 +0000 (UTC) X-FDA: 82907118378.05.44DB678 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf13.hostedemail.com (Postfix) with ESMTP id C188A20009 for ; Wed, 18 Dec 2024 06:35:13 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SIuRQ8al; spf=pass (imf13.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.171 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=1734503729; 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=Jx9bIgiEIqkEeB+/C7YzsZikx7IBwIxJmTKfYS6wvFk=; b=XxbLzw6JQRkQFQD1QkAgXrdHEB+9zVhO/3NQ/reYiCSANdkCjNltnozvEck7b02WxuSrhz K7Mylujkj2SADcfggPKH4CliIdwTPCJgI6cnl3ls8iAyWo75bGxrsP8AXhoF4iP8XxRirc xBfec6O94h/03rL6I9MRKGb/sFA+U/E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734503729; a=rsa-sha256; cv=none; b=cPKjL22fGlo228Ku65Mrlrqe2dqaU4XPovJfuHGNraa3adamO3CkClriEkfseN5RBe5/O5 X7GMBkskPgRVgqnheZAJr5fMCeP7tjavbVp2uyRiTG4OcNMmjQmPSnMCYBCragk5sEiKSj FPArDGU6tFIEJ1OwmXA40ttZVHaaq9I= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SIuRQ8al; spf=pass (imf13.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.171 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-725ea1e19f0so5324440b3a.3 for ; Tue, 17 Dec 2024 22:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1734503743; x=1735108543; darn=kvack.org; 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=Jx9bIgiEIqkEeB+/C7YzsZikx7IBwIxJmTKfYS6wvFk=; b=SIuRQ8alLjcJ7dl9CbMi0JGKVppllIoViecmAmEFjQuWktzaNWkvx1Dz/Y1IRvh6Ly qw0Vc2Ki/Y+D/qzs/5zmN0ZySynjCXCYyz34n449jLApnaYEH8vPJJW/QRKYa3C208gG HDJZxTiUcGF91j+e9dQqQkHHcafKXEvbNF+lA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734503743; x=1735108543; 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=Jx9bIgiEIqkEeB+/C7YzsZikx7IBwIxJmTKfYS6wvFk=; b=NmHT8WedoC0PWmhEjIvE6Pl7YBanC7tc8tUTLp6MunWKRQQbkEGV/e8PfxBpScYO2V rMNrBqJ3v69AhRwcBAUux4hZFNij3iy1p5NlRW0+78elZzgEejiwODYtk7ROdRKLYQho 8D/mYJzEURfSdH4+RKKB/sCqaIDFmU4G4qPk6ymgL2Mxov5jT5n3RrI+xLTpUtLBvLn+ 4GUXfDHMxaE6R3wjOeCo50HoaJMa7D4XXYBALRTy9ANUyqxKBSYadlH6StAAiHnS9ldc R8IqWhQV7knK6MpMohukIlxgzoITN2c+igKIMNufpumq/dZcNW/DjIMvBDyUSvCR1bGk EEGA== X-Forwarded-Encrypted: i=1; AJvYcCUkow1fn0sZgAx2zPt3Kh/M/KgGEPTvlmC08xEdoqEYjyrY+Rb3rZciaV9C9tBrwQ8N0DulLVyWLw==@kvack.org X-Gm-Message-State: AOJu0YylHnBg7g6hy3i6+k9JNbdZGiXUo7oJGMeMYtjmpK66DRxKzXl9 S0o8QVRyiO72SC+w1pwygikqMXGY/Yfu+his8Kl0CDhosRTpotb8NtsWEV5J4w== X-Gm-Gg: ASbGncsEROmI6x+v6+j6Txpax7ti1+6mvbbLNvx2wCFc8SF1W2P+QHoA7lPQ7nu12A4 JXW97/PQR8siW2ss6EHqdBtVexdWHH9QXU1/jCh5yCLBDYCrEIZbnDqfvjhMUuOmQ03ePCtyfWe LJSepbR0b9ePeAa4kou7U22hwm3qgIemk5RjPr02ze89Erf5phbbenAXA+uqhvA8Jxhj6Uqdm7a RhzPIcEokLdRgODf7yDysETi+DLFiNpOD2/mIi4GCn9O4XuTjziY5Exckc= X-Google-Smtp-Source: AGHT+IFnXzThR3kYgLdl6KAfkV3e2DAw4nVMXA+afaVN1un8QDO+bjEptYoZDse8hnX1mt8BUslL8Q== X-Received: by 2002:aa7:888c:0:b0:725:f097:ed21 with SMTP id d2e1a72fcca58-72a8d23e809mr2464921b3a.15.1734503743201; Tue, 17 Dec 2024 22:35:43 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:3bcc:36cc:b9fe:9379]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-7291bca1069sm7446008b3a.114.2024.12.17.22.35.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Dec 2024 22:35:42 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 6/7] zram: use zram_read_from_zspool() in writeback Date: Wed, 18 Dec 2024 15:34:23 +0900 Message-ID: <20241218063513.297475-7-senozhatsky@chromium.org> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20241218063513.297475-1-senozhatsky@chromium.org> References: <20241218063513.297475-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C188A20009 X-Stat-Signature: p5ctp7cyu9oauqmmcn93jed5hewaphem X-Rspam-User: X-HE-Tag: 1734503713-332113 X-HE-Meta: U2FsdGVkX1+3IlNedWgkPWUs4YXIi5zOC2FEAk+vWKSVU6Jqi3wHCEbD9z9UY9A3SEA7LRJq/fetdDPiPLdeq2M5MzY56efguAXfsqmPZAIa3WrepZnupy/HcMreOD1ebghyNhBn1dm1i0jds7JPq1Vbk+VDoFA2akc4i2qrz98ecdRueulXXAD+xs4IkYbN86eampBT3/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ta3eIixusxw/fZlRHpnQK9hrhg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.073721, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We only can read pages from zspool in writeback, zram_read_page() is not really right in that context not only because it's a more generic function that handles ZRAM_WB pages, but also because it requires us to unlock slot between slot flag check and actual page read. Use zram_read_from_zspool() instead and do slot flags check and page read under the same slot lock. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 465297d31bdf..7dd72b58e921 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -55,8 +55,8 @@ 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); -static int zram_read_page(struct zram *zram, struct page *page, u32 index, - struct bio *parent); +static int zram_read_from_zspool(struct zram *zram, struct page *page, + u32 index); static int zram_slot_trylock(struct zram *zram, u32 index) { @@ -831,13 +831,10 @@ static ssize_t writeback_store(struct device *dev, */ if (!zram_test_flag(zram, index, ZRAM_PP_SLOT)) goto next; + if (zram_read_from_zspool(zram, page, index)) + goto next; zram_slot_unlock(zram, index); - if (zram_read_page(zram, page, index, NULL)) { - release_pp_slot(zram, pps); - continue; - } - bio_init(&bio, zram->bdev, &bio_vec, 1, REQ_OP_WRITE | REQ_SYNC); bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);