From nobody Thu Oct 2 02:16:53 2025 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 AB7E6313E3A; Thu, 25 Sep 2025 15:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.153.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758812718; cv=none; b=N86b59fWgvOBUP2h1dTxDxQwY2s2miJRbG99cy2QrtokVF+I7jhJqaXyVZVVM4cHF42XCyxiEqj7PHLIMrf+a3bacPfsFWyCM6oakzTWfJf+h8+28FLgu9TY6mf8ush2d1lf2KlrNgUwa/GOaTmgzNuG1OQRVyUyFL3dNOUO8AA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758812718; c=relaxed/simple; bh=3onupmVD5/2IoDoElAt/o05PCAfeDat+6p0RvJChYCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BYqGsLf3sGh/HGnC+qDseEdnMpEUTbIKeQ7x5sAsx22vKtvEzH6rswABhBySJ4Sd+MDVklraOMfEUgLM1TEQHR+qa/Xtw2tLzvyVjZQl9IpqY5a9QJr6qSJhsP7CE4iPyW3sfqaQBbvUbKals5+qr3DGGyOHDN9RfdkDm2TLWeM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=DehIfYce; arc=none smtp.client-ip=216.71.153.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="DehIfYce" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1758812716; x=1790348716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3onupmVD5/2IoDoElAt/o05PCAfeDat+6p0RvJChYCo=; b=DehIfYceYjcC1u1qNPKvNfQU1iQ1essDgg2QipWNWNCom9lBf5YynHkN RKMRMybhX7C8ZJyOl/xviSQb8Dr2kmklV7bRVOHYhEW1kqcpsAy0rygx4 VE1iXw637z70khr9x1IQC1EeT84c6uy/5eDxmUDTR68uQPUnFTo90foGA DpZ1T6Wua2bvuji2P9q0AS305QR0lVmwWr/KHY6TAQVKkP1PTjmnSao7l GQ/6xNa4jCgDVgzKT0hLh8Tgd0hAH5p6s67sUnrKBVH3MMJ/my8SJjrIb JgLwPRKKNLj5yYphlrO/1AyiPs8dOGNdTOhgCtjWN7TsvheOH7YuXuvJ7 A==; X-CSE-ConnectionGUID: uoWEkBHWQCCdUWfNmF/Xew== X-CSE-MsgGUID: jDIE4+AiSRCMr5/rEYfnug== X-IronPort-AV: E=Sophos;i="6.18,292,1751212800"; d="scan'208";a="130349023" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2025 23:05:16 +0800 IronPort-SDR: 68d55a2c_dKHWDae2EqzLqtkhIun/FJYm7CuZEjLziZyp/dVBGrwOsxQ qUfPrMxMeghUDxBurQEVy8jSe9QG+ox+1rbVaZg== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 25 Sep 2025 08:05:16 -0700 WDCIronportException: Internal Received: from c02g55f6ml85.ad.shared (HELO C02G55F6ML85.wdc.com) ([10.224.183.46]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Sep 2025 08:05:13 -0700 From: Johannes Thumshirn To: Jens Axboe Cc: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-btrace@vger.kernel.org, John Garry , Hannes Reinecke , Damien Le Moal , Christoph Hellwig , Naohiro Aota , Shinichiro Kawasaki , Chaitanya Kulkarni , "Martin K . Petersen" , Johannes Thumshirn Subject: [PATCH blktrace v2 10/22] blkparse: skip unsupported protocol versions Date: Thu, 25 Sep 2025 17:04:15 +0200 Message-ID: <20250925150427.67394-11-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250925150427.67394-1-johannes.thumshirn@wdc.com> References: <20250925150427.67394-1-johannes.thumshirn@wdc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Skip unsupported protocol versions for now. Signed-off-by: Johannes Thumshirn --- blkparse.c | 136 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 76 insertions(+), 60 deletions(-) diff --git a/blkparse.c b/blkparse.c index 2e175b8..163da73 100644 --- a/blkparse.c +++ b/blkparse.c @@ -2462,10 +2462,10 @@ static int read_events(int fd, int always_block, in= t *fdblock) unsigned int events =3D 0; =20 while (!is_done() && events < rb_batch) { - struct blk_io_trace *bit; struct trace *t; int should_block, ret; __u32 magic; + u8 version; =20 should_block =3D !events || always_block; =20 @@ -2489,42 +2489,50 @@ static int read_events(int fd, int always_block, in= t *fdblock) fprintf(stderr, "Bad magic %x\n", magic); break; } + version =3D magic & 0xff; + if (version =3D=3D SUPPORTED_VERSION) { + struct blk_io_trace *bit; + bit =3D bit_alloc(); + bit->magic =3D magic; =20 - bit =3D bit_alloc(); - bit->magic =3D magic; + ret =3D read_one_bit(fd, bit, 1, fdblock); + if (ret) + break; =20 - ret =3D read_one_bit(fd, bit, 1, fdblock); - if (ret) - break; + /* + * not a real trace, so grab and handle it here + */ + if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && + (bit->action & ~__BLK_TN_CGROUP) !=3D BLK_TN_MESSAGE) { + handle_notify(bit); + output_binary(bit, sizeof(*bit) + bit->pdu_len); + continue; + } =20 - if (verify_trace(bit)) { - bit_free(bit); - bit =3D NULL; - continue; - } + if (verify_trace(bit)) { + bit_free(bit); + bit =3D NULL; + continue; + } =20 - /* - * not a real trace, so grab and handle it here - */ - if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_= CGROUP) !=3D BLK_TN_MESSAGE) { - handle_notify(bit); - output_binary(bit, sizeof(*bit) + bit->pdu_len); - continue; - } + t =3D t_alloc(); + memset(t, 0, sizeof(*t)); + t->bit =3D bit; + t->read_sequence =3D read_sequence; =20 - t =3D t_alloc(); - memset(t, 0, sizeof(*t)); - t->bit =3D bit; - t->read_sequence =3D read_sequence; + t->next =3D trace_list; + trace_list =3D t; =20 - t->next =3D trace_list; - trace_list =3D t; + if (!pdi || pdi->dev !=3D bit->device) + pdi =3D get_dev_info(bit->device); =20 - if (!pdi || pdi->dev !=3D bit->device) - pdi =3D get_dev_info(bit->device); + if (bit->time > pdi->last_read_time) + pdi->last_read_time =3D bit->time; + } else { + fprintf(stderr, "unsupported version %d\n", version); + continue; + } =20 - if (bit->time > pdi->last_read_time) - pdi->last_read_time =3D bit->time; =20 events++; } @@ -2616,6 +2624,7 @@ static int ms_prime(struct ms_stream *msp) int ret, ndone =3D 0; =20 for (i =3D 0; !is_done() && pci->fd >=3D 0 && i < rb_batch; i++) { + u8 version; =20 ret =3D read_data(pci->fd, &magic, sizeof(magic), 1, &pci->fdblock); @@ -2631,46 +2640,53 @@ static int ms_prime(struct ms_stream *msp) goto err; =20 } - bit =3D bit_alloc(); - bit->magic =3D magic; + version =3D magic & 0xff; + if (version =3D=3D SUPPORTED_VERSION) { + bit =3D bit_alloc(); + bit->magic =3D magic; =20 - ret =3D read_one_bit(pci->fd, bit, 1, &pci->fdblock); - if (ret) - goto err; + ret =3D read_one_bit(pci->fd, bit, 1, &pci->fdblock); + if (ret) + goto err; =20 - if (verify_trace(bit)) - goto err; + if (verify_trace(bit)) + goto err; =20 - if (bit->cpu !=3D pci->cpu) { - fprintf(stderr, "cpu %d trace info has error cpu %d\n", - pci->cpu, bit->cpu); - continue; - } + if (bit->cpu !=3D pci->cpu) { + fprintf(stderr, + "cpu %d trace info has error cpu %d\n", + pci->cpu, bit->cpu); + continue; + } =20 - if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && (bit->action & ~__BLK_TN_= CGROUP) !=3D BLK_TN_MESSAGE) { - handle_notify(bit); - output_binary(bit, sizeof(*bit) + bit->pdu_len); - bit_free(bit); - bit =3D NULL; + if (bit->action & BLK_TC_ACT(BLK_TC_NOTIFY) && + (bit->action & ~__BLK_TN_CGROUP) !=3D BLK_TN_MESSAGE) { + handle_notify(bit); + output_binary(bit, sizeof(*bit) + bit->pdu_len); + bit_free(bit); + bit =3D NULL; =20 - i -=3D 1; - continue; - } + i -=3D 1; + continue; + } =20 - if (bit->time > pdi->last_read_time) - pdi->last_read_time =3D bit->time; + if (bit->time > pdi->last_read_time) + pdi->last_read_time =3D bit->time; =20 - t =3D t_alloc(); - memset(t, 0, sizeof(*t)); - t->bit =3D bit; + t =3D t_alloc(); + memset(t, 0, sizeof(*t)); + t->bit =3D bit; =20 - if (msp->first =3D=3D NULL) - msp->first =3D msp->last =3D t; - else { - msp->last->next =3D t; - msp->last =3D t; + if (msp->first =3D=3D NULL) + msp->first =3D msp->last =3D t; + else { + msp->last->next =3D t; + msp->last =3D t; + } + } else { + fprintf(stderr, "unsupported version %d\n", version); + continue; } - ndone++; bit =3D NULL; } --=20 2.51.0