Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5781597pxu; Thu, 22 Oct 2020 10:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydhHO944zPi+3kh+C3UN0Y1dt0sEXEzvnLSk6BB7b7VL0Imv07bYv4ICbLlY37jrZrgp3O X-Received: by 2002:a17:906:c1c3:: with SMTP id bw3mr3305370ejb.126.1603389125312; Thu, 22 Oct 2020 10:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603389125; cv=none; d=google.com; s=arc-20160816; b=k1RuFs3mKJT6n6JOAialVUgi6CHyFo0r5TlKiS+CoMGHRttLUQyYL2k0Q5VUcASL5b K3GaqGvHHW2E8h2+pUx1VhdkaCu9c7BKq4iZ4POANfb1m7UoWbMRHAvIbht16AR4fND7 F8C0yLNbQiapApgvYUKc/EReUSedWt+3jtrGbRbp8zQMqlgimfIYut26dJp5EhLOUYNF jo5RPPgkWNO1b7ni12fDRXkssYAsceRH1HXBZcUJn1qwJE2+TbKbBq5VW22lPsy6Zy2s 3KF5qFkFo0hCiJFaesahof+ndxd4xgABIMWESGe7hK3mXr/xnlC+XwTgX1w+58GY65su naHA== 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=m+KvnfBf8xuQNeIuRRe0vdHUkvX140+IsRUPrl0yksw=; b=czOENJZGrqfHRwM1hKRhkkYtjUVF6oYduRwBmUBkqxkHI3e4CyD6BWKnNkcDh7y4Ae DUyQE4RbwFOWg0NJ9OOqWwmF2KUeKHWJIGXqgvLsSTKH69dlkSzR/PK1M2J24NctCO3E ZlewjwwmoFJliZPpkS8UIQoPO6/a8JcP3AQqfdfD34vNxt/J40XqiQyXZUWWDRPFbxuK ssfExB8mCSmBCHztHPNdEl5gGUjWe689c0MmO7zWveqQpSguJcXOr/7GGh+Mdx0bhuBC wn6w9nksRyc9BFUs5fqNdz3WlKnAPSQganApWD7an13SpZFz1nECOLviep7PdD9kaHqb 9//g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=W2zSDzkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb14si198849ejc.249.2020.10.22.10.51.42; Thu, 22 Oct 2020 10:52:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=W2zSDzkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S368295AbgJVO6K (ORCPT + 99 others); Thu, 22 Oct 2020 10:58:10 -0400 Received: from sonic308-54.consmr.mail.gq1.yahoo.com ([98.137.68.30]:32962 "EHLO sonic308-54.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368245AbgJVO6K (ORCPT ); Thu, 22 Oct 2020 10:58:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1603378689; bh=m+KvnfBf8xuQNeIuRRe0vdHUkvX140+IsRUPrl0yksw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=W2zSDzkS2yZELWeNGpxmBEQe8QOUf10AUcdWI4i8jlL/CAOLqigJUCb5wpKcfBnZLPnXUiRNDaQF3liCy02v+l5Sgh3CMv9D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S d3kAnqE1arF7N..1c3_w7GHvAJITPfwTBkzfKDoBHy7XC_qh2ziarjl2ky4FqFmKywurRR_5dY29 VIzLaGjPdHylW548mKuvhDdWb_yXhz005IPfIMY6775uxvF3pIVOqMhaF0Jsjv9p6Zs.6J9XnKbP wlPVPM5YF.w-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Thu, 22 Oct 2020 14:58:09 +0000 Received: by smtp401.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 354b2034a70b817070abfec37b60849b; Thu, 22 Oct 2020 14:58:03 +0000 (UTC) From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: Chao Yu , Chao Yu , LKML , Gao Xiang Subject: [PATCH 4/4] erofs: complete a missing case for inplace I/O Date: Thu, 22 Oct 2020 22:57:24 +0800 Message-Id: <20201022145724.27284-4-hsiangkao@aol.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20201022145724.27284-1-hsiangkao@aol.com> References: <20201022145724.27284-1-hsiangkao@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Length: 2466 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Add a missing case which could cause unnecessary page allocation but not directly use inplace I/O instead, which increases runtime extra memory footprint. The detail is, considering a file-backed page, the right half of the page is chosen to be cached (e.g. the end page) and some of its data doesn't exist in managed cache, so the pcluster will be kept in the submission chain. (In other words, it cannot be decompressed in advance, for example, due to the bypass chain). Currently, the pcluster for this case is downgraded as NOINPLACE, and stop the left half of the page from doing inplace I/O (so an extra page allocation is needed then.) Let's avoid such unnecessary downgrade instead. Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index edd7325570e1..ef12275f7fcc 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -160,7 +160,8 @@ static void preload_compressed_pages(struct z_erofs_collector *clt, const unsigned int clusterpages = BIT(pcl->clusterbits); struct page **pages = clt->compressedpages; pgoff_t index = pcl->obj.index + (pages - pcl->compressed_pages); - bool standalone = true; + bool io_cant_bypass = false; + bool updated = false; if (clt->mode < COLLECT_PRIMARY_FOLLOWED) return; @@ -180,20 +181,31 @@ static void preload_compressed_pages(struct z_erofs_collector *clt, } else if (type == DELAYEDALLOC) { t = tagptr_init(compressed_page_t, PAGE_UNALLOCATED); } else { /* DONTALLOC */ - if (standalone) + /* update to first inplace I/O page */ + if (!updated) { clt->compressedpages = pages; - standalone = false; + updated = true; + } + io_cant_bypass = true; continue; } - if (!cmpxchg_relaxed(pages, NULL, tagptr_cast_ptr(t))) + if (!cmpxchg_relaxed(pages, NULL, tagptr_cast_ptr(t))) { + if (type == DELAYEDALLOC) + io_cant_bypass = true; continue; + } if (page) put_page(page); } - if (standalone) /* downgrade to PRIMARY_FOLLOWED_NOINPLACE */ + /* + * for COLLECT_PRIMARY_FOLLOWED pcluster, if all managed pages have + * been found (which means it can be handled without submittng I/O) + * it's unsafe to do inplace I/O. let's downgrade to NOINPLACE instead. + */ + if (!io_cant_bypass) clt->mode = COLLECT_PRIMARY_FOLLOWED_NOINPLACE; } -- 2.24.0