All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Remove several superfluous sector casts
@ 2025-08-15 16:54 Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 1/5] block, bfq: Remove a superfluous cast Bart Van Assche
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Christoph Hellwig, Bart Van Assche

Hi Jens,

This patch series fixes one bcache bug and removes superfluous casts of sector
numbers / offsets. Please consider this patch series for inclusion in the
upstream kernel.

Thanks,

Bart.

Changes compared to v2:
 - Fixed Kent's email address.

Changes compared to v1:
 - Rebased on top of v6.17-rc1.
 - Added Acked-by and Reviewed-by tags.

Bart Van Assche (5):
  block, bfq: Remove a superfluous cast
  block, genhd: Remove disk_stats.sectors casts
  bcache, tracing: Do not truncate orig_sector
  bcache, tracing: Remove superfluous casts
  block, tracing: Remove superfluous casts

 block/bfq-iosched.c           |  3 +--
 block/genhd.c                 | 12 ++++++------
 include/trace/events/bcache.h | 15 +++++++--------
 include/trace/events/block.h  | 34 +++++++++++++---------------------
 4 files changed, 27 insertions(+), 37 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/5] block, bfq: Remove a superfluous cast
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
@ 2025-08-15 16:54 ` Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 2/5] block, genhd: Remove disk_stats.sectors casts Bart Van Assche
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Yu Kuai,
	Chaitanya Kulkarni

sector_t is a synonym for u64 and all architectures define u64 as unsigned
long long. Hence, it is not necessary to cast type sector_t to unsigned
long long. Remove a superfluous cast to improve compile-time type checking.

Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/bfq-iosched.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 50e51047e1fe..d24143f55fd2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -760,8 +760,7 @@ bfq_rq_pos_tree_lookup(struct bfq_data *bfqd, struct rb_root *root,
 	if (rb_link)
 		*rb_link = p;
 
-	bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d",
-		(unsigned long long)sector,
+	bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d", sector,
 		bfqq ? bfqq->pid : 0);
 
 	return bfqq;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/5] block, genhd: Remove disk_stats.sectors casts
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 1/5] block, bfq: Remove a superfluous cast Bart Van Assche
@ 2025-08-15 16:54 ` Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 3/5] bcache, tracing: Do not truncate orig_sector Bart Van Assche
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche,
	Chaitanya Kulkarni

