From patchwork Sat Nov 16 21:27:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877727 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E55AF196C9B for ; Sat, 16 Nov 2024 21:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792433; cv=none; b=S1LJnUcQbu7hPutuNGj3W6LEnI4DOAPHIFKHfL47HW9jRVIfft+1X/j2jU+pMiihuNDwvOVMCU0Vg20v++2nReiu4DLwm/itDNLkktCrpu974GEk5A4+OQxDVnJKd7aLx8jZOq6Bu6LEZEi/Bw082QwzLoW7WauYx+ffsFQnodo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792433; c=relaxed/simple; bh=ZpzgsozMuAk/ochldTowI7h7bTEw7JWBZOOahdDVlW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W8PkxBnU+sEJ5japghUlnJ2ArEBWTPDs6NMNau7ovR1hiGq2bXIRHFC25lbSz6SGOElTUlMVOYlOcmlpSvBtfiF1ZpNqyaipRBPk9nPlI5qhkEtJOMN0RzT909aSHaGXsCJWLF230Lt5jAU2vv694ru89pD/IY/MQPpuQloEN/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZC1InzS7; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZC1InzS7" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so6660445e9.3 for ; Sat, 16 Nov 2024 13:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792429; x=1732397229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wg+v/WEafR0hhxU0jQVQiPnsF9EILrTwW/uQsLAHZ2k=; b=ZC1InzS7PCGlcK5UW9jo2V54SQ8OV10R2Kr3S+/g67n5YniFJytj0pH8nx0rPH7CTA vy7euZnQfc+8ks90QGwwvCjmC3Me3d8LtFmbMmfUq6VGYlOk12cbUQuj9jPPAhMBT8pj ne9iSpGJywfBjXHsBdFEz3e9+EUDArFDwok7yjePEDUdZqRWtKavogkzjGzWD12xHeZB yWccyr6vmedWbeO4TzZOLol1di4CiL07IpnKmPoS4RJjjkw3FMBtW61RcmxZvxnbCNvv p/k2WjEnXDA5syGy3+yDdY1c3V1+DCGJWG4U8+j4uzvuFbRjMDfrDNNK+CbmJJEAStga CCqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792429; x=1732397229; 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:message-id:reply-to; bh=Wg+v/WEafR0hhxU0jQVQiPnsF9EILrTwW/uQsLAHZ2k=; b=qooEAvYWbWZlZdN9WIJvCFt0QbC8QZxQgqzRBzdL1Q/PD+UoP7zkNRjNngBFfo4TYY G9AtXOGizjA+uUJgPFNOoEYZ0iS6RAxrNtFLF63kKGqJCmQ4FZciliKyFRRTvvgTKwuU 1G09WxYjb0dDxpGjmpy4N0qGU+XMcBQ1YMat0oiI+n9PY/utSaDVJPhiTIF5gnU6CHXl GHGGtTsqRdmimFTKLeiTMgUIA7lQDHdakOR+G+y9+LKGTV8qBCE6wYSB6sKCeneuJp0p r6X98yV86iqs7RRIKckaHQAYOF+zsZsk0j4UDsr3S9nmy4IdJCI1pIgRQUQYsvXmJvAG 4ywA== X-Gm-Message-State: AOJu0YxqFuA3d0+CMFR8zwhsJeDuhK+glaynjOGfjlILgRHiCrY8WT1+ eBt9zKnVqjxu0bHLJQUgGnUjjdcSEXm4vkVc7Dp0boKpoeUXMrMgJMRsFQ== X-Google-Smtp-Source: AGHT+IHtvy1HqyUf3Kg1RThApoE+yK2cE2VoE9L5hkGfYTCe+se5M49Y+gMpVjoWSapsHUd48xp1aA== X-Received: by 2002:a05:600c:3b03:b0:431:6083:cd2a with SMTP id 5b1f17b1804b1-432df74ba87mr67477105e9.15.1731792429334; Sat, 16 Nov 2024 13:27:09 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:08 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 1/8] test/reg-wait: fix test_regions Date: Sat, 16 Nov 2024 21:27:41 +0000 Message-ID: <13bd6e7b30bdaed0d11bdfda409e5369ab8005ec.1731792294.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Regions for CQ wait arguments are registered to disabled rings, and test_try_register_region() doesn't do it right. While at it kill the extra argument as it doesn't do anything useful. Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index aef4546..eef10e0 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -222,7 +222,7 @@ err: } static int test_try_register_region(struct io_uring_mem_region_reg *pr, - bool disabled, bool reenable) + bool disabled) { struct io_uring ring; int flags = 0; @@ -237,15 +237,16 @@ static int test_try_register_region(struct io_uring_mem_region_reg *pr, return 1; } - if (reenable) { + ret = io_uring_register_region(&ring, pr); + if (ret) + goto err; + + if (disabled) { ret = io_uring_enable_rings(&ring); - if (ret) { + if (ret) fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); - return 1; - } } - - ret = io_uring_register_region(&ring, pr); +err: io_uring_queue_exit(&ring); return ret; } @@ -270,28 +271,22 @@ static int test_regions(void) mr.region_uptr = (__u64)(unsigned long)&rd; mr.flags = IORING_MEM_REGION_REG_WAIT_ARG; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (ret == -EINVAL) return T_EXIT_SKIP; if (ret) { - fprintf(stderr, "test_try_register_region(true, false) fail %i\n", ret); - return T_EXIT_FAIL; - } - - ret = test_try_register_region(&mr, false, false); - if (ret != -EINVAL) { - fprintf(stderr, "test_try_register_region(false, false) fail %i\n", ret); + fprintf(stderr, "region: register normal fail %i\n", ret); return T_EXIT_FAIL; } - ret = test_try_register_region(&mr, true, true); + ret = test_try_register_region(&mr, false); if (ret != -EINVAL) { - fprintf(stderr, "test_try_register_region(true, true) fail %i\n", ret); + fprintf(stderr, "region: register with !R_DISABLED fail %i\n", ret); return T_EXIT_FAIL; } rd.size = 4096 * 4; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (ret) { fprintf(stderr, "test_try_register_region() 16KB fail %i\n", ret); return T_EXIT_FAIL; @@ -299,7 +294,7 @@ static int test_regions(void) rd.size = 4096; rd.user_addr = 0; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (ret != -EFAULT) { fprintf(stderr, "test_try_register_region() null uptr fail %i\n", ret); return T_EXIT_FAIL; @@ -307,7 +302,7 @@ static int test_regions(void) rd.user_addr = (__u64)(unsigned long)buffer; rd.flags = 0; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (!ret) { fprintf(stderr, "test_try_register_region() kernel alloc with uptr fail %i\n", ret); return T_EXIT_FAIL; @@ -315,7 +310,7 @@ static int test_regions(void) rd.flags = IORING_MEM_REGION_TYPE_USER; rd.size = 0; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (!ret) { fprintf(stderr, "test_try_register_region() 0-size fail %i\n", ret); return T_EXIT_FAIL; @@ -323,7 +318,7 @@ static int test_regions(void) rd.size = 4096; mr.region_uptr = 0; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (!ret) { fprintf(stderr, "test_try_register_region() NULL region %i\n", ret); return T_EXIT_FAIL; @@ -331,14 +326,14 @@ static int test_regions(void) mr.region_uptr = (__u64)(unsigned long)&rd; rd.user_addr += 16; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (!ret) { fprintf(stderr, "test_try_register_region() misaligned region %i\n", ret); return T_EXIT_FAIL; } rd.user_addr = 0x1000; - ret = test_try_register_region(&mr, true, false); + ret = test_try_register_region(&mr, true); if (!ret) { fprintf(stderr, "test_try_register_region() bogus uptr %i\n", ret); return T_EXIT_FAIL; From patchwork Sat Nov 16 21:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877728 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91FF4199951 for ; Sat, 16 Nov 2024 21:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792434; cv=none; b=F5u4mMQM8nDW9emKQVcMDPs1R2qFkJNxmNqE4JBl9eOTLWXP/N0sP+N9TDFS/jaTYrIdQK8AT0K0YyboLOt0V11E3ZJK3FltzC3C6hG8Y/SnsT4Ex41hFi2J83l9XZqFOQeYIP6mQ9bHNU+5e53NaxM6V6cUj7THXE9bEziiEDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792434; c=relaxed/simple; bh=EBjtApE+0ml2VVg5tZc0gb1Jm+KXzRBdLxw6ViaGhuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bhhoN3o9Ei91TdYpXTnlBJ+khiCQXPLa2ofywe9HfmPVBaZzhYojKWck9e7od2Dd0nPoNbLsXJCE9TgrhoHfnFR9+6510+3xGJV7Xvgu3f1xtuOsX7HYZeZ7fuoXTGPAOzoxehAmALFhyqNvZVPtnp5/dAgVF1gOZ0FCtzqflWM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pk3Ex+aL; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pk3Ex+aL" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-431616c23b5so16691355e9.0 for ; Sat, 16 Nov 2024 13:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792430; x=1732397230; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DOUfpRV7H9ek215nIoavPI9l7/2gX9TLCS2UpNr7zAc=; b=Pk3Ex+aLRc3laZBvu3/CedYXlYJNp2LMOdBSwlK3O92ySP5DtfN90MeRyLdq7RvcCH qCgi96Qb9KcDnad1YUyV6MAWwQIKnXLec9CttvbsLu6kNc724HSpZ+W8/cn+YPk6cheE zXZaMGPPmgtiZmzDp423r1anDIMNFuZxOn0HLxGgC1JUoQ1sEWsIwKHzsdRD1hgTcwN6 C7DPCqJbZ9R1bcpHdBRHja6eMDMCCgUqhdN80NaLTdO+qzfl7c/eOykIM1fMip06keYJ ME+lD0jwSj1cIhWBbTWYjULjFbCYWAyei1y9MCb/XAXWHbfKNzoSoN0UU/EaDWYeLp3u 200g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792430; x=1732397230; 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:message-id:reply-to; bh=DOUfpRV7H9ek215nIoavPI9l7/2gX9TLCS2UpNr7zAc=; b=Ol6FQFOyIRaAfeIjP0NMf5eSB/Af28/I/QzpOQf4D87S6k44IRJf4/qxJx1uP/pnvG G5GxL1P2wVIhfYMWPWBo42nuxM1YfeF2rxeoUSa8V3rGebGmx466bVDHyWFCeJ0/sZhb gB/bx0X/KWL62raWpsWMWLq5Yqz8fte5bpk4NkEuB/xCjnLufqRJuZ8CmpsjmSG/by63 aj6aPcVU6gnP6vRbijafMEZlvXlvCbpCzL3wO/jjkBFxtSLNMwEv5ygIo/BMhDCKjg4p Ll4yKwMlCEkqkxd/AHlg4OVX9i488MPT/fmGaYiVrlVCrhnQEmR7gUT2msIXHu+2XzUs o+IA== X-Gm-Message-State: AOJu0Yy3pPcd6Rpb765ZGK7kohgLXR04/ws1hKqOXmddcfb3pC1v7Dpd v5Xa1RV0z9aJ4oJJxcpDEv5q+1OiUzuQjX4ygBZ7E8DSLG5cM/O4LQQJwA== X-Google-Smtp-Source: AGHT+IF0z6m87URy1Xd5VUPGNw2SH/FqyT/guSTpCAv9RrRVk+tAPzM8nTfmQyXkeaZo9Rdji5oz+w== X-Received: by 2002:a05:600c:1f88:b0:426:5e32:4857 with SMTP id 5b1f17b1804b1-432def7e5e8mr60412015e9.0.1731792429953; Sat, 16 Nov 2024 13:27:09 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:09 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 2/8] test/reg-wait: pass right timeout indexes Date: Sat, 16 Nov 2024 21:27:42 +0000 Message-ID: <4a64eff75fbdd1fc93e1683f5b8b0f58794e27fe.1731792294.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index eef10e0..ec90019 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -72,10 +72,11 @@ static int test_offsets(struct io_uring *ring) rw = reg + max_index; memset(rw, 0, sizeof(*rw)); + rw->flags = IORING_REG_WAIT_TS; rw->ts.tv_sec = 0; rw->ts.tv_nsec = 1000; - ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, 0); + ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index); if (ret != -EFAULT) { fprintf(stderr, "max+1 index failed: %d\n", ret); return T_EXIT_FAIL; From patchwork Sat Nov 16 21:27:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877729 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5485199951 for ; Sat, 16 Nov 2024 21:27:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792436; cv=none; b=d0AYd37OCXvpK1BuKKP+hx3xnfrgYBrfi+l5GewSa3z5uVEOMcsvJYrTFo4Pl/8abG6WvRCZI7upRkouUs4IHqUBNWEWMoFMFNYfxCd/jn7UePk+fgyOcWld1e8MuLceqzmJT066+iFCMlkXHY8x8u186pDgVxcU7cQIIP7TIEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792436; c=relaxed/simple; bh=yjB4gJwDQul0jz8AIPThX3h4EGCwd+BWB09OydCbPOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vxh+YUBHWMSDxFNg14hheeIt2qhrZylH1e5gpS3z7FMd+GUDvDcdmDZeQrzquQtpwQiWvS2ojwyltLULRedNaoBCAMTbpCpG4uc7r7S+jnaubv2XT7Y3f5FI+BgGjlg/AJDsQsEinJlLhXkGo7CjvKQNjV2xWOWzCdGKuNaMooU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FPB56OOc; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FPB56OOc" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-432d86a3085so7515135e9.2 for ; Sat, 16 Nov 2024 13:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792431; x=1732397231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mh8I21kvfztjBG+u8dEs8RjQmxtH6iAHnm7ZZZMg+q4=; b=FPB56OOcWWIMoS06eUMZZTupKQpVwCp7n301JueJjH5TxbUfFa1tJM0zodLiJs+AD4 7C/Ojg6IasF66+S4VzIJ9S3Nr27Qa5vJaSWNFsSc03WCwlVDP4/kn9oX/cleFgpWCQvv km3TANIb/119qLdsmkb4rAQ0+Z+r+96vo+5KS36fRRLXQtUOnwpd3VRpCVaKXzYVMBMH oRNXtRsATGtn+1KxWbfaKbgFKErCIVCpBZwU15oPYpSq98OGlayr93jLt3qbusaMpLU2 89K+INA6RS24QjthQ4KMM303UoCOrU31TUBA63mUzvQ2NpOs4TAdjbwSIbd5B2t7ZAKF onfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792431; x=1732397231; 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:message-id:reply-to; bh=mh8I21kvfztjBG+u8dEs8RjQmxtH6iAHnm7ZZZMg+q4=; b=qFgZVG5Wl6yrGo1h/WKeDGcIxN0psG29i1WlSIdk3sFKo9VZMWgnl0+C3aIaSu/hcp DZuXX19koamq8skHq4fHuyeSNshFsofLk7rKd3U+H9aAmCYvz+Og3fA14SBmKs46vU/I NNIFSH3O84ZU2GbjrI14i6G/SBnYdM34niwau31HGnW7HMFyvEasNvBtmj0ouMn7OxIU kXhHvMj7egHYUkCKT4jvAd4/azDdgB1czhGP13tamsjCPSLKXG+90V6jlXw42Vh63/IA c5fvlj0fv+9FAySvmLQv0j8OFSuc6z2tTgjJj0XcLFi12JnD/+hRN1xz1+LAvGjg/qUR WuaQ== X-Gm-Message-State: AOJu0YzoA4O4busnnhUTg4MSXHqTCsTL5Zo+cSqW1GbjTSuOjOjl+UJa +MSLrninlKTy4RU73r/18KR+v8YNNrHN+E4IV22cwKkt1uUTNktOe3hBiw== X-Google-Smtp-Source: AGHT+IFIxT2h3vien8C2Reg8jIdgAZps3rYx8+8QfTVGhaurmoVyHn0BkM16ZNGhD7Hptn9BGU2iOA== X-Received: by 2002:a05:600c:3c9a:b0:431:5465:807b with SMTP id 5b1f17b1804b1-432df793de8mr54377595e9.32.1731792431309; Sat, 16 Nov 2024 13:27:11 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:10 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 3/8] test/reg-wait: use queried page_size Date: Sat, 16 Nov 2024 21:27:43 +0000 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index ec90019..6cf47bf 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -101,7 +101,7 @@ static int test_offsets(struct io_uring *ring) return T_EXIT_FAIL; } - offset = 4096 - sizeof(long); + offset = page_size - sizeof(long); rw = (void *)reg + offset; memset(rw, 0, sizeof(*rw)); rw->flags = IORING_REG_WAIT_TS; @@ -259,14 +259,14 @@ static int test_regions(void) void *buffer; int ret; - buffer = aligned_alloc(4096, 4096 * 4); + buffer = aligned_alloc(page_size, page_size * 4); if (!buffer) { fprintf(stderr, "allocation failed\n"); return T_EXIT_FAIL; } rd.user_addr = (__u64)(unsigned long)buffer; - rd.size = 4096; + rd.size = page_size; rd.flags = IORING_MEM_REGION_TYPE_USER; mr.region_uptr = (__u64)(unsigned long)&rd; @@ -286,13 +286,13 @@ static int test_regions(void) return T_EXIT_FAIL; } - rd.size = 4096 * 4; + rd.size = page_size * 4; ret = test_try_register_region(&mr, true); if (ret) { fprintf(stderr, "test_try_register_region() 16KB fail %i\n", ret); return T_EXIT_FAIL; } - rd.size = 4096; + rd.size = page_size; rd.user_addr = 0; ret = test_try_register_region(&mr, true); @@ -316,7 +316,7 @@ static int test_regions(void) fprintf(stderr, "test_try_register_region() 0-size fail %i\n", ret); return T_EXIT_FAIL; } - rd.size = 4096; + rd.size = page_size; mr.region_uptr = 0; ret = test_try_register_region(&mr, true); From patchwork Sat Nov 16 21:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877730 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0C1B19ABCB for ; Sat, 16 Nov 2024 21:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792436; cv=none; b=blbdV+e6aNFUYu0Rb3HPIlUvMmMIpsTUrtUivlb0yn9ujqnDAoX6polLvh6NOK6b9GXEmsu/YT/lbppRLNYpI0/RYUzpMK/cod4h21nMYa1fM+blMUJe+Rzjy7XfeOSwzROrhrDmxdHVbhZAZzjcN2uK1qgPgJ56Y5zaw025aZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792436; c=relaxed/simple; bh=0oquaQSJronYWIIv+ITe/LbMsasUYJPeto+6SMQsExA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajT8gvHxLzz+R2I9OjDcg4qDihdvvZTm4GYilT/RaAg6Lf9pxMq+FFA3T23UKL6KVw9AWpbHYH/xmjvwnuB5W7Xps/O+hC0D2gyOpyk53MjhRf9+dBbQKfN/iXAYxgaD9xYnNUwWv9TFR80FRdCMuABJi9gaZsjay89JEXrJ6UU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nW4tmSfe; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nW4tmSfe" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4315f24a6bbso24046485e9.1 for ; Sat, 16 Nov 2024 13:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792433; x=1732397233; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Eh8S1ft0d/EV8XH2TSFyBR9s0X7trD21Wxf8HXk8GL0=; b=nW4tmSfejr5NdT+lUjM/MZCrakcsSWfFv4tjAaF6dFtj6OwO2eYuVhfKbn0FzzkK4b 8YMjQpJ2Avhn/MblDn3766BqhP7ooZqJA7J9ozzt/zW+LMEIrudVgYKV7lGnsMzE/aIq IeKSBRO2eBflBGKACCWT+6L7xGk6WcrQbNgWzzK8MycCU/8y38OBWZFo0N50+gcv6JTp N00K2tHhwtffL3qcOyZMcdNPD819JhdGNKA61ORGoR5hbUaBr7izN7jps5g8JrOJUASC 6d/tSns77qzziKV49XSLunI3tb8lnutgWyFnishxIhNQMzGbS+FgbDMXaNoA2rSd/Hd0 sXjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792433; x=1732397233; 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:message-id:reply-to; bh=Eh8S1ft0d/EV8XH2TSFyBR9s0X7trD21Wxf8HXk8GL0=; b=LaNOU5xVqs5e6rclXXi7TVuYFTjHfXGM9xdqSEDhnyhK7vtgY815b6jlxYENYeyix3 Jco9zeYV8jQK2GYlveuparFfreI72Mht8sP41AQUNd11IbM1JC8XmsSeiaCRwk+YzHnv 3N/GWw3ODOt814yvNf3lC4O8vYX5yUL3b2PpmLF2H4CPd1EtEU78u+eSE7nXjthB5reg dycDyTw0w9J59vSYl0hy5MnqFuXVwAVEMr3Yh4kSgfLAgnwzNRuzpzorolnHn1cIn20X 5Qt6luWEzFjmGXJfcXiPNXJGvAM76BG82GFY+CL3TrlVBX8a30flZeoX15GYtc7Mu7dI Rfcg== X-Gm-Message-State: AOJu0Yy/n59nHmg2yoGNlL4kWVkTAI5EsnzhqUlaAtpmHvnrjuBCfu5h BaySFI48H3pKqTVT+JtE/xo76JrFBnJx4bBG6nW2viwbJ93lyqRBysctvQ== X-Google-Smtp-Source: AGHT+IEF66p13O7uX6kntjHoqnD9DDnSKhCnzsqXH8UgNOulvn5QjB5WjfHgl/Bb5cnEJ4RLN/B2Yw== X-Received: by 2002:a05:600c:1e11:b0:431:52c4:1069 with SMTP id 5b1f17b1804b1-432df72a7ffmr63948325e9.8.1731792432711; Sat, 16 Nov 2024 13:27:12 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:11 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 4/8] test/reg-wait: skip when R_DISABLED is not supported Date: Sat, 16 Nov 2024 21:27:44 +0000 Message-ID: <0552baa20df1d23eb05f585cd45ed75ce2c7e277.1731792294.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index 6cf47bf..c4e5863 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -234,8 +234,9 @@ static int test_try_register_region(struct io_uring_mem_region_reg *pr, ret = io_uring_queue_init(8, &ring, flags); if (ret) { - fprintf(stderr, "ring setup failed: %d\n", ret); - return 1; + if (ret != -EINVAL) + fprintf(stderr, "ring setup failed: %d\n", ret); + return ret; } ret = io_uring_register_region(&ring, pr); From patchwork Sat Nov 16 21:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877731 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B397519D096 for ; Sat, 16 Nov 2024 21:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792437; cv=none; b=M/wsTvYAEFszOwA1lpQCV7kO8caTtSgBnqFPf2qk7x/TIWV4jpE9qnngSB3UuCdcOwPC3kvYEpO/Ou3imMvLuuM64SJIgyzOuXRnreUuAwXIx6XfJMDNi9q4vxorc80KkRN/Khdu0CqBGMW1YWf83acUd/FqpPeR/pfEpIUQJgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792437; c=relaxed/simple; bh=OU7dryaE8SkeouRhD+3wmcD0a8lTfRG4iCSTyA7gINo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H0S6yJQtliiWraRXOVM3nfC6OdZeAcTQWScV4PCKlTU21p9LqaIX7cmBy10YAUyOzSqxXg/JlxdurkipvtrquNYETQnafQq7frVjRXbznuPUxtsCyy79+7Gt5k6c1xEZBgZclNHbBCde59f/PFZ0iedzT7NUbUVZ10K5MlIwOZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OSCb6ycT; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OSCb6ycT" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-431616c23b5so16691465e9.0 for ; Sat, 16 Nov 2024 13:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792434; x=1732397234; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JNIFDJ60IAyJpMisfwJXe/VMtMZ+0miT/Bgpj+F9MiE=; b=OSCb6ycT0FIskw6ymowBtdHtQWOfNIn7bw8YdV8HPfRWNSXAtsNvW9qsLa4NihzdgP SQdMv1QgY97TfKUZWxY+5avAkKGzkX69hpp+BCNX6YKETwssZKxuRT5Uphbph2G2vRmk PYw0CEt2WfSd03NbB+VW/wYw0d9plbnoIPuHwatvuBO35IdJ3Zb6phWxr2Ek+ePl6jaA Sj8Vh8dKX2SHo2+tlxMAyyuZCDRpFg3zJSEFxqzYZ9J80pZ4aGY3zAbAmg19Vk/nMaoA vrkoSTdshnK2rieBbbsB/dqK9sJI5n7d8I5++BydxC34NrfxhJ0+Zdrqj2Ol1Rtd/LhD VPrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792434; x=1732397234; 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:message-id:reply-to; bh=JNIFDJ60IAyJpMisfwJXe/VMtMZ+0miT/Bgpj+F9MiE=; b=HldtwVZQDb3ZQjqHJCvcOjfZJZ2YsBF1sNTN4kqeZZAEIrtnSp3KDM3WWInpN9d0CD aAKZ/GU8XifWxEJn5/g5ysS1hJ0cVr+gfLbMwgL8+SXMc3SoXNgeN//v4Xtm59aWOcEV l9CmV2gkgp5Ireqa+Dta3qWQd3IbQK8yJAv7c99YMXQF2w/BDR38FMilidSI5wfRJynR LiaVhTS8tqz0X90R/09pny9aOYGqeHmvyD4YpJTAQP975UGjqtWTtj1zoxjoKXQu0N+I lQvATYkhL0vSCQYf7/4gtpSMJ34vn7avrglWnJHR7xVa2rtwvZxOd8vuXI0hzsGw2jcg rtGA== X-Gm-Message-State: AOJu0YxsTxQ+Hv1wFkkmSjb93Uw58Z9P8q97CAXcLAeKq4TUJ8GvCAkI l3CCkKtR9pHhK/hcWmZHPOQMV652DOXifBB1/IJoTup/HtKmVbWebP9Gjw== X-Google-Smtp-Source: AGHT+IELAHILVld3gHVeQgnVEPANfFQ0GImclvNSjbiczLorHv9mkEoeVje1k6Y6l7wdV/mSNV9w0A== X-Received: by 2002:a05:600c:3c9e:b0:431:52da:9d89 with SMTP id 5b1f17b1804b1-432defc8b2bmr66395155e9.1.1731792433760; Sat, 16 Nov 2024 13:27:13 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:13 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 5/8] test/reg-wait: dedup regwait init Date: Sat, 16 Nov 2024 21:27:45 +0000 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index c4e5863..10ab3a2 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -15,6 +15,12 @@ #include "test.h" #include "../src/syscall.h" +static const struct io_uring_reg_wait brief_wait = { + .flags = IORING_REG_WAIT_TS, + .ts.tv_sec = 0, + .ts.tv_nsec = 1000, +}; + static int test_wait_reg_offset(struct io_uring *ring, unsigned wait_nr, unsigned long offset) { @@ -71,11 +77,7 @@ static int test_offsets(struct io_uring *ring) int ret; rw = reg + max_index; - memset(rw, 0, sizeof(*rw)); - rw->flags = IORING_REG_WAIT_TS; - rw->ts.tv_sec = 0; - rw->ts.tv_nsec = 1000; - + memcpy(rw, &brief_wait, sizeof(brief_wait)); ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index); if (ret != -EFAULT) { fprintf(stderr, "max+1 index failed: %d\n", ret); @@ -83,11 +85,7 @@ static int test_offsets(struct io_uring *ring) } rw = reg + max_index - 1; - memset(rw, 0, sizeof(*rw)); - rw->flags = IORING_REG_WAIT_TS; - rw->ts.tv_sec = 0; - rw->ts.tv_nsec = 1000; - + memcpy(rw, &brief_wait, sizeof(brief_wait)); ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index - 1); if (ret != -ETIME) { fprintf(stderr, "last index failed: %d\n", ret); @@ -103,11 +101,7 @@ static int test_offsets(struct io_uring *ring) offset = page_size - sizeof(long); rw = (void *)reg + offset; - memset(rw, 0, sizeof(*rw)); - rw->flags = IORING_REG_WAIT_TS; - rw->ts.tv_sec = 0; - rw->ts.tv_nsec = 1000; - + memcpy(rw, &brief_wait, sizeof(brief_wait)); ret = test_wait_reg_offset(ring, 1, offset); if (ret != -EFAULT) { fprintf(stderr, "OOB offset failed: %d\n", ret); @@ -116,11 +110,7 @@ static int test_offsets(struct io_uring *ring) offset = 1; rw = (void *)reg + offset; - memset(rw, 0, sizeof(*rw)); - rw->flags = IORING_REG_WAIT_TS; - rw->ts.tv_sec = 0; - rw->ts.tv_nsec = 1000; - + memcpy(rw, &brief_wait, sizeof(brief_wait)); /* undefined behaviour, check the kernel doesn't crash */ (void)test_wait_reg_offset(ring, 1, offset); From patchwork Sat Nov 16 21:27:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877732 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A666199951 for ; Sat, 16 Nov 2024 21:27:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792438; cv=none; b=IMaRLiDPdBBwxXCkgmV2bDrhZvHt8ffyQlClBIjzXRxZUpaP91hbEXPEhdvIOAZA9ireQufjj4u30I6ZNHXAYp2+sq6XWIYSZPvDpaBqTPLZG4LSbO4WHfmPLt5o+DqJgYWifwjFaueyzkI/Pb79hP87OiN+YT1t/0yZJwqVn8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792438; c=relaxed/simple; bh=6oCskojPouHFBRFauRD/kfM65ctb7KylFZnjAcIfZDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d6xVFMhH2uwiPWJ12EOBP0dkc0kFax4FVBbBlQTo996JXyGLAHbSInVrLPq7tbxQkfHTD319lTY5mqM/dIyo/uI7yOQDGw37c5CrJqLT0+Sun4qB2/PiKUIppgEQxlyOBD35aRceyMsHOySshmN1WXipcl7X22pMiT5Vqy2k53I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RbQnkqpm; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RbQnkqpm" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43159c9f617so23991105e9.2 for ; Sat, 16 Nov 2024 13:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792435; x=1732397235; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=40pR5Lk5LlWwR03ynPbwgMitElQCwkmpfLSghqHxoGc=; b=RbQnkqpmt+6jpCKeV8PgbY/bL5S7FcMLw6xo2NoJ0ExKNlOGWtF4UAh+tpin2DEXHN zpye11pz9EVfy3+zeahLQm4LtqBRcGXlH4RcOv2hMZjl/NDHTHVL2sbJlTn7G0KmekDl vctrpWWnspE/I7z572ju48/W8b7yyJmjKphQYSztuwj6mTV62YC2MWtAeGxcvkDEH/6Z /FyY2s1mGj1nNI65jm04YiUjlx5RwZf/0l/yfzlGvqA5ekAaHO5qyR5/B4XedPhib7lz xo1zdIGqjTMdF+l1EbZ2NgT8XRPbsMhyBE7oOCBfO04LViSmzYP3WWR1S4HUTax4yH1H BtXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792435; x=1732397235; 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:message-id:reply-to; bh=40pR5Lk5LlWwR03ynPbwgMitElQCwkmpfLSghqHxoGc=; b=LICqMBgJVv7QvomJo4zir4HaCCxHUKISu2pyeXYbYmt7YN5ITWhtL/yuCecLYW13hO CiD7ptIdarDy2GYvvchRHETBCuN79QCFNuHgrEVVhjMgl4t3Ru4IBl75atwQLkkbBEvv fmWpfVGpqlNdRqFHdaEm1k0S9X5Lka7ipyXW6Isy/gPbDXKSzX6+ZpyqjVAtAHJBuBZx 1mWBcXfp2IJQ4KPG4POOsH+x+8V7iRT0NbhybOHxeMvH6Sx+4aYN35dPowDnAjr/qxy2 a7xjkqZNjs/UaZKP5YbtjN3JdG6mAZNFc1EZchcj5XrYwys/IiWYwRrn6aBcJmAzwOBI Arfw== X-Gm-Message-State: AOJu0YzsYyquXAxpsz8gPCbkfotUb8cohgSSIyRLi5UqU0Zk8ZF0dyvp lqzCECYnC7FXSbcdxFDJYyBPXKx5zA39U29uMGg28Z7rgiVvneF2IbLWKg== X-Google-Smtp-Source: AGHT+IFUQDcmQ6FnNbiOFbch06uSSeEhc4P2iKk97XQIlu9yE9bQZS28+XDTjRKD8kegVuubxnC8ww== X-Received: by 2002:a05:600c:4e12:b0:431:5d4f:73b9 with SMTP id 5b1f17b1804b1-432df77c7ccmr55209615e9.26.1731792435049; Sat, 16 Nov 2024 13:27:15 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:14 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 6/8] test/reg-wait: parameterise test_offsets Date: Sat, 16 Nov 2024 21:27:46 +0000 Message-ID: <939b7af82e46d7e857aec12cfaa74fbd42fab5a2.1731792294.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index 10ab3a2..ffe4c1d 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -68,23 +68,27 @@ static int test_invalid_sig(struct io_uring *ring) return T_EXIT_PASS; } -static int test_offsets(struct io_uring *ring) +static int test_offsets(struct io_uring *ring, struct io_uring_reg_wait *base, + size_t size, bool overallocated) { struct io_uring_cqe *cqe; - int max_index = page_size / sizeof(struct io_uring_reg_wait); + int max_index = size / sizeof(struct io_uring_reg_wait); struct io_uring_reg_wait *rw; unsigned long offset; + int copy_size; int ret; - rw = reg + max_index; - memcpy(rw, &brief_wait, sizeof(brief_wait)); + if (overallocated) { + rw = base + max_index; + memcpy(rw, &brief_wait, sizeof(brief_wait)); + } ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index); if (ret != -EFAULT) { fprintf(stderr, "max+1 index failed: %d\n", ret); return T_EXIT_FAIL; } - rw = reg + max_index - 1; + rw = base + max_index - 1; memcpy(rw, &brief_wait, sizeof(brief_wait)); ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index - 1); if (ret != -ETIME) { @@ -100,8 +104,10 @@ static int test_offsets(struct io_uring *ring) } offset = page_size - sizeof(long); - rw = (void *)reg + offset; - memcpy(rw, &brief_wait, sizeof(brief_wait)); + rw = (void *)base + offset; + copy_size = overallocated ? sizeof(brief_wait) : sizeof(long); + memcpy(rw, &brief_wait, copy_size); + ret = test_wait_reg_offset(ring, 1, offset); if (ret != -EFAULT) { fprintf(stderr, "OOB offset failed: %d\n", ret); @@ -109,7 +115,7 @@ static int test_offsets(struct io_uring *ring) } offset = 1; - rw = (void *)reg + offset; + rw = (void *)base + offset; memcpy(rw, &brief_wait, sizeof(brief_wait)); /* undefined behaviour, check the kernel doesn't crash */ (void)test_wait_reg_offset(ring, 1, offset); @@ -201,7 +207,7 @@ static int test_wait_arg(void) goto err; } - ret = test_offsets(&ring); + ret = test_offsets(&ring, buffer, page_size, true); if (ret == T_EXIT_FAIL) { fprintf(stderr, "test_offsets failed\n"); goto err; From patchwork Sat Nov 16 21:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877733 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 015B519D096 for ; Sat, 16 Nov 2024 21:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792439; cv=none; b=TNljGVYTXlPjLzxpe8vQ/KiY+HXTC/eR5XZGny0jmz6fz89kE9n56e0fHQQCjP2gGeBtplg/WTufOUBLoNvu0RUlVIy93UGmO2jcRfGrayAJCbSzPSqWPvsn6e+8fYKsAHo8kXqrV0IelAQjCaH2AqmHY7cFeMkEtcwraGZDzls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792439; c=relaxed/simple; bh=/U7llu4aV2Z6u48nn6cMMkQl3HL89ZiKItVcEZmCaQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FCSq/a3KwW4c1HxjpiwWkL9cgGCb8B71n7DQEQZO5Ro/RXaibmgKo7z/vpiU+t6pZbZ6wUPA46/2NtGvCbJOFsKoM68pRd3tTItcakr1O78q2H/bcBsWpSQwTfNyM/lh1Bn2DgDYs0JwCqDlpIflwVavcu5xjgIRV9+PkV05P6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZvalBXIO; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZvalBXIO" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-43167ff0f91so15962155e9.1 for ; Sat, 16 Nov 2024 13:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792436; x=1732397236; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ycXKQjejvoZ7J/mfxsd4mU/r13p1EMUuROr4/t67Bsk=; b=ZvalBXIOr3WP8kTlTOnvkMIm8Sq2tnB6iYuu/j3BwwM160Y+7IBzbY15jeOnUMimQw 9PuLCnHKbipmAsRH5ukZ0Tf7lYMITRHllNiHjp49qU4D8bPA4OoROTxuNYMyeRNeT24O 2hBllw+JFdnW63PysUiCsarusMQ3DixUY6YBY2XG/vCi4Qj9J8BDcQ+gHX6oN+9ztrNK rm/dA6hwg6rmawnHh+beHSrmt4ZnMh0atdrLF/Fw8p1d/hGPCZ47GN/3nBiVYMdV5ea3 Fs9inCERlVYVeyVeI/2AqcBpITBuWBS3lOpb/n3FS4smPzdlvSf9mtY8CZxQOQTg4nnB A3hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792436; x=1732397236; 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:message-id:reply-to; bh=ycXKQjejvoZ7J/mfxsd4mU/r13p1EMUuROr4/t67Bsk=; b=oUIn2iywKrizQM1O8bmjspRuBauvrIzQWmHxIgltjj0eukLrm+W5NRQNQdwVL9JpKo 1uZtSnRTi6494WbNiciSn9ty+/aI3O8/IDTEsadTHMhQsOVyd4qbZZXSmkD7n29l54FJ 3XRRIG16KI4kgRm2AWwYXo83W82WfIBXli2Ri1UMwPWlBXttt90TdtmqJqUbQOCV6TBk wdBabdUiKpgU1nLQedW06SbCXOTTHSL1hVmLlhdkwlSqrEmOym33rEFaRJUnnmCQ3/io fVjTpRqaFuoiAMcWri6rxyrIgDLzL+Nbyq9g4pYrVJgb/rhZwbiSKI2vKaJoRDs8SuiZ kw1w== X-Gm-Message-State: AOJu0YwNRhWV2Qfez5GmsJKDf+WtUf9VCg8jpn3Q10Rz9IL1L9hfdNlk VBSHMQ9JvwGhlet21mpHP30rtk+2xjTLDokNo97FuEIN7wOx7uDAqPGjIg== X-Google-Smtp-Source: AGHT+IGOqujDqci6eHkb1Ecr5P6naecR3A9n/7NvBOrk1iLPYE2otoykNPh39tbwW2W1p2iyiq6pmQ== X-Received: by 2002:a05:600c:3d86:b0:42f:8515:e490 with SMTP id 5b1f17b1804b1-432df7179c6mr63419205e9.5.1731792436152; Sat, 16 Nov 2024 13:27:16 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:15 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 7/8] test/reg-wait: add registration helper Date: Sat, 16 Nov 2024 21:27:47 +0000 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 56 ++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index ffe4c1d..559228f 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -32,6 +32,37 @@ static int test_wait_reg_offset(struct io_uring *ring, sizeof(struct io_uring_reg_wait)); } +static int __init_ring_with_region(struct io_uring *ring, unsigned ring_flags, + struct io_uring_mem_region_reg *pr, + bool disabled) +{ + int flags = disabled ? IORING_SETUP_R_DISABLED : 0; + int ret; + + ret = io_uring_queue_init(8, ring, flags); + if (ret) { + if (ret != -EINVAL) + fprintf(stderr, "ring setup failed: %d\n", ret); + return ret; + } + + ret = io_uring_register_region(ring, pr); + if (ret) + goto err; + + if (disabled) { + ret = io_uring_enable_rings(ring); + if (ret) { + fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); + goto err; + } + } + return 0; +err: + io_uring_queue_exit(ring); + return ret; +} + static int page_size; static struct io_uring_reg_wait *reg; @@ -222,30 +253,11 @@ static int test_try_register_region(struct io_uring_mem_region_reg *pr, bool disabled) { struct io_uring ring; - int flags = 0; int ret; - if (disabled) - flags = IORING_SETUP_R_DISABLED; - - ret = io_uring_queue_init(8, &ring, flags); - if (ret) { - if (ret != -EINVAL) - fprintf(stderr, "ring setup failed: %d\n", ret); - return ret; - } - - ret = io_uring_register_region(&ring, pr); - if (ret) - goto err; - - if (disabled) { - ret = io_uring_enable_rings(&ring); - if (ret) - fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); - } -err: - io_uring_queue_exit(&ring); + ret = __init_ring_with_region(&ring, 0, pr, disabled); + if (!ret) + io_uring_queue_exit(&ring); return ret; } From patchwork Sat Nov 16 21:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877734 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10C94198E80 for ; Sat, 16 Nov 2024 21:27:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792440; cv=none; b=oKxRoRcHoFnQFqPcIgLoay1SaSVttNipYpNoMcqUlrdh4LkMljLjxJFMdMj5+43oTv62vPva0u+n24cmRiexJlJLfmsh7k8aUhsLiboje3elS8QMitSIFfJpxYys8710hZ9BptIBDS9f0wcusrPWc1GSu7MK3lgzZmH+t8iZirY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731792440; c=relaxed/simple; bh=hkVKUkENVbqyJqDlHt03FqumUOp2/hffMrETnKCt9fU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OgNXSn8KSwxCJ+GoGHzXFxyHYPO2qAGVQ8mXkJGZYDhlRa0TwqDCg+92Em1lyqpLWC3KdJG89WQfdbAOI63xBBu6G+RdRP5aeL8xJoAPX1l9E4L8PeWSQ2fs4uOzDM8fnSDzutR2RFubYPtiLMBBxFv8YmAVYqf1zluQBjskFhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E3VZAPZ2; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E3VZAPZ2" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so15912665e9.2 for ; Sat, 16 Nov 2024 13:27:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731792437; x=1732397237; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VknFPR0P1FV3lPWvCpBDYnQxmfE5/HgO96NgGZKcy3k=; b=E3VZAPZ2PSDeQTsp+VKAXMsTEOiFRWfyA9gMtLhmRt/qV8uyyQBIKDFw/BTh+RNV+n n5voIUvM+27nUbyY5DnWczhdmrxFxwjnlmkMgl6kw2nQAjOOEUhT1pMzceTZOBHwFok4 CnBWi+ywirJqE5cvs9ZHPaSyrwV5oIkIoV6LH1brd26lNwwqK2RpEsRfXZ5cRRnWL6D6 IzKciTQxkiu0BCsALmFVMzOs9sCMuI+VZmj+Qh0WlTnIgRKZD1znrC4+jsJeK6+v2Egq gLONyJzwhbO4jSGif4KSTLPapS1YOSBQIg/ajnMDiZVyiGnmsnpaLlJbAO3Y6SKoE5Oj pXxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731792437; x=1732397237; 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:message-id:reply-to; bh=VknFPR0P1FV3lPWvCpBDYnQxmfE5/HgO96NgGZKcy3k=; b=Hc2WS2cncCuumKkGdnRPl1pAPPYiMwvk71ThVe0S+4kPJW88gb4peLhy1eyaVGrFlh UnpId0cY7Y3LqkL9m65MRBscUrQjBxFTt1HWxyyoC3EpciVpLEy8Pw+8xmp/BWQPWQZE pZPlpctwQBayDOTvczErUZiI4XLG7fzAZm25CNCxBHlJAY2oY10YTXR5m+G/bYuAA7Gj jAIxAI0I8oK/1F/Guih1ZFei+7GC3uhSMT3q5BUqgsksH+XtBGfTos7yGCKR0xdXL9fj BfpExEreG7bIxBAJjG+YOURwYhGqbvHfo1yabYr/xIStMI+YormEraffbBusdLKYonwB avGw== X-Gm-Message-State: AOJu0YzP9hlnS8/gmpsNfPL/adN6uPQtFSJuMTh0CSjEj63aGQQ5IAi9 0LTSjaC5bv9NUMlGYBHsXYmfPWBc/+QKops3p9OsmkB9KUz+vZud7kJQJA== X-Google-Smtp-Source: AGHT+IFs4OzPha+cdEliLHnJJyGCyCfcnCSZdri0bkJMYlFWXms6Z0LeSee+Jgufvc9VeVUyaITwtQ== X-Received: by 2002:a05:600c:3d86:b0:42f:8515:e490 with SMTP id 5b1f17b1804b1-432df7179c6mr63419375e9.5.1731792436996; Sat, 16 Nov 2024 13:27:16 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.146.122]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm101071325e9.28.2024.11.16.13.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 13:27:16 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 8/8] test/reg-wait: test various sized regions Date: Sat, 16 Nov 2024 21:27:48 +0000 Message-ID: <84233449abb8f5f3c878e7ccabf8520880bac624.1731792294.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index 559228f..b7c823a 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "liburing.h" #include "helpers.h" @@ -63,6 +65,12 @@ err: return ret; } +static int init_ring_with_region(struct io_uring *ring, unsigned ring_flags, + struct io_uring_mem_region_reg *pr) +{ + return __init_ring_with_region(ring, ring_flags, pr, true); +} + static int page_size; static struct io_uring_reg_wait *reg; @@ -109,6 +117,14 @@ static int test_offsets(struct io_uring *ring, struct io_uring_reg_wait *base, int copy_size; int ret; + rw = base; + memcpy(rw, &brief_wait, sizeof(brief_wait)); + ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, 0); + if (ret != -ETIME) { + fprintf(stderr, "0 index failed: %d\n", ret); + return T_EXIT_FAIL; + } + if (overallocated) { rw = base + max_index; memcpy(rw, &brief_wait, sizeof(brief_wait)); @@ -134,7 +150,7 @@ static int test_offsets(struct io_uring *ring, struct io_uring_reg_wait *base, return T_EXIT_FAIL; } - offset = page_size - sizeof(long); + offset = size - sizeof(long); rw = (void *)base + offset; copy_size = overallocated ? sizeof(brief_wait) : sizeof(long); memcpy(rw, &brief_wait, copy_size); @@ -354,6 +370,62 @@ static int test_regions(void) return 0; } +static void *alloc_region_buffer(size_t size, bool huge) +{ + int flags = MAP_PRIVATE | MAP_ANONYMOUS; + void *p; + + if (huge) + flags |= MAP_HUGETLB | MAP_HUGE_2MB; + p = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, -1, 0); + return p == MAP_FAILED ? NULL : p; +} + +static int test_region_buffer_types(void) +{ + const size_t huge_size = 1024 * 1024 * 2; + const size_t map_sizes[] = { page_size, page_size * 2, page_size * 16, + huge_size, 2 * huge_size}; + struct io_uring_region_desc rd = {}; + struct io_uring_mem_region_reg mr = {}; + struct io_uring ring; + int sz_idx, ret; + + mr.region_uptr = (__u64)(unsigned long)&rd; + mr.flags = IORING_MEM_REGION_REG_WAIT_ARG; + + for (sz_idx = 0; sz_idx < ARRAY_SIZE(map_sizes); sz_idx++) { + size_t size = map_sizes[sz_idx]; + void *buffer; + + buffer = alloc_region_buffer(size, size >= huge_size); + if (!buffer) + continue; + + rd.user_addr = (__u64)(unsigned long)buffer; + rd.size = size; + rd.flags = IORING_MEM_REGION_TYPE_USER; + + ret = init_ring_with_region(&ring, 0, &mr); + if (ret) { + fprintf(stderr, "init ring failed %i\n", ret); + return 1; + } + + ret = test_offsets(&ring, buffer, size, false); + if (ret) { + fprintf(stderr, "test_offsets failed, size %lu\n", + (unsigned long)size); + return 1; + } + + munmap(buffer, size); + io_uring_queue_exit(&ring); + } + + return 0; +} + int main(int argc, char *argv[]) { int ret; @@ -381,5 +453,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "test_wait_arg failed\n"); return 1; } + + ret = test_region_buffer_types(); + if (ret == T_EXIT_FAIL) { + fprintf(stderr, "test_region_buffer_types failed\n"); + return 1; + } + return 0; }