From patchwork Fri Mar 1 16:51:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 10835703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF4A6139A for ; Fri, 1 Mar 2019 16:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D99AD2FD72 for ; Fri, 1 Mar 2019 16:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD9912FD7F; Fri, 1 Mar 2019 16:53:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76E812FD72 for ; Fri, 1 Mar 2019 16:53:51 +0000 (UTC) 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 DE01E3078DB8; Fri, 1 Mar 2019 16:53:49 +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 A7E7060142; Fri, 1 Mar 2019 16:53:49 +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 5AE24181A010; Fri, 1 Mar 2019 16:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21GrerB016517 for ; Fri, 1 Mar 2019 11:53:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 585675BBA9; Fri, 1 Mar 2019 16:53:40 +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 7653F5D964; Fri, 1 Mar 2019 16:53:33 +0000 (UTC) Received: from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83F93C0D2625; Fri, 1 Mar 2019 16:52:45 +0000 (UTC) Received: from troi.prod.arr (mail.arr [10.99.0.5]) by mx0.arrikto.com (Postfix) with ESMTP id B6B73182004; Fri, 1 Mar 2019 18:52:43 +0200 (EET) Received: from snf-864.vm.snf.arr (snf-864.vm.snf.arr [10.97.70.29]) by troi.prod.arr (Postfix) with ESMTPSA id 6F13D2BA; Fri, 1 Mar 2019 18:52:43 +0200 (EET) From: Nikos Tsironis To: snitzer@redhat.com, agk@redhat.com, dm-devel@redhat.com Date: Fri, 1 Mar 2019 18:51:46 +0200 Message-Id: <20190301165151.1352-1-ntsironis@arrikto.com> X-Greylist: Sender passed SPF test, ACL 242 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 01 Mar 2019 16:52:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 01 Mar 2019 16:52:46 +0000 (UTC) for IP:'212.71.252.59' DOMAIN:'mx0.arrikto.com' HELO:'mx0.arrikto.com' FROM:'ntsironis@arrikto.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 212.71.252.59 mx0.arrikto.com 212.71.252.59 mx0.arrikto.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: mpatocka@redhat.com, iliastsi@arrikto.com Subject: [dm-devel] [PATCH v2 0/5] dm snapshot: Improve performance using a more fine-grained locking scheme 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.43]); Fri, 01 Mar 2019 16:53:50 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP dm-snapshot uses a single mutex to serialize every access to the snapshot state, including accesses to the exception hash tables. This mutex is a bottleneck preventing dm-snapshot to scale as the number of threads doing IO increases. The major contention points are __origin_write()/snapshot_map() and pending_complete(), i.e., the submission and completion of pending exceptions. This patchset substitutes the single mutex with: * A read-write semaphore, which protects the mostly read fields of the snapshot structure. * Per-bucket bit spinlocks, that protect accesses to the exception hash tables. fio benchmarks using the null_blk device show significant performance improvements as the number of worker processes increases. Write latency is almost halved and write IOPS are nearly doubled. The relevant patch provides detailed benchmark results. A summary of the patchset follows: 1. The first patch adds two helper functions to linux/list_bl.h, which is used to implement the per-bucket bit spinlocks in dm-snapshot. 2. The second patch removes the need to sleep holding the snapshot lock in pending_complete(), thus allowing us to replace the mutex with the per-bucket bit spinlocks. 3. The third patch changes the locking scheme, as described previously. Changes in v2: - Split third patch of v1 into three patches: 3/5, 4/5, 5/5. v1: https://www.redhat.com/archives/dm-devel/2018-December/msg00161.html Nikos Tsironis (5): list_bl: Add hlist_bl_add_before/behind helpers dm snapshot: Don't sleep holding the snapshot lock dm snapshot: Replace mutex with rw semaphore dm snapshot: Make exception tables scalable dm snapshot: Use fine-grained locking scheme drivers/md/dm-exception-store.h | 3 +- drivers/md/dm-snap.c | 359 +++++++++++++++++++++++++++------------- include/linux/list_bl.h | 27 +++ 3 files changed, 269 insertions(+), 120 deletions(-) Acked-by: Mikulas Patocka