In include/linux/part_stat.h, disk_stats.sectors is declared as
unsigned long[]. Instead of casting disk_stats.sectors to unsigned long
long and formatting it with %llu, remove the cast and format these numbers
with %lu. No functionality has been changed.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/genhd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 9bbc38d12792..31cff7980f70 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1074,19 +1074,19 @@ ssize_t part_stat_show(struct device *dev,
 	}
 	part_stat_read_all(bdev, &stat);
 	return sysfs_emit(buf,
-		"%8lu %8lu %8llu %8u "
-		"%8lu %8lu %8llu %8u "
+		"%8lu %8lu %8lu %8u "
+		"%8lu %8lu %8lu %8u "
 		"%8u %8u %8u "
-		"%8lu %8lu %8llu %8u "
+		"%8lu %8lu %8lu %8u "
 		"%8lu %8u"
 		"\n",
 		stat.ios[STAT_READ],
 		stat.merges[STAT_READ],
-		(unsigned long long)stat.sectors[STAT_READ],
+		stat.sectors[STAT_READ],
 		(unsigned int)div_u64(stat.nsecs[STAT_READ], NSEC_PER_MSEC),
 		stat.ios[STAT_WRITE],
 		stat.merges[STAT_WRITE],
-		(unsigned long long)stat.sectors[STAT_WRITE],
+		stat.sectors[STAT_WRITE],
 		(unsigned int)div_u64(stat.nsecs[STAT_WRITE], NSEC_PER_MSEC),
 		inflight,
 		jiffies_to_msecs(stat.io_ticks),
@@ -1097,7 +1097,7 @@ ssize_t part_stat_show(struct device *dev,
 						NSEC_PER_MSEC),
 		stat.ios[STAT_DISCARD],
 		stat.merges[STAT_DISCARD],
-		(unsigned long long)stat.sectors[STAT_DISCARD],
+		stat.sectors[STAT_DISCARD],
 		(unsigned int)div_u64(stat.nsecs[STAT_DISCARD], NSEC_PER_MSEC),
 		stat.ios[STAT_FLUSH],
 		(unsigned int)div_u64(stat.nsecs[STAT_FLUSH], NSEC_PER_MSEC));

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/5] bcache, tracing: Do not truncate orig_sector
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 1/5] block, bfq: Remove a superfluous cast Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 2/5] block, genhd: Remove disk_stats.sectors casts Bart Van Assche
@ 2025-08-15 16:54 ` Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 4/5] bcache, tracing: Remove superfluous casts Bart Van Assche
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Kent Overstreet,
	Coly Li, Chaitanya Kulkarni, Steven Rostedt, Masami Hiramatsu

Change the type of orig_sector from dev_t (unsigned int) into sector_t
(u64) to prevent truncation of orig_sector by the tracing code.

Cc: Kent Overstreet <kent.overstreet@linux.dev>
Acked-by: Coly Li <colyli@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Fixes: cafe56359144 ("bcache: A block layer cache")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/trace/events/bcache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/events/bcache.h b/include/trace/events/bcache.h
index 899fdacf57b9..d0eee403dc15 100644
--- a/include/trace/events/bcache.h
+++ b/include/trace/events/bcache.h
@@ -16,7 +16,7 @@ DECLARE_EVENT_CLASS(bcache_request,
 		__field(unsigned int,	orig_major		)
 		__field(unsigned int,	orig_minor		)
 		__field(sector_t,	sector			)
-		__field(dev_t,		orig_sector		)
+		__field(sector_t,	orig_sector		)
 		__field(unsigned int,	nr_sector		)
 		__array(char,		rwbs,	6		)
 	),

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 4/5] bcache, tracing: Remove superfluous casts
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
                   ` (2 preceding siblings ...)
  2025-08-15 16:54 ` [PATCH v3 3/5] bcache, tracing: Do not truncate orig_sector Bart Van Assche
@ 2025-08-15 16:54 ` Bart Van Assche
  2025-08-15 16:54 ` [PATCH v3 5/5] block, " Bart Van Assche
  2025-08-19  1:47 ` [PATCH v3 0/5] Remove several superfluous sector casts Martin K. Petersen
  5 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Coly Li,
	Chaitanya Kulkarni, Steven Rostedt, Masami Hiramatsu

sector_t is a synonym for u64 and all architectures define u64 as unsigned
long long. Hence, it is not necessary to cast type sector_t to unsigned
long long. Remove the superfluous casts to improve compile-time type
checking.

