Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp923391rwl; Fri, 31 Mar 2023 04:31:25 -0700 (PDT) X-Google-Smtp-Source: AKy350axabC3S/2FbneeP+D1+kNfJg8YloM+6TxezZs5ZLI6U+5nlUQ263JIWVvVwGsaGY1eGnXJ X-Received: by 2002:a05:6402:5107:b0:502:ffd:74a0 with SMTP id m7-20020a056402510700b005020ffd74a0mr5943550edd.2.1680262285235; Fri, 31 Mar 2023 04:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680262285; cv=none; d=google.com; s=arc-20160816; b=xCiLvgdJoK/LpUsaz8KrApQMTIX+t8BnPUeTqk3Zi8lplhrHgNRKh881aGXmQCsmlT ijfObiatez2TN5gcNQDAgf9UWImQSOk16AlCkEnqjrqn7mPGk71qZBCBTYxHta/44LvB JrGdJOSU9Ofd3CIqTvdXGpGAQq2f/MF3LYEQyB6xgrsMlZ1NOmBEiEwEholTGM79bRb9 psstjhD5GmPPeIr8vfl9ntDEdEenyBIuSE3FQ8NYzP1Ah52C7ZbHOG2uxq1dvxeGoFno gY4VzYYd6JBrOKpRqGkDUG/+nKE0UjX5uImt5RquSAeUiosHv3J1aqBlORAfZVjSm4/F KMuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :in-reply-to:content-language:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature:dkim-filter; bh=rotXHmLJ+3RmVvig7nNDjJgCDFpn3JfHaBhmEOHV1xU=; b=b4FaCRAGU36jGjKBc/k901tCjUIxGAfaiW9UTte2WLB4KeUYJtRkbfzfeP4UpW3BYr fb6D1HT0RLJjb7XapCezS+7diGdw7AnOCH2gyWuOENriMaFSFDxGgFPh17c8DJN0bSx8 HyDaYMBKGale0xc1IH0q5ZEDIynG646qgsyHdAmOLvGbjm/NTsweLlEkTeizuKcTQTE9 scaxvEKorlTlKOOQSbUwN09UGyKNFdTWwcB9k44W5Wl5XBA0lmL0Q05rtPMxGL5j5zGh O1uYr2HrkGN8DjC+Ji3vJele2ejgL1tlNMZF3pRSJ71JXERkSIrYQbWQxItKDJzkMPV8 3RHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=AvRRY729; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020aa7d70b000000b00501d48232ecsi1927972edq.404.2023.03.31.04.30.55; Fri, 31 Mar 2023 04:31:25 -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=@samsung.com header.s=mail20170921 header.b=AvRRY729; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231562AbjCaLUA (ORCPT + 99 others); Fri, 31 Mar 2023 07:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbjCaLT5 (ORCPT ); Fri, 31 Mar 2023 07:19:57 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9221C1DF for ; Fri, 31 Mar 2023 04:19:54 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230331111951euoutp011456cb72e7229b0ece9eec5f0ce95c68~RfQPOPrxM2853028530euoutp01j for ; Fri, 31 Mar 2023 11:19:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230331111951euoutp011456cb72e7229b0ece9eec5f0ce95c68~RfQPOPrxM2853028530euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680261591; bh=rotXHmLJ+3RmVvig7nNDjJgCDFpn3JfHaBhmEOHV1xU=; h=Date:From:Subject:To:CC:In-Reply-To:References:From; b=AvRRY729uZ3p9BOnTZjG0mklUGgK5XB+IKF3dmfyY5XDjb39MYGjmQOAm49/+82gB 9WtlEF7EpqRA9qgU2pF6dWQF93zQvcLCbuFwBoDFqYd3eX5bN5/GYzkEOO8iLXdURn yEWKU+bOWK1EdwpOm6GTukN/krDcvk/xbqvSwrFM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230331111950eucas1p20fd7a4a982cb8f666bb7d574d0950f24~RfQO6FUKT0705007050eucas1p2y; Fri, 31 Mar 2023 11:19:50 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 3A.5A.09503.6D1C6246; Fri, 31 Mar 2023 12:19:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230331111950eucas1p24613fe162e4c64b427fc13182914c84e~RfQOVp2I91172711727eucas1p2t; Fri, 31 Mar 2023 11:19:50 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230331111950eusmtrp289d12c6234d5114b90c0f2c48cde8703~RfQOU7ns72314123141eusmtrp2a; Fri, 31 Mar 2023 11:19:50 +0000 (GMT) X-AuditID: cbfec7f2-ea5ff7000000251f-d9-6426c1d6a538 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FF.85.09583.6D1C6246; Fri, 31 Mar 2023 12:19:50 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230331111950eusmtip22bed4ddfdecd2e651183996406d37c70~RfQOHI4Uw2857728577eusmtip2N; Fri, 31 Mar 2023 11:19:50 +0000 (GMT) Received: from [106.110.32.65] (106.110.32.65) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 31 Mar 2023 12:19:48 +0100 Message-ID: <3b116359-d346-a63c-1a78-f95ad1912dfe@samsung.com> Date: Fri, 31 Mar 2023 13:19:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: Pankaj Raghav Subject: Re: [PATCH 1/5] zram: remove the call to page_endio in the bio end_io handler To: Minchan Kim CC: , , , , , , , , , , , , , , , Christoph Hellwig Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [106.110.32.65] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBKsWRmVeSWpSXmKPExsWy7djP87rXDqqlGPT2mVjMWb+GzWL13X42 i9eHPzFa7N88hcli5eqjTBbtd/uYLPbe0rbYs/cki8XlXXPYLO6t+c9qcXL9f2aLGxOeMlos +/qe3WL3xkVsFuf/Hme1+P1jDpuDgMfshossHptXaHlcPlvqsWlVJ5vHpk+T2D1OzPjN4tEw 9Rabx+6bDWwev27fYfX4vEnOY9OTt0wB3FFcNimp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RRnJBpqMRcVJwIApiMYd7ADAAA= X-CMS-MailID: 20230331111950eucas1p24613fe162e4c64b427fc13182914c84e X-Msg-Generator: CA X-RootMTR: 20230328112718eucas1p214a859cfb3d7b45523356bcc16c373b1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230328112718eucas1p214a859cfb3d7b45523356bcc16c373b1 References: <20230328112716.50120-1-p.raghav@samsung.com> <20230328112716.50120-2-p.raghav@samsung.com> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 On 2023-03-31 00:51, Minchan Kim wrote: > On Tue, Mar 28, 2023 at 01:27:12PM +0200, Pankaj Raghav wrote: >> zram_page_end_io function is called when alloc_page is used (for >> partial IO) to trigger writeback from the user space. The pages used for > > No, it was used with zram_rw_page since rw_page didn't carry the bio. > >> this operation is never locked or have the writeback set. So, it is safe > > VM had the page lock and wait to unlock. > >> to remove the call to page_endio() function that unlocks or marks >> writeback end on the page. >> >> Rename the endio handler from zram_page_end_io to zram_read_end_io as >> the call to page_endio() is removed and to associate the callback to the >> operation it is used in. > I revisited the code again. Let me know if I got it right. When we trigger writeback, we will always call zram_bvec_read() only if ZRAM_WB is not set. That means we will only call zram_read_from_zspool() in __zram_bvec_read when parent bio set to NULL. static ssize_t writeback_store(struct device *dev, ... { if (zram_test_flag(zram, index, ZRAM_WB) || zram_test_flag(zram, index, ZRAM_SAME) || zram_test_flag(zram, index, ZRAM_UNDER_WB)) goto next; ... if (zram_bvec_read(zram, &bvec, index, 0, NULL)) { ... } static int __zram_bvec_read(struct zram *zram, struct page *page, u32 index, struct bio *bio, bool partial_io) { .... 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); ret = zram_bvec_read_from_bdev(zram, page, index, bio, partial_io); } .... } > Since zram removed the rw_page and IO comes with bio from now on, > IIUC, we are fine since every IO will go with chained-IO. Right? > We will never call zram_bvec_read_from_bdev() with parent bio set to NULL. IOW, we will always only hit the bio_chain case in read_from_bdev_async. So we could do the following?: diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index b7bb52f8dfbd..2341f4009b0f 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -606,15 +606,6 @@ static void free_block_bdev(struct zram *zram, unsigned long blk_idx) atomic64_dec(&zram->stats.bd_count); } -static void zram_page_end_io(struct bio *bio) -{ - struct page *page = bio_first_page_all(bio); - - page_endio(page, op_is_write(bio_op(bio)), - blk_status_to_errno(bio->bi_status)); - bio_put(bio); -} - /* * Returns 1 if the submission is successful. */ @@ -634,9 +625,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec, return -EIO; } - if (!parent) - bio->bi_end_io = zram_page_end_io; - else + if (parent) bio_chain(bio, parent); submit_bio(bio);