From patchwork Mon Feb 3 18:41:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13958014 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4406D1922F6 for ; Mon, 3 Feb 2025 18:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738608236; cv=none; b=Pc355JBW03fsYB3qGLDcI+Qq+sqWWc/1XoxtBGbHzjonKqXcP7syXHrhkQmePPcym8qU6NXRtD0H+DF412p+9yQ1TJH1yryU8x+bsq5nra5haOZokEOozd64jTk57js1UeyETfxA8dVZijx93/k2fTHvRtXxniE1SwCqmE30jNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738608236; c=relaxed/simple; bh=rHXuJVlwM6MHiXntSK70gQzihbKi5IYzSwVqyr8z7Rs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fkRgchnLdfQt4K3pOJWABE6mNSmo1IRiyDT82mbXOGq9fv+U651K25Ree3DLtMZeULe84qRHJcRZ3/iXKr2xp4FyR38dcL+odiBfUvdWPkkvDqoOTk5xcvG1hX4AIWIbT+A3ergeyekEb3pFQn0EYGKt2rvDi/0VFdni23AzXJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=ZXBdj27W; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="ZXBdj27W" Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 513IHpkg029078 for ; Mon, 3 Feb 2025 10:43:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=s2048-2021-q4; bh=nQyaNOkEiJKrwg1pUGQQuMbh9usC9AVDbq//1SwlJY4=; b=ZXBdj27W7V6X q6/8WAD/w6DV/L2MggOWZhVrOxfBHQtD+Z/eGv4ypjgxh3vM85vqV2lv1NZo4kSs NSy4eTDWFoDvK0sVTpnrJWpUGmvhZmL4rV/pUVuXcjWg7rZjyIiKkdpTwR3sYKIr hXXQ1u0trOFIkyPGeKHQQXiBIWXPr0yEphU+bCi5hLd4Bs0EXlTbEN0K0YdlYBcs X3ejwEySnSdH5nRPv4OI6Z0zPdmnn81k5+Ketx8uBouKfBwi/pt4HpAu5a2vC2++ cb0uin3i4L5isnnHRxcdr79Ewp8aSipuFNtd6wtKzWakXhqGv1/qR3p2JVLC4taF wMeNpMA6Yw== Received: from maileast.thefacebook.com ([163.114.135.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 44k2e9ghex-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 03 Feb 2025 10:43:53 -0800 (PST) Received: from twshared53813.03.ash8.facebook.com (2620:10d:c0a8:1c::1b) by mail.thefacebook.com (2620:10d:c0a9:6f::8fd4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.14; Mon, 3 Feb 2025 18:43:52 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id A168E179C2629; Mon, 3 Feb 2025 10:41:34 -0800 (PST) From: Keith Busch To: , , CC: , , , , , Hannes Reinecke , Nitesh Shetty , Keith Busch Subject: [PATCHv2 04/11] block: introduce a write_stream_granularity queue limit Date: Mon, 3 Feb 2025 10:41:22 -0800 Message-ID: <20250203184129.1829324-5-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250203184129.1829324-1-kbusch@meta.com> References: <20250203184129.1829324-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: wzMiC0QkOJA7GZ-Mc2_GyP0K0LO4Nroa X-Proofpoint-GUID: wzMiC0QkOJA7GZ-Mc2_GyP0K0LO4Nroa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_08,2025-01-31_02,2024-11-22_01 From: Christoph Hellwig Export the granularity that write streams should be discarded with, as it is essential for making good use of them. Reviewed-by: Hannes Reinecke Reviewed-by: Nitesh Shetty Signed-off-by: Christoph Hellwig Signed-off-by: Keith Busch --- Documentation/ABI/stable/sysfs-block | 8 ++++++++ block/blk-sysfs.c | 3 +++ include/linux/blkdev.h | 1 + 3 files changed, 12 insertions(+) diff --git a/Documentation/ABI/stable/sysfs-block b/Documentation/ABI/stable/sysfs-block index f67139b8b8eff..c454c68b68fe6 100644 --- a/Documentation/ABI/stable/sysfs-block +++ b/Documentation/ABI/stable/sysfs-block @@ -514,6 +514,14 @@ Description: supported. If supported, valid values are 1 through max_write_streams, inclusive. +What: /sys/block//queue/write_stream_granularity +Date: November 2024 +Contact: linux-block@vger.kernel.org +Description: + [RO] Granularity of a write stream in bytes. The granularity + of a write stream is the size that should be discarded or + overwritten together to avoid write amplification in the device. + What: /sys/block//queue/max_segments Date: March 2010 Contact: linux-block@vger.kernel.org diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 8b8f2b0f0c048..a4badc1f8d904 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -107,6 +107,7 @@ QUEUE_SYSFS_LIMIT_SHOW(max_discard_segments) QUEUE_SYSFS_LIMIT_SHOW(max_integrity_segments) QUEUE_SYSFS_LIMIT_SHOW(max_segment_size) QUEUE_SYSFS_LIMIT_SHOW(max_write_streams) +QUEUE_SYSFS_LIMIT_SHOW(write_stream_granularity) QUEUE_SYSFS_LIMIT_SHOW(logical_block_size) QUEUE_SYSFS_LIMIT_SHOW(physical_block_size) QUEUE_SYSFS_LIMIT_SHOW(chunk_sectors) @@ -436,6 +437,7 @@ QUEUE_RO_ENTRY(queue_max_segments, "max_segments"); QUEUE_RO_ENTRY(queue_max_integrity_segments, "max_integrity_segments"); QUEUE_RO_ENTRY(queue_max_segment_size, "max_segment_size"); QUEUE_RO_ENTRY(queue_max_write_streams, "max_write_streams"); +QUEUE_RO_ENTRY(queue_write_stream_granularity, "write_stream_granularity"); QUEUE_RW_LOAD_MODULE_ENTRY(elv_iosched, "scheduler"); QUEUE_RO_ENTRY(queue_logical_block_size, "logical_block_size"); @@ -571,6 +573,7 @@ static struct attribute *queue_attrs[] = { &queue_max_integrity_segments_entry.attr, &queue_max_segment_size_entry.attr, &queue_max_write_streams_entry.attr, + &queue_write_stream_granularity_entry.attr, &queue_hw_sector_size_entry.attr, &queue_logical_block_size_entry.attr, &queue_physical_block_size_entry.attr, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f92db4b35f4b6..927d5531930e3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -398,6 +398,7 @@ struct queue_limits { unsigned short max_discard_segments; unsigned short max_write_streams; + unsigned int write_stream_granularity; unsigned int max_open_zones; unsigned int max_active_zones;