Acked-by: Coly Li <colyli@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/trace/events/bcache.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/trace/events/bcache.h b/include/trace/events/bcache.h
index d0eee403dc15..697e0f80d17c 100644
--- a/include/trace/events/bcache.h
+++ b/include/trace/events/bcache.h
@@ -33,9 +33,9 @@ DECLARE_EVENT_CLASS(bcache_request,
 
 	TP_printk("%d,%d %s %llu + %u (from %d,%d @ %llu)",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, (unsigned long long)__entry->sector,
+		  __entry->rwbs, __entry->sector,
 		  __entry->nr_sector, __entry->orig_major, __entry->orig_minor,
-		  (unsigned long long)__entry->orig_sector)
+		  __entry->orig_sector)
 );
 
 DECLARE_EVENT_CLASS(bkey,
@@ -107,7 +107,7 @@ DECLARE_EVENT_CLASS(bcache_bio,
 
 	TP_printk("%d,%d  %s %llu + %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector, __entry->nr_sector)
+		  __entry->sector, __entry->nr_sector)
 );
 
 DEFINE_EVENT(bcache_bio, bcache_bypass_sequential,
@@ -144,7 +144,7 @@ TRACE_EVENT(bcache_read,
 
 	TP_printk("%d,%d  %s %llu + %u hit %u bypass %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
-		  __entry->rwbs, (unsigned long long)__entry->sector,
+		  __entry->rwbs, __entry->sector,
 		  __entry->nr_sector, __entry->cache_hit, __entry->bypass)
 );
 
@@ -175,7 +175,7 @@ TRACE_EVENT(bcache_write,
 
 	TP_printk("%pU inode %llu  %s %llu + %u hit %u bypass %u",
 		  __entry->uuid, __entry->inode,
-		  __entry->rwbs, (unsigned long long)__entry->sector,
+		  __entry->rwbs, __entry->sector,
 		  __entry->nr_sector, __entry->writeback, __entry->bypass)
 );
 
@@ -243,8 +243,7 @@ TRACE_EVENT(bcache_journal_write,
 
 	TP_printk("%d,%d  %s %llu + %u keys %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector, __entry->nr_sector,
-		  __entry->nr_keys)
+		  __entry->sector, __entry->nr_sector, __entry->nr_keys)
 );
 
 /* Btree */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 5/5] block, tracing: Remove superfluous casts
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
                   ` (3 preceding siblings ...)
  2025-08-15 16:54 ` [PATCH v3 4/5] bcache, tracing: Remove superfluous casts Bart Van Assche
@ 2025-08-15 16:54 ` Bart Van Assche
  2025-08-19  1:47 ` [PATCH v3 0/5] Remove several superfluous sector casts Martin K. Petersen
  5 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2025-08-15 16:54 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Christoph Hellwig, Bart Van Assche, Damien Le Moal,
	Chaitanya Kulkarni, Steven Rostedt, Masami Hiramatsu,
	Johannes Thumshirn, Ritesh Harjani (IBM)

sector_t is a synonym for u64 and all architectures define u64 as unsigned
long long. Hence, it is not necessary to cast type sector_t to unsigned
long long. Remove the superfluous casts to improve compile-time type
checking.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/trace/events/block.h | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 6aa79e2d799c..57fcf3d673fd 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -41,7 +41,7 @@ DECLARE_EVENT_CLASS(block_buffer,
 
 	TP_printk("%d,%d sector=%llu size=%zu",
 		MAJOR(__entry->dev), MINOR(__entry->dev),
-		(unsigned long long)__entry->sector, __entry->size
+		__entry->sector, __entry->size
 	)
 );
 
@@ -108,7 +108,7 @@ TRACE_EVENT(block_rq_requeue,
 	TP_printk("%d,%d %s (%s) %llu + %u %s,%u,%u [%d]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector, __entry->nr_sector,
+		  __entry->sector, __entry->nr_sector,
 		  __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
 				   IOPRIO_CLASS_STRINGS),
 		  IOPRIO_PRIO_HINT(__entry->ioprio),
@@ -145,7 +145,7 @@ DECLARE_EVENT_CLASS(block_rq_completion,
 	TP_printk("%d,%d %s (%s) %llu + %u %s,%u,%u [%d]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->rwbs, __get_str(cmd),
-		  (unsigned long long)__entry->sector, __entry->nr_sector,
+		  __entry->sector, __entry->nr_sector,
 		  __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
 				   IOPRIO_CLASS_STRINGS),
 		  IOPRIO_PRIO_HINT(__entry->ioprio),
@@ -219,7 +219,7 @@ DECLARE_EVENT_CLASS(block_rq,
 	TP_printk("%d,%d %s %u (%s) %llu + %u %s,%u,%u [%s]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev),
 		  __entry->rwbs, __entry->bytes, __get_str(cmd),
-		  (unsigned long long)__entry->sector, __entry->nr_sector,
+		  __entry->sector, __entry->nr_sector,
 		  __print_symbolic(IOPRIO_PRIO_CLASS(__entry->ioprio),
 				   IOPRIO_CLASS_STRINGS),
 		  IOPRIO_PRIO_HINT(__entry->ioprio),
@@ -328,8 +328,7 @@ TRACE_EVENT(block_bio_complete,
 
 	TP_printk("%d,%d %s %llu + %u [%d]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->error)
+		  __entry->sector, __entry->nr_sector, __entry->error)
 );
 
 DECLARE_EVENT_CLASS(block_bio,
@@ -356,8 +355,7 @@ DECLARE_EVENT_CLASS(block_bio,
 
 	TP_printk("%d,%d %s %llu + %u [%s]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector, __entry->comm)
+		  __entry->sector, __entry->nr_sector, __entry->comm)
 );
 
 /**
@@ -509,9 +507,7 @@ TRACE_EVENT(block_split,
 
 	TP_printk("%d,%d %s %llu / %llu [%s]",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  (unsigned long long)__entry->new_sector,
-		  __entry->comm)
+		  __entry->sector, __entry->new_sector, __entry->comm)
 );
 
 /**
@@ -549,10 +545,9 @@ TRACE_EVENT(block_bio_remap,
 
 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector,
+		  __entry->sector, __entry->nr_sector,
 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
-		  (unsigned long long)__entry->old_sector)
+		  __entry->old_sector)
 );
 
 /**
@@ -593,10 +588,9 @@ TRACE_EVENT(block_rq_remap,
 
 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sector,
+		  __entry->sector, __entry->nr_sector,
 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
-		  (unsigned long long)__entry->old_sector, __entry->nr_bios)
+		  __entry->old_sector, __entry->nr_bios)
 );
 
 /**
@@ -630,8 +624,7 @@ TRACE_EVENT(blkdev_zone_mgmt,
 
 	TP_printk("%d,%d %s %llu + %llu",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sectors)
+		  __entry->sector, __entry->nr_sectors)
 );
 
 DECLARE_EVENT_CLASS(block_zwplug,
@@ -657,8 +650,7 @@ DECLARE_EVENT_CLASS(block_zwplug,
 
 	TP_printk("%d,%d zone %u, BIO %llu + %u",
 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->zno,
-		  (unsigned long long)__entry->sector,
-		  __entry->nr_sectors)
+		  __entry->sector, __entry->nr_sectors)
 );
 
 DEFINE_EVENT(block_zwplug, disk_zone_wplug_add_bio,

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/5] Remove several superfluous sector casts
  2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
                   ` (4 preceding siblings ...)
  2025-08-15 16:54 ` [PATCH v3 5/5] block, " Bart Van Assche
@ 2025-08-19  1:47 ` Martin K. Petersen
  5 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-08-19  1:47 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Jens Axboe, linux-block, Christoph Hellwig


Bart,

> This patch series fixes one bcache bug and removes superfluous casts
> of sector numbers / offsets. Please consider this patch series for
> inclusion in the upstream kernel.

Looks OK.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-19  1:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15 16:54 [PATCH v3 0/5] Remove several superfluous sector casts Bart Van Assche
2025-08-15 16:54 ` [PATCH v3 1/5] block, bfq: Remove a superfluous cast Bart Van Assche
2025-08-15 16:54 ` [PATCH v3 2/5] block, genhd: Remove disk_stats.sectors casts Bart Van Assche
2025-08-15 16:54 ` [PATCH v3 3/5] bcache, tracing: Do not truncate orig_sector Bart Van Assche
2025-08-15 16:54 ` [PATCH v3 4/5] bcache, tracing: Remove superfluous casts Bart Van Assche
2025-08-15 16:54 ` [PATCH v3 5/5] block, " Bart Van Assche
2025-08-19  1:47 ` [PATCH v3 0/5] Remove several superfluous sector casts Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.