From patchwork Sun Sep 11 18:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12973007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5402C54EE9 for ; Sun, 11 Sep 2022 18:18:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbiIKSSI (ORCPT ); Sun, 11 Sep 2022 14:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbiIKSSH (ORCPT ); Sun, 11 Sep 2022 14:18:07 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BBEA24979 for ; Sun, 11 Sep 2022 11:18:06 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id cc5so2170256wrb.6 for ; Sun, 11 Sep 2022 11:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/7Dk60TU8OMo0FEUlY5XbrNEevKq+ZNj0KLJElMVzrI=; b=BbgJ2xflBQZZRjAcMWsxagpsTyYmG2nKLOGOPvRiWpnFfO0kyJwQaVlnNDuc+fUlKK PuiP/5NgHOL0GRL9NTZo63l2bDz+PuU4qGlNHYgpDjR6m8hSixpq0YGHSP5eE+0I/1Gi jEnKDPi89y+/QYwaSHjcKhfvvatpppPAvM5tKmlFFqkCkf+C1fnxizS8wMTRxKgFxqRr wDPAREA+k96tBDKviuhoYFzf1cYxogZ7UTqfdyc75wBhDuPjXZ1lupkhP5QVho2k6In+ fcNGBvwIhfPt0BrQQdUR299UZgnsSItF4PprCvtlzc+D07O1mgeMY7/GO0uvxgWroNLl YQBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/7Dk60TU8OMo0FEUlY5XbrNEevKq+ZNj0KLJElMVzrI=; b=6rM8sA4DpGt2Do019JkGp/WqAuBFdhAu5+hcyfrkFZcpL669VByml+sKA1UjoiHK6t kfD0W98FgweT+4FQrsPUHqdgsZ3yGgV/n9H4OiiZm4GNUwH5Ljt6hd8naQjANe7SeHC8 zB2I/IMySZ2m8Nv8S2DQWTf6bH+mvCrFA0v1Oi1afP/yJ3c0i84+ZQHbDO5rBlYlRu0+ UjLlgrMMsG89ph6jnb3xSC2VRPGV0fgqonScbubI8MZiWl3ESjrEf5yItZL9gguCMKE9 mdE3JR5EnBZTeizYp23Gdj1bpClhdkO/WzbmDbeLhclIGoCLt+BM+7QUkgUelGJdz9d0 jByA== X-Gm-Message-State: ACgBeo325Nda1+94gFNM4YDZMv6s90Fgu4hZwHPzYiO+YjFYz6JgASc+ OTbzrZ+Uif5tk3Zj/hOHVC7ctrFwN8O9Gu83NTE= X-Google-Smtp-Source: AA6agR5hjZr2kJBd8f0UUJeaGgnLKiBe9kxA7flchu4MAlQM55MWYMkmDwAYkB9Bt3xfIuQL2wMgQw== X-Received: by 2002:adf:e4ca:0:b0:228:d8b7:48a7 with SMTP id v10-20020adfe4ca000000b00228d8b748a7mr12687607wrm.300.1662920284767; Sun, 11 Sep 2022 11:18:04 -0700 (PDT) Received: from m1max.access.network ([185.122.133.20]) by smtp.gmail.com with ESMTPSA id v2-20020adfe282000000b00228dff8d975sm5160056wri.109.2022.09.11.11.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 11:18:04 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 1/2] io_uring/fdinfo: get rid of unnecessary is_cqe32 variable Date: Sun, 11 Sep 2022 12:18:00 -0600 Message-Id: <20220911181801.22659-2-axboe@kernel.dk> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911181801.22659-1-axboe@kernel.dk> References: <20220911181801.22659-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org We already have the cq_shift, just use that to tell if we have doubly sized CQEs or not. While in there, cleanup the CQE32 vs normal CQE size printing. Signed-off-by: Jens Axboe --- io_uring/fdinfo.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c index b29e2d02216f..d341e73022b1 100644 --- a/io_uring/fdinfo.c +++ b/io_uring/fdinfo.c @@ -62,10 +62,9 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, unsigned int cq_shift = 0; unsigned int sq_entries, cq_entries; bool has_lock; - bool is_cqe32 = (ctx->flags & IORING_SETUP_CQE32); unsigned int i; - if (is_cqe32) + if (ctx->flags & IORING_SETUP_CQE32) cq_shift = 1; /* @@ -102,16 +101,13 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, unsigned int entry = i + cq_head; struct io_uring_cqe *cqe = &r->cqes[(entry & cq_mask) << cq_shift]; - if (!is_cqe32) { - seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x\n", + seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x", entry & cq_mask, cqe->user_data, cqe->res, cqe->flags); - } else { - seq_printf(m, "%5u: user_data:%llu, res:%d, flag:%x, " - "extra1:%llu, extra2:%llu\n", - entry & cq_mask, cqe->user_data, cqe->res, - cqe->flags, cqe->big_cqe[0], cqe->big_cqe[1]); - } + if (cq_shift) + seq_printf(m, ", extra1:%llu, extra2:%llu\n", + cqe->big_cqe[0], cqe->big_cqe[1]); + seq_printf(m, "\n"); } /* From patchwork Sun Sep 11 18:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12973008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF925C6FA83 for ; Sun, 11 Sep 2022 18:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbiIKSSJ (ORCPT ); Sun, 11 Sep 2022 14:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbiIKSSI (ORCPT ); Sun, 11 Sep 2022 14:18:08 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0C5024975 for ; Sun, 11 Sep 2022 11:18:07 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id o5so1611245wms.1 for ; Sun, 11 Sep 2022 11:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=39FBJTRng/1zJh/tOPCqg7gk9AHqZOjn0ySnL6ZiRuY=; b=H3PGcLwuC+8EsqHXEy0ink7RJtZ4+SiTBBYSN3E6mJq6DLUBMAUdAJ0MhXJ1dMwmYj VSycyCjepcFmbGzAfhOpGjEdMPZI2lrVBw8S8+pZQ1TV3sq16w4me+ITNCchhSvLhCRJ 3438exhIbgJO7ncyur5/33S3XNNri5ueZ/i2x6TXEkAJZZCfyFlhIXgdBjCrrHcRtxO3 KmNmTCepJ4N50S06PeMJ19iX3Zbdb1AA0rX02ePfqHqhJ8mcYH+IJxhyYWHUYJdSEt0t pscCX7Sbb5ejIzUUE8TcxLmo63GrtUcN1hFxBhbx+69wjCP9M3RWd/sUfX1WXcCYzngL M2aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=39FBJTRng/1zJh/tOPCqg7gk9AHqZOjn0ySnL6ZiRuY=; b=KEY9H9zf4DzR2K9/5W0z7W6ULz1JPzl3U8Ns1I/rFpEa242iDAqY2g/yjjgFif0D7j mS66mJ0gRGyAvN6X2cYoeTA3xBVea5tRj7oNxoiaTQNURBcB4yE9qxZnUN6XzGSUX1EF A4aKfrO+tcgzGQtXNspLJSXez9g3D+3RRMKNjc9xM4SMBMA8syDKFy33l/wTe9zwzh6Z 7w9guEwsEJ4/GXxObDPrU7qx63KBA3DuAgrYnIrAUKeGty0HolDtki9xsIQw6obv4YfX EYyPSHUCZJUluiIJYwJWTw9lexlLK/hEkL5PZK5I4TeApoAuFGW5WlFR10uigyx/Ctka w46A== X-Gm-Message-State: ACgBeo1imj0W9NCoOnCFcQsNmEJCywwBt9fSQA43PyhMfGarGR1/VkfN 7YMzj80oSOo4xHBrjd99RIjElxVviE02CHe3D9A= X-Google-Smtp-Source: AA6agR5J4UhLbHNBgpNJsvaSssOSlLM+kTpcIGZXhLPcUSly80818ipqzwKKgV/lsg1m9tKomfB+GA== X-Received: by 2002:a05:600c:348d:b0:3a6:b4e:ff6d with SMTP id a13-20020a05600c348d00b003a60b4eff6dmr11000599wmq.95.1662920285769; Sun, 11 Sep 2022 11:18:05 -0700 (PDT) Received: from m1max.access.network ([185.122.133.20]) by smtp.gmail.com with ESMTPSA id v2-20020adfe282000000b00228dff8d975sm5160056wri.109.2022.09.11.11.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 11:18:05 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/2] io_uring/fdinfo: fix sqe dumping for IORING_SETUP_SQE128 Date: Sun, 11 Sep 2022 12:18:01 -0600 Message-Id: <20220911181801.22659-3-axboe@kernel.dk> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220911181801.22659-1-axboe@kernel.dk> References: <20220911181801.22659-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org If we have doubly sized SQEs, then we need to shift the sq index by 1 to account for using two entries for a single request. The CQE dumping gets this right, but the SQE one does not. Improve the SQE dumping in general, the information dumped is pretty sparse and doesn't even cover the whole basic part of the SQE. Include information on the extended part of the SQE, if doubly sized SQEs are in use. A typical dump now looks like the following: [...] SQEs: 32 32: opcode:URING_CMD, fd:0, flags:1, off:3225964160, addr:0x0, rw_flags:0x0, buf_index:0 user_data:2721, e0:0x0, e1:0xffffb8041000, e2:0x100000000000, e3:0x5500, e4:0x7, e5:0x0, e6:0x0, e7:0x0 33: opcode:URING_CMD, fd:0, flags:1, off:3225964160, addr:0x0, rw_flags:0x0, buf_index:0 user_data:2722, e0:0x0, e1:0xffffb8043000, e2:0x100000000000, e3:0x5508, e4:0x7, e5:0x0, e6:0x0, e7:0x0 34: opcode:URING_CMD, fd:0, flags:1, off:3225964160, addr:0x0, rw_flags:0x0, buf_index:0 user_data:2723, e0:0x0, e1:0xffffb8045000, e2:0x100000000000, e3:0x5510, e4:0x7, e5:0x0, e6:0x0, e7:0x0 [...] Fixes: ebdeb7c01d02 ("io_uring: add support for 128-byte SQEs") Signed-off-by: Jens Axboe --- io_uring/fdinfo.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/io_uring/fdinfo.c b/io_uring/fdinfo.c index d341e73022b1..4eae088046d0 100644 --- a/io_uring/fdinfo.c +++ b/io_uring/fdinfo.c @@ -60,12 +60,15 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, unsigned int cq_head = READ_ONCE(r->cq.head); unsigned int cq_tail = READ_ONCE(r->cq.tail); unsigned int cq_shift = 0; + unsigned int sq_shift = 0; unsigned int sq_entries, cq_entries; bool has_lock; unsigned int i; if (ctx->flags & IORING_SETUP_CQE32) cq_shift = 1; + if (ctx->flags & IORING_SETUP_SQE128) + sq_shift = 1; /* * we may get imprecise sqe and cqe info if uring is actively running @@ -81,19 +84,36 @@ static __cold void __io_uring_show_fdinfo(struct io_ring_ctx *ctx, seq_printf(m, "CqHead:\t%u\n", cq_head); seq_printf(m, "CqTail:\t%u\n", cq_tail); seq_printf(m, "CachedCqTail:\t%u\n", ctx->cached_cq_tail); - seq_printf(m, "SQEs:\t%u\n", sq_tail - ctx->cached_sq_head); + seq_printf(m, "SQEs:\t%u\n", sq_tail - sq_head); sq_entries = min(sq_tail - sq_head, ctx->sq_entries); for (i = 0; i < sq_entries; i++) { unsigned int entry = i + sq_head; - unsigned int sq_idx = READ_ONCE(ctx->sq_array[entry & sq_mask]); struct io_uring_sqe *sqe; + unsigned int sq_idx; + sq_idx = READ_ONCE(ctx->sq_array[entry & sq_mask]); if (sq_idx > sq_mask) continue; - sqe = &ctx->sq_sqes[sq_idx]; - seq_printf(m, "%5u: opcode:%d, fd:%d, flags:%x, user_data:%llu\n", - sq_idx, sqe->opcode, sqe->fd, sqe->flags, - sqe->user_data); + sqe = &ctx->sq_sqes[sq_idx << 1]; + seq_printf(m, "%5u: opcode:%s, fd:%d, flags:%x, off:%llu, " + "addr:0x%llx, rw_flags:0x%x, buf_index:%d " + "user_data:%llu", + sq_idx, io_uring_get_opcode(sqe->opcode), sqe->fd, + sqe->flags, (unsigned long long) sqe->off, + (unsigned long long) sqe->addr, sqe->rw_flags, + sqe->buf_index, sqe->user_data); + if (sq_shift) { + u64 *sqeb = (void *) (sqe + 1); + int size = sizeof(struct io_uring_sqe) / sizeof(u64); + int j; + + for (j = 0; j < size; j++) { + seq_printf(m, ", e%d:0x%llx", j, + (unsigned long long) *sqeb); + sqeb++; + } + } + seq_printf(m, "\n"); } seq_printf(m, "CQEs:\t%u\n", cq_tail - cq_head); cq_entries = min(cq_tail - cq_head, ctx->cq_entries);