[PATCH 1/8] selftests: ublk: correct last_rw map type in seq_io.bt

Caleb Sander Mateos posted 8 patches 5 days, 11 hours ago
There is a newer version of this series
[PATCH 1/8] selftests: ublk: correct last_rw map type in seq_io.bt
Posted by Caleb Sander Mateos 5 days, 11 hours ago
The last_rw map is initialized with a value of 0 but later assigned the
value args.sector + args.nr_sector, which has type sector_t = u64.
bpftrace complains about the type mismatch between int64 and uint64:
trace/seq_io.bt:18:3-59: ERROR: Type mismatch for @last_rw: trying to assign value of type 'uint64' when map already contains a value of type 'int64'
        @last_rw[$dev, str($2)] = (args.sector + args.nr_sector);

Cast the initial value to uint64 so bpftrace will load the program.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 tools/testing/selftests/ublk/trace/seq_io.bt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ublk/trace/seq_io.bt b/tools/testing/selftests/ublk/trace/seq_io.bt
index 272ac54c9d5f..507a3ca05abf 100644
--- a/tools/testing/selftests/ublk/trace/seq_io.bt
+++ b/tools/testing/selftests/ublk/trace/seq_io.bt
@@ -2,11 +2,11 @@
 	$1: 	dev_t
 	$2: 	RWBS
 	$3:     strlen($2)
 */
 BEGIN {
-	@last_rw[$1, str($2)] = 0;
+	@last_rw[$1, str($2)] = (uint64)0;
 }
 tracepoint:block:block_rq_complete
 {
 	$dev = $1;
 	if ((int64)args.dev == $1 && !strncmp(args.rwbs, str($2), $3)) {
-- 
2.45.2
Re: [PATCH 1/8] selftests: ublk: correct last_rw map type in seq_io.bt
Posted by Ming Lei 5 days, 7 hours ago
On Wed, Dec 10, 2025 at 10:15:56PM -0700, Caleb Sander Mateos wrote:
> The last_rw map is initialized with a value of 0 but later assigned the
> value args.sector + args.nr_sector, which has type sector_t = u64.
> bpftrace complains about the type mismatch between int64 and uint64:
> trace/seq_io.bt:18:3-59: ERROR: Type mismatch for @last_rw: trying to assign value of type 'uint64' when map already contains a value of type 'int64'
>         @last_rw[$dev, str($2)] = (args.sector + args.nr_sector);
> 
> Cast the initial value to uint64 so bpftrace will load the program.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
>  tools/testing/selftests/ublk/trace/seq_io.bt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/ublk/trace/seq_io.bt b/tools/testing/selftests/ublk/trace/seq_io.bt
> index 272ac54c9d5f..507a3ca05abf 100644
> --- a/tools/testing/selftests/ublk/trace/seq_io.bt
> +++ b/tools/testing/selftests/ublk/trace/seq_io.bt
> @@ -2,11 +2,11 @@
>  	$1: 	dev_t
>  	$2: 	RWBS
>  	$3:     strlen($2)
>  */
>  BEGIN {
> -	@last_rw[$1, str($2)] = 0;
> +	@last_rw[$1, str($2)] = (uint64)0;

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming