Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp309814pxu; Fri, 23 Oct 2020 00:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzck9C2jtfP62pbs7/xSs4HbrJzjTaL6XMp3D8IZYH0ECojPdiyxq0l/cBokwGYvplr1Ncu X-Received: by 2002:a17:907:24cf:: with SMTP id e15mr754550ejn.191.1603439989314; Fri, 23 Oct 2020 00:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603439989; cv=none; d=google.com; s=arc-20160816; b=TS/4XdWWavjumf0GtOl+UkqJxE16r39PWhS7PUYaCOFKQKKa0Z/AH8Nj2GMgIJxFQ3 5nt0NGrKh7lJFO4jlD+VvW92yW2wAC6TUfrHKNDl32uP5/AGvBGiNxlXHgrxvYIqRGS5 WTQ9HCPkcitkWovYX5WqMNUf7NitXBGFR7MOl2/xlDCOLJ+PCkSUsnaH4mKiuicmDYra 0d4pHdip4DZf3hIwUHmnDEzstbL5YCxJI8k7c8wpZRa5fohgi2EruZtJaCNPD1benzmz nhs+KZzv1JAkal/PEA+ZzKTnqTxmsRgoiy/PUgauKlsLWQR+I7eYc9EsUKtDxHV8xtku zb6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GZM44D/Mc0nu3nh+1+8KJjUfK9tbD8dmy97W4TiMTYA=; b=ZjwlLUBXqUx9W7s2OHPR5ZqBK4nb6E5+R6OpKtuxC3fsxQQE6agLSaipcKL2mSuz1e zqfXgk9p+cWI8E4xgOQR2y4Z/eywEnoFf9bW7TnjSRhzVRwSLzB3II0ITjb1qVIIekL6 uSIAwMqEFdJxWd6zZCOD+erZll5bhofD/PBpSU/pCfwwNHUDoCWZ/W6MizKsG7dzCvCv IkSKezKbyTrl2cltSJpu+4Weswyjvexiqb+JskTdx0IysFfhF30KIPzcxNwebcIRElF0 eIHnnn27wstXCuJAJM1uizDUTKSd56wYIUlbCgUfT758WhDEZjno3zqBzxM4Y3hwJMIx sKkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mqh+sCvP; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cd8si421739ejb.516.2020.10.23.00.59.27; Fri, 23 Oct 2020 00:59:49 -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=@kernel.org header.s=default header.b=Mqh+sCvP; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S371632AbgJWFmF (ORCPT + 99 others); Fri, 23 Oct 2020 01:42:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:58138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S371624AbgJWFmF (ORCPT ); Fri, 23 Oct 2020 01:42:05 -0400 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3DFD020BED; Fri, 23 Oct 2020 05:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603431724; bh=YMvvRcZYimxB0yoov1roU28wevk7Men9gENsSxF7cvM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Mqh+sCvPQC67UG5bWtV3Eh+J6Oih83DZhxYLFMLw7x9+m7mjooq4w3UF9xWhlBvMi nBpU1mK1Mh9mWCN3pk3kquDYvePW9KAAxYngKYRpAx77pcQJQ3Mvyb8q6fmPvkzJ/I M3HRoj4Qmwdg/s8TgrxMdjmg0o5wAlY0wcl2MR8k= Received: by mail-lf1-f49.google.com with SMTP id v6so569010lfa.13; Thu, 22 Oct 2020 22:42:04 -0700 (PDT) X-Gm-Message-State: AOAM533Do49Cnjuz4iXar/LNsW5M/dFYtyn2LVwaTtMD6pRi/EeNGG7j 5FkBsXIDxh93GfLXxMwWAHljJniyCs+npDqPFEo= X-Received: by 2002:a05:6512:3710:: with SMTP id z16mr194904lfr.504.1603431722387; Thu, 22 Oct 2020 22:42:02 -0700 (PDT) MIME-Version: 1.0 References: <20201023033130.11354-1-cunkel@drivescale.com> In-Reply-To: <20201023033130.11354-1-cunkel@drivescale.com> From: Song Liu Date: Thu, 22 Oct 2020 22:41:51 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/3] mdraid sb and bitmap write alignment on 512e drives To: Christopher Unkel Cc: linux-raid , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 8:31 PM Christopher Unkel wrote: > > Hello all, > > While investigating some performance issues on mdraid 10 volumes > formed with "512e" disks (4k native/physical sector size but with 512 > byte sector emulation), I've found two cases where mdraid will > needlessly issue writes that start on 4k byte boundary, but are are > shorter than 4k: > > 1. writes of the raid superblock; and > 2. writes of the last page of the write-intent bitmap. > > The following is an excerpt of a blocktrace of one of the component > members of a mdraid 10 volume during a 4k write near the end of the > array: > > 8,32 11 2 0.000001687 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 5 0.001454119 711 D WS 2056 + 1 [kworker/11:1H] > * 8,32 11 8 0.002847204 711 D WS 2080 + 7 [kworker/11:1H] > 8,32 11 11 0.003700545 3094 D WS 11721043920 + 8 [md127_raid1] > 8,32 11 14 0.308785692 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 17 0.310201697 711 D WS 2056 + 1 [kworker/11:1H] > 8,32 11 20 5.500799245 711 D WS 2064 + 8 [kworker/11:1H] > * 8,32 11 23 15.740923558 711 D WS 2080 + 7 [kworker/11:1H] > > Note the starred transactions, which each start on a 4k boundary, but > are less than 4k in length, and so will use the 512-byte emulation. > Sector 2056 holds the superblock, and is written as a single 512-byte > write. Sector 2086 holds the bitmap bit relevant to the written > sector. When it is written the active bits of the last page of the > bitmap are written, starting at sector 2080, padded out to the end of > the 512-byte logical sector as required. This results in a 3.5kb > write, again using the 512-byte emulation. > > Note that in some arrays the last page of the bitmap may be > sufficiently full that they are not affected by the issue with the > bitmap write. > > As there can be a substantial penalty to using the 512-byte sector > emulation (turning writes into read-modify writes if the relevant > sector is not in the drive's cache) I believe it makes sense to pad > these writes out to a 4k boundary. The writes are already padded out > for "4k native" drives, where the short access is illegal. > > The following patch set changes the superblock and bitmap writes to > respect the physical block size (e.g. 4k for today's 512e drives) when > possible. In each case there is already logic for padding out to the > underlying logical sector size. I reuse or repeat the logic for > padding out to the physical sector size, but treat the padding out as > optional rather than mandatory. > > The corresponding block trace with these patches is: > > 8,32 1 2 0.000003410 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 5 0.001368788 694 D WS 2056 + 8 [kworker/1:1H] > 8,32 1 8 0.002727981 694 D WS 2080 + 8 [kworker/1:1H] > 8,32 1 11 0.003533831 3063 D WS 11721043920 + 8 [md127_raid1] > 8,32 1 14 0.253952321 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 17 0.255354215 694 D WS 2056 + 8 [kworker/1:1H] > 8,32 1 20 5.337938486 694 D WS 2064 + 8 [kworker/1:1H] > 8,32 1 23 15.577963062 694 D WS 2080 + 8 [kworker/1:1H] > > I do notice that the code for bitmap writes has a more sophisticated > and thorough check for overlap than the code for superblock writes. > (Compare write_sb_page in md-bitmap.c vs. super_1_load in md.c.) From > what I know since the various structures starts have always been 4k > aligned anyway, it is always safe to pad the superblock write out to > 4k (as occurs on 4k native drives) but not necessarily futher. > > Feedback appreciated. > > --Chris Thanks for the patches. Do you have performance numbers before/after these changes? Some micro benchmarks results would be great motivation. Thanks, Song > > > Christopher Unkel (3): > md: align superblock writes to physical blocks > md: factor sb write alignment check into function > md: pad writes to end of bitmap to physical blocks > > drivers/md/md-bitmap.c | 80 +++++++++++++++++++++++++----------------- > drivers/md/md.c | 15 ++++++++ > 2 files changed, 63 insertions(+), 32 deletions(-) > > -- > 2.17.1 >