Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724903pxb; Tue, 2 Feb 2021 16:47:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/rvfhZOInjLXLT67dA9P1/F+UAepQHEIib6KpdXamT9h6RWrVUSEjyjaIee3Ot6GlPPQc X-Received: by 2002:a17:906:1c4b:: with SMTP id l11mr613900ejg.155.1612313261857; Tue, 02 Feb 2021 16:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313261; cv=none; d=google.com; s=arc-20160816; b=mv47n8JIit/9Jd9Nii71cmxOzHY/AG4fpX0Ov4BK44qbB15lj+LhxSnwdXpEvTMghd WLhOvPCgvpol2iYN9ysXw98OOism1RNgijr414LyqDRWZRztcqrh9uW1NpEKi3LOP9u7 WWFDXkcJZAZg7cutNOrPGtVBdhi9250cYxvQXnxWez5tQCndITF0gHPftKgImSZPBSNF +MoTLYpMasB8IDWUiqVKsxeWx4qvENEfxDxjwwVxpNlrnWRku5vmuX8pbRf4fwtnapne QL8Tkl1ydS+5vjpAU6+Fs8dNKcKBn7NUbHdB0KGjzIEhk771BilxM2QX8syxWoXMGUeo g64g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BHgXh82d0aWL2kXJRc3tSCu5l4j8K/a6g5S8hLWA+IQ=; b=KV151A2Cq7FHcS5THZKJ8ZvnrUE1yWC8pB7URI9lVW+vu4Km+xYuJi0igkjdmNf9ct XWZElDyIr/KXhYBsZxUJNcQwlstQZFSIvebI+R1F7ggcXbYF/Y15cslCtcgQdo09nF3U boEWNbMnwipxXsY4RuPEb4yVVBOtc0eSZdgCEiII1Lqo5TBfVHYTvjp1+oh4ko/wToco x/ALQROlJGHSiznaDhsKC44ROvRaJp/GjzF5X0SM92ydukVoCbxDB9l1IEY1WqcdEj3t 9syH2UjuTU+KCJJIeUGX0Lhd5uEqCmTLQ7nv1pEyuP9CmZVLQXocOmYx7P+ThBxG/ukD IZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pdxofku2; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si249103edr.533.2021.02.02.16.47.17; Tue, 02 Feb 2021 16:47:41 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Pdxofku2; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239967AbhBBTnT (ORCPT + 99 others); Tue, 2 Feb 2021 14:43:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:42038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233271AbhBBNxY (ORCPT ); Tue, 2 Feb 2021 08:53:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9087264FD6; Tue, 2 Feb 2021 13:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273444; bh=AE5CRdV5pTg398EOsEgJPgCIIxFO+/EblHIVh2hYYrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pdxofku2klLIV6p/mimMlZ732OLPKp0ZBOcz4kJ8qYO19DB3K/KW85zkka20sn/Th HW2dhj9hSxbNu22oR52/RCoJ5zTgDAuCWvMOa5k3FUEYz4kVsR/5K7aoz8f5/KqiB2 cg4aa1B1ohv3EKsdJcZGg9OHoEBsbnsOE4MiepYc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Christoph Hellwig , Jens Axboe Subject: [PATCH 5.10 077/142] Revert "block: simplify set_init_blocksize" to regain lost performance Date: Tue, 2 Feb 2021 14:37:20 +0100 Message-Id: <20210202133000.885609641@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Mikityanskiy commit 8dc932d3e8afb65e12eba7495f046c83884c49bf upstream. The cited commit introduced a serious regression with SATA write speed, as found by bisecting. This patch reverts this commit, which restores write speed back to the values observed before this commit. The performance tests were done on a Helios4 NAS (2nd batch) with 4 HDDs (WD8003FFBX) using dd (bs=1M count=2000). "Direct" is a test with a single HDD, the rest are different RAID levels built over the first partitions of 4 HDDs. Test results are in MB/s, R is read, W is write. | Direct | RAID0 | RAID10 f2 | RAID10 n2 | RAID6 ----------------+--------+-------+-----------+-----------+-------- 9011495c9466 | R:256 | R:313 | R:276 | R:313 | R:323 (before faulty) | W:254 | W:253 | W:195 | W:204 | W:117 ----------------+--------+-------+-----------+-----------+-------- 5ff9f19231a0 | R:257 | R:398 | R:312 | R:344 | R:391 (faulty commit) | W:154 | W:122 | W:67.7 | W:66.6 | W:67.2 ----------------+--------+-------+-----------+-----------+-------- 5.10.10 | R:256 | R:401 | R:312 | R:356 | R:375 unpatched | W:149 | W:123 | W:64 | W:64.1 | W:61.5 ----------------+--------+-------+-----------+-----------+-------- 5.10.10 | R:255 | R:396 | R:312 | R:340 | R:393 patched | W:247 | W:274 | W:220 | W:225 | W:121 Applying this patch doesn't hurt read performance, while improves the write speed by 1.5x - 3.5x (more impact on RAID tests). The write speed is restored back to the state before the faulty commit, and even a bit higher in RAID tests (which aren't HDD-bound on this device) - that is likely related to other optimizations done between the faulty commit and 5.10.10 which also improved the read speed. Signed-off-by: Maxim Mikityanskiy Fixes: 5ff9f19231a0 ("block: simplify set_init_blocksize") Cc: Christoph Hellwig Cc: Jens Axboe Acked-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/block_dev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -134,7 +134,15 @@ EXPORT_SYMBOL(truncate_bdev_range); static void set_init_blocksize(struct block_device *bdev) { - bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev)); + unsigned int bsize = bdev_logical_block_size(bdev); + loff_t size = i_size_read(bdev->bd_inode); + + while (bsize < PAGE_SIZE) { + if (size & bsize) + break; + bsize <<= 1; + } + bdev->bd_inode->i_blkbits = blksize_bits(bsize); } int set_blocksize(struct block_device *bdev, int size)