From patchwork Sun Aug 25 07:24:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 11114105 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D63814F7 for ; Mon, 26 Aug 2019 07:24:52 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E22A20874 for ; Mon, 26 Aug 2019 07:24:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=zoho.com header.i=yehs2007@zoho.com header.b="IWXUumZz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E22A20874 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=zoho.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8298F300DA2E; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64F8019D7A; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3AD2D180BA9D; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7P7PCsn025006 for ; Sun, 25 Aug 2019 03:25:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19A2C5D6D0; Sun, 25 Aug 2019 07:25:12 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A6D75D6A3; Sun, 25 Aug 2019 07:25:07 +0000 (UTC) Received: from sender-pp-o92.zoho.com (sender-pp-o92.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 984A8811DE; Sun, 25 Aug 2019 07:25:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1566717904; cv=none; d=zoho.com; s=zohoarc; b=ldzPbGLT+phX41skMR487QM7VL1Vh995xoJxj0oo8rNNgxozgHtVpnEVlo/JGZ8qgFr2sTffSITYrVEXiupqfy4GbCKfxZSKCv9sU0IIicOKKw5TmMnX2X0zNA8uj9zQRnwOgeiDY5OAJg4rTWLrHWFqb/bvRg4T5rP8UN/bHEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566717904; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=GBEJpVc45vEgTHzPnaWjFe1ezba09XmkZtfewSChPOA=; b=CAxidBtB4ryAxSHLktB548ZFZSFKM3QkSD5o696o+ZCs9jA61gMzMNZpMmlkvtxX77PChqtbwmiW8K2wJifVn0RjFdd8xA4wcMIKvpY9urr5li5hGcM3+JaP/eDpdWbc7+4HzjpE1uB746OX2T5AACwMTBfGRCvGyX+wFTwHB9g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=ddh0MTBebnOgvtxBq84DNzIHZ7pY1U3xkVNoXqo0GirJoqYxPwZZR5oBOFjAOqYN9sWO3lCem6w5 +g8EXs1mHeajKUjP6kymcQvOT7zPBrmCQrTcP1a2Uo/JdKzCOU06 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1566717904; s=zm2019; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=714; bh=GBEJpVc45vEgTHzPnaWjFe1ezba09XmkZtfewSChPOA=; b=IWXUumZzwAkajLMcOI61NRT+FphXnrnMi69LG6SNO3qJYYDxIla2CaGZA7A9EsHK nXq9AcnW4BDylrs0QuCj/xH8A88TJStzcN+xWycLqNPKF32dCjTRToxCRGON212DQCa E+8QSTjOO7sRIwkrqwKbEfZfOX+Uc7M4ngBcT8hY= Received: from YEHS1XR3054QMS.lenovo.com (123.120.58.107 [123.120.58.107]) by mx.zohomail.com with SMTPS id 1566717903096668.6389464058707; Sun, 25 Aug 2019 00:25:03 -0700 (PDT) From: Huaisheng Ye To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com Date: Sun, 25 Aug 2019 15:24:31 +0800 Message-Id: <20190825072433.2628-2-yehs2007@zoho.com> In-Reply-To: <20190825072433.2628-1-yehs2007@zoho.com> References: <20190825072433.2628-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 25 Aug 2019 07:25:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 25 Aug 2019 07:25:07 +0000 (UTC) for IP:'135.84.80.237' DOMAIN:'sender-pp-o92.zoho.com' HELO:'sender-pp-o92.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.151 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 135.84.80.237 sender-pp-o92.zoho.com 135.84.80.237 sender-pp-o92.zoho.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 26 Aug 2019 03:24:39 -0400 Cc: prarit@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, tyu1@lenovo.com, Huaisheng Ye Subject: [dm-devel] [PATCH 1/3] dm writecache: remove unused member pointer in writeback_struct X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 26 Aug 2019 07:24:51 +0000 (UTC) From: Huaisheng Ye The stucture member pointer page in writeback_struct never has been used actually. Remove it. Signed-off-by: Huaisheng Ye Acked-by: Mikulas Patocka --- drivers/md/dm-writecache.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 1cb137f..5c7009d 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -190,7 +190,6 @@ struct writeback_struct { struct dm_writecache *wc; struct wc_entry **wc_list; unsigned wc_list_n; - struct page *page; struct wc_entry *wc_list_inline[WB_LIST_INLINE]; struct bio bio; }; From patchwork Sun Aug 25 07:24:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 11114109 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B0CD174A for ; Mon, 26 Aug 2019 07:24:55 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F02252087E for ; Mon, 26 Aug 2019 07:24:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=zoho.com header.i=yehs2007@zoho.com header.b="Vw/993Q/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F02252087E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=zoho.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 194F889AC2; Mon, 26 Aug 2019 07:24:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECD7E600C4; Mon, 26 Aug 2019 07:24:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C1F85180BA9E; Mon, 26 Aug 2019 07:24:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7P7PGGM025019 for ; Sun, 25 Aug 2019 03:25:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E6509F5C; Sun, 25 Aug 2019 07:25:16 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx23.extmail.prod.ext.phx2.redhat.com [10.5.110.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8E1660C80; Sun, 25 Aug 2019 07:25:11 +0000 (UTC) Received: from sender-pp-o92.zoho.com (sender-pp-o92.zoho.com [135.84.80.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86E8010576E0; Sun, 25 Aug 2019 07:25:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1566717906; cv=none; d=zoho.com; s=zohoarc; b=Yjj9Rt7PSlWq0HPfmzbLhvQKdcqom6NrNe9llRsWF7aVQMOXiV8AjiXUqO365DJ9eM5icwuJWFKadheAf2j1bbMRrISZ5aPec/WihxbFFM1SA4mheQvWpQNvDfmn5Py6jhON/AcmRR+EbqFSGXLOnuZsQGqE2FH//NHhiDwTPH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566717906; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=Ll1ddxjlpuzcBFEPUI7g0gZvBDFbmDed0ou/3799LFI=; b=hV8XNvO8xGgJRInjwl3m2YHfosYI13JUkRBMtglehScoNS+VOAmXYwTDqdd5VonySa4+AaQMgUn2w7Aen9/IkxVysyGe9FlPM+ceTNhX23fbUHrLAKPF9ixlr6CJS/TFRWvweZmsQuZkn61eeZzM59Ryw1QcYCMwbkxmRdbyztQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=h8bNdcwCOcnyX9C96B/SV8Gcd5TJBr05qUyw+Ya95aHltSrT1fEdPfZBFfOUDhsk0JNlQNoucCBy uQVk6ioHUUH5IrAkKeo+LAKHbthlCpewJJEAvjU3X6Pec2VdIkB1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1566717906; s=zm2019; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1017; bh=Ll1ddxjlpuzcBFEPUI7g0gZvBDFbmDed0ou/3799LFI=; b=Vw/993Q/FtiTHaRCQNPB36qpst0AacARkWXRYwkz9T3O0WqHYSAzmlfJqcIZWhz4 SwNI6wUdgoDjY4VwlCg0A2BmT166xBAlA32FGQnasKVw/LH9xNoyLcuG7KDEhkGzYtL UTrv4SIHrXYIWpaCtVHbsFjjcVJkbQKFlQIsnVVU= Received: from YEHS1XR3054QMS.lenovo.com (123.120.58.107 [123.120.58.107]) by mx.zohomail.com with SMTPS id 1566717905963339.9025705087869; Sun, 25 Aug 2019 00:25:05 -0700 (PDT) From: Huaisheng Ye To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com Date: Sun, 25 Aug 2019 15:24:32 +0800 Message-Id: <20190825072433.2628-3-yehs2007@zoho.com> In-Reply-To: <20190825072433.2628-1-yehs2007@zoho.com> References: <20190825072433.2628-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Sun, 25 Aug 2019 07:25:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Sun, 25 Aug 2019 07:25:11 +0000 (UTC) for IP:'135.84.80.237' DOMAIN:'sender-pp-o92.zoho.com' HELO:'sender-pp-o92.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.151 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 135.84.80.237 sender-pp-o92.zoho.com 135.84.80.237 sender-pp-o92.zoho.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.64 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 26 Aug 2019 03:24:39 -0400 Cc: prarit@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, tyu1@lenovo.com, Huaisheng Ye Subject: [dm-devel] [PATCH 2/3] dm writecache: add unlikely for getting two block with same LBA X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 26 Aug 2019 07:24:54 +0000 (UTC) From: Huaisheng Ye In function writecache_writeback, entries g and f has same original sector only happens at entry f has been committed, but entry g has NOT yet. The probability of this happening is very low in the following 256 blocks at most of entry e. Signed-off-by: Huaisheng Ye Acked-by: Mikulas Patocka --- drivers/md/dm-writecache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 5c7009d..3643084 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1628,8 +1628,8 @@ static void writecache_writeback(struct work_struct *work) if (unlikely(!next_node)) break; g = container_of(next_node, struct wc_entry, rb_node); - if (read_original_sector(wc, g) == - read_original_sector(wc, f)) { + if (unlikely(read_original_sector(wc, g) == + read_original_sector(wc, f))) { f = g; continue; } From patchwork Sun Aug 25 07:24:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng Ye X-Patchwork-Id: 11114107 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB9DF174A for ; Mon, 26 Aug 2019 07:24:52 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87FEB20874 for ; Mon, 26 Aug 2019 07:24:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=zoho.com header.i=yehs2007@zoho.com header.b="pu/b7LyN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87FEB20874 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=zoho.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B728FA31CEF; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 995265C220; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 71655180BA9E; Mon, 26 Aug 2019 07:24:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7P7PGUu025011 for ; Sun, 25 Aug 2019 03:25:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AB465D713; Sun, 25 Aug 2019 07:25:16 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F12415D6A3; Sun, 25 Aug 2019 07:25:15 +0000 (UTC) Received: from sender4-pp-o95.zoho.com (sender4-pp-o95.zoho.com [136.143.188.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81F4BC049E10; Sun, 25 Aug 2019 07:25:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1566717910; cv=none; d=zoho.com; s=zohoarc; b=SJpPVL1y/fFECRiorlnRKTcsvUGgqfPM0WCrlkRXq8+ksnLCjUjhcIUt5HbILFyAwN83keYNb1iiCZPha5JSnCw777qcvl0QGgkKThpwDmVYpZhQvTljG69SAy5OVPLKDPN8eO9KTK7SrPtB4VBKdknWrMNvTuMlxav37Bb1KgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566717910; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=JbPeKwL0y9K5o8QvWTYI+guOBqyfTVLeLMRqF8VDqWc=; b=bEMCgOUh1pBeKMb/u7u3grM3ujaZVzGTOPRRROtLXOs3C3/3x7mZdsFrbsIq2pGe74AtMToDOtvkZuomTBAhmPmKfyWGqBWVcWtiwcn2hXIRFUzPEa2aJA681FW6sXyAzmOXXM6jmWXvqeHo7Z3cGHAzMDlRGQEqXVYPn84DaNI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=yehs2007@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=i7y2aEyOHh/la9dU3CPx42PbzlTdsTP9AIatWSaev26MhvxazXL9kgiLtuYSGKE0vaAVtr7CacPu UxeGSKrTnyEcL66hHrbYbIu4R8iV5qlMuOhCWOOUWmaib0WCiuuq DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1566717910; s=zm2019; d=zoho.com; i=yehs2007@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=3969; bh=JbPeKwL0y9K5o8QvWTYI+guOBqyfTVLeLMRqF8VDqWc=; b=pu/b7LyNmYvufL43cLjOm9uc6q7eI2PfNoaarhXUjd/qlCh2Hi2xduAPONT5OyO7 rofiHB/FJvRmrIOJRH42WcnkP/TxtGQNeZNa4V/HbXxJi0nrMlKVBvj+1YqyZRu/bej 1qq2aaLi8arB2HnAeusARLo0U0rhRbhoqewsZhnU= Received: from YEHS1XR3054QMS.lenovo.com (123.120.58.107 [123.120.58.107]) by mx.zohomail.com with SMTPS id 15667179088951020.9475134769934; Sun, 25 Aug 2019 00:25:08 -0700 (PDT) From: Huaisheng Ye To: mpatocka@redhat.com, snitzer@redhat.com, agk@redhat.com Date: Sun, 25 Aug 2019 15:24:33 +0800 Message-Id: <20190825072433.2628-4-yehs2007@zoho.com> In-Reply-To: <20190825072433.2628-1-yehs2007@zoho.com> References: <20190825072433.2628-1-yehs2007@zoho.com> X-ZohoMailClient: External X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 25 Aug 2019 07:25:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 25 Aug 2019 07:25:15 +0000 (UTC) for IP:'136.143.188.95' DOMAIN:'sender4-pp-o95.zoho.com' HELO:'sender4-pp-o95.zoho.com' FROM:'yehs2007@zoho.com' RCPT:'' X-RedHat-Spam-Score: 0.151 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 136.143.188.95 sender4-pp-o95.zoho.com 136.143.188.95 sender4-pp-o95.zoho.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 26 Aug 2019 03:24:39 -0400 Cc: prarit@redhat.com, dm-devel@redhat.com, linux-kernel@vger.kernel.org, tyu1@lenovo.com, Huaisheng Ye Subject: [dm-devel] [PATCH 3/3] dm writecache: optimize performance by sorting the blocks for writeback_all X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 26 Aug 2019 07:24:52 +0000 (UTC) From: Huaisheng Ye During the process of writeback, the blocks, which have been placed in wbl.list for writeback soon, are partially ordered for the contiguous ones. When writeback_all has been set, for most cases, also by default, there will be a lot of blocks in pmem need to writeback at the same time. For this case, we could optimize the performance by sorting all blocks in wbl.list. writecache_writeback doesn't need to get blocks from the tail of wc->lru, whereas from the first rb_node from the rb_tree. The benefit is that, writecache_writeback doesn't need to have any cost to sort the blocks, because of all blocks are incremental originally in rb_tree. There will be a writecache_flush when writeback_all begins to work, that will eliminate duplicate blocks in cache by committed/uncommitted. Testing platform: Thinksystem SR630 with persistent memory. The cache comes from pmem, which has 1006MB size. The origin device is HDD, 2GB of which for using. Testing steps: 1) dmsetup create mycache --table '0 4194304 writecache p /dev/sdb1 /dev/pmem4 4096 0' 2) fio -filename=/dev/mapper/mycache -direct=1 -iodepth=20 -rw=randwrite -ioengine=libaio -bs=4k -loops=1 -size=2g -group_reporting -name=mytest1 3) time dmsetup message /dev/mapper/mycache 0 flush Here is the results below, With the patch: # fio -filename=/dev/mapper/mycache -direct=1 -iodepth=20 -rw=randwrite -ioengine=libaio -bs=4k -loops=1 -size=2g -group_reporting -name=mytest1 iops : min= 1582, max=199470, avg=5305.94, stdev=21273.44, samples=197 # time dmsetup message /dev/mapper/mycache 0 flush real 0m44.020s user 0m0.002s sys 0m0.003s Without the patch: # fio -filename=/dev/mapper/mycache -direct=1 -iodepth=20 -rw=randwrite -ioengine=libaio -bs=4k -loops=1 -size=2g -group_reporting -name=mytest1 iops : min= 1202, max=197650, avg=4968.67, stdev=20480.17, samples=211 # time dmsetup message /dev/mapper/mycache 0 flush real 1m39.221s user 0m0.001s sys 0m0.003s I also have checked the data accuracy with this patch by making EXT4 filesystem on mycache, then mount it for checking md5 of files on that. The test result is positive, with this patch it could save more than half of time when writeback_all. Signed-off-by: Huaisheng Ye --- drivers/md/dm-writecache.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 3643084..c481947 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1560,7 +1560,7 @@ static void writecache_writeback(struct work_struct *work) { struct dm_writecache *wc = container_of(work, struct dm_writecache, writeback_work); struct blk_plug plug; - struct wc_entry *e, *f, *g; + struct wc_entry *f, *g, *e = NULL; struct rb_node *node, *next_node; struct list_head skipped; struct writeback_list wbl; @@ -1597,7 +1597,14 @@ static void writecache_writeback(struct work_struct *work) break; } - e = container_of(wc->lru.prev, struct wc_entry, lru); + if (unlikely(wc->writeback_all)) { + if (unlikely(!e)) { + writecache_flush(wc); + e = container_of(rb_first(&wc->tree), struct wc_entry, rb_node); + } else + e = g; + } else + e = container_of(wc->lru.prev, struct wc_entry, lru); BUG_ON(e->write_in_progress); if (unlikely(!writecache_entry_is_committed(wc, e))) { writecache_flush(wc); @@ -1658,8 +1665,14 @@ static void writecache_writeback(struct work_struct *work) g->wc_list_contiguous = BIO_MAX_PAGES; f = g; e->wc_list_contiguous++; - if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES)) + if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES)) { + if (unlikely(wc->writeback_all)) { + next_node = rb_next(&f->rb_node); + if (likely(next_node)) + g = container_of(next_node, struct wc_entry, rb_node); + } break; + } } cond_resched(); }