From patchwork Fri Nov 15 21:33: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: 13877330 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 22DAF18DF6D for ; Fri, 15 Nov 2024 21:33:13 +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=1731706395; cv=none; b=ZEFO9VtVPVVF2UXr0Zt42pn7O4yzsipGd6wAQc1PsUghSm2ZSZ+t5is9q8o3aLgvsOsGK4OMSdU6CCMMRgRok1LzlG8TmxNcOVAsbolhRAI6nlGijiqKGk4g37Y5P5ewzM5gn8e98fd5rvP80QsN4ptzu+3jNQo75Fq6ZAw4wt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706395; c=relaxed/simple; bh=4Wi69DKVB39pFl8/D1pSzFc34pxnEHe1sKDwZtEo2+M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LeoV++hdbEAwJsyQtfqWqUkvAFy7nN/iq364oTVHgusz549nDZ88yWb1N2IFxB+KgjmWOH+wrZdJdfj4S+CjKY2XhdI5fUK3HIP06L1gPXMj1RNSFnet9gBf+Dmw14Xttcl5ZZ42mFTlvib2Q/J2Z0qrZMA0HkHytrJIuhQO+fw= 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=Tno4B8PJ; 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="Tno4B8PJ" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4315baa51d8so9472045e9.0 for ; Fri, 15 Nov 2024 13:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706392; x=1732311192; 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=yRJvpXkonpZLFq2sXYvgesC2fqUsJ/OFGmvyeGbZlGA=; b=Tno4B8PJ7rqBeP84MeV5W8Eny2H6l02KrDrVthM2pjzSIWIsfoahpjkOOAsKp4EoVr 8o5R+ZJAwxQLJXoK0XMJgfzf8vnXn2ZdDtwyNbAiHxzitwB9G38jyOdV68GIn4pKN8cF qprG+uHj1c26e1qHYZvD6Ms83iuSNf83JC1Qp1eYYqusUBYZ2cql6meOIId+fwnxbEMJ aOErMq2bUzqv0CgJUWLySOQVP6ZxrWuwIPKD+DSkY6gI2rtay1/2oiXX1u+ghdWxmNKL 7foGZPMRifuOH9e8irs3dLrKkRqbwEwx2IfrYgu1QAlATv8MKPs3ghvOYDvayTXoY/5e uLvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706392; x=1732311192; 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=yRJvpXkonpZLFq2sXYvgesC2fqUsJ/OFGmvyeGbZlGA=; b=lc+Jxk3x9069XwLvB4dhCJWt1M31a7zeyxQcn0zMBfFsT7fvH109bbi144fIdzeVbS HcwP8etZcp517Oy3m1SdQaNS0T7oyjxhGRBTCqpydLN+txTn/6QXii10oecKMc1/9rnw WYfllyQS+ft55PDV16cXfuySYw3dunPwpN+Q3O7IGU6f6div9feeOhLkeEmicjS0Ii5I kIMayhVB834dlGaAkbHkVxk+ETOoIsUhI1+V1/AU5pYKmb3qfVMMushL+fEy8XYNmuv4 G+BYPhZ12qZHGDiBM6qy4/NItZys/BD5fzwJI3TQNXeyI0crYeutZlkMgU35caxbBdru YMBQ== X-Gm-Message-State: AOJu0YxcOdpynCML9kn8fntQtx/SkJ5RSMfWfWAcbtgXFrKfxLQaZM0I h5/x8HawWMo6l5TVQcvCgZEfoJZzAC5fwfHSTIjygWyIOLkU3hqAWBtoSw== X-Google-Smtp-Source: AGHT+IEp2CFwu1PD2Qt9LONRFFHcmRPoYa156F4cu7RVc5RwgnWninX1jYq85pf0fAd4bMMxnYdZCw== X-Received: by 2002:a05:6000:1fa3:b0:37c:cbd4:ec9 with SMTP id ffacd0b85a97d-382259023f1mr3666410f8f.5.1731706391475; Fri, 15 Nov 2024 13:33:11 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:10 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 1/8] queue: break reg wait setup Date: Fri, 15 Nov 2024 21:33:48 +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 We're changing the registration and kernel api, kill reg wait registration but leave definitions so that tests build. Signed-off-by: Pavel Begunkov --- src/register.c | 9 +-------- src/setup.c | 19 ------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/register.c b/src/register.c index aef5baf..d566f5c 100644 --- a/src/register.c +++ b/src/register.c @@ -468,12 +468,5 @@ out: int io_uring_register_wait_reg(struct io_uring *ring, struct io_uring_reg_wait *reg, int nr) { - struct io_uring_cqwait_reg_arg arg = { - .flags = 0, - .struct_size = sizeof(*reg), - .nr_entries = nr, - .user_addr = (unsigned long) (uintptr_t) reg, - }; - - return do_register(ring, IORING_REGISTER_CQWAIT_REG, &arg, 1); + return -EINVAL; } diff --git a/src/setup.c b/src/setup.c index 073de50..7c0cfab 100644 --- a/src/setup.c +++ b/src/setup.c @@ -689,29 +689,10 @@ int io_uring_free_buf_ring(struct io_uring *ring, struct io_uring_buf_ring *br, void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries) { - __sys_munmap(reg, nentries * sizeof(struct io_uring_reg_wait)); } struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring, unsigned nentries, int *err) { - struct io_uring_reg_wait *reg; - size_t size = nentries * sizeof(*reg); - int ret; - - reg = __sys_mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_SHARED|MAP_POPULATE|MAP_ANONYMOUS, -1, 0); - if (IS_ERR(reg)) { - *err = PTR_ERR(reg); - return NULL; - } - - memset(reg, 0, size); - ret = io_uring_register_wait_reg(ring, reg, nentries); - if (!ret) - return reg; - - __sys_munmap(reg, size); - *err = ret; return NULL; } From patchwork Fri Nov 15 21:33:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877331 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 8575C1FDF92 for ; Fri, 15 Nov 2024 21:33:15 +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=1731706397; cv=none; b=a1zVK+sbPt8E9XK1NvDLd5uFgscaV8F6ySz+d8NnHYtLaQNUGBQSJqZJ5oY5mY74CFV6UqcJy7CuWsqs84fHGgL5XqJuOrUSSOVVXvplSNHedtRoabctUBDyd9xa2uFC6qCCmcwdoahDqywhpXxUYvbvG9itUvRrkmXC2O8LDvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706397; c=relaxed/simple; bh=xYZHUvywzGJloDPhoEEV20mT5d5lF6lAtamijUkqOOs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=miF/ThkySEcgfMrQ2HJKM6IvJjjflOvILaCbtPmSQp2TxBXhbM137ovMFhmokpHtsE4GZadoH+epdvlpbk2BVxIiesi120lsSzZgPNJddTQC7kwPexXxd6Y6WF53xYvY+TjGNcQ8uBvZZX3hSqj3eZcvn5fFUlTF5phwrrNJKQE= 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=UgXQRsY0; 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="UgXQRsY0" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4315e62afe0so19535475e9.1 for ; Fri, 15 Nov 2024 13:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706393; x=1732311193; 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=xQBi1iIuoh3NbsC5pbTwBoqOZ+wl3kG8MmjMdEdWtac=; b=UgXQRsY0Tw6GJ0lm3pxH0t/Y2KHekhX8huR7abRxbymFVN3d2sIyl2MS4pKAVKKUut 0fZnEvjAnaSrxDNZGB8HJnfRAtLAK0BK5hk2Qe2u+KPXJ1VUVEC5xw0Q1G3C+sgEPj5j culoDwbsquhFgyuHIVVOhMPD41DLLJEmpqKCFrp9La9xuhwv6/ztrpR7q8Aqx1yvZezH QEJfuUHbZuTU81ADe/D8ehmNF8jAn5YLXczw/a4O3a/IYg5f1yosHgBxTgaKXt0QAClo BIUWEzlISsYng5cMRIvOswqGhzxuugSZBSV6e6cQ3cCTaqU7KtTZrV8P/Ap6IG3ts7Nu CZyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706393; x=1732311193; 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=xQBi1iIuoh3NbsC5pbTwBoqOZ+wl3kG8MmjMdEdWtac=; b=XGXLEo9MedqNT5a1nQx73Tvw0F21lHmGLAf3NbiiS8v8rJyiR6Hglu+G0F486qsvoz mUn1zUE6hk6Dw1QOToAuGbhA71S6kt4n+q990IoaA8+a66qNKqNPd9jVZTvwsILpSVXW op7bYjsWd0oGayfTLIRrhtVQwMl7wCbwKFj5Fm9C2eNCasgq1o3ra/oOSJo6jTSAqPXy Hb4TPpLvnedo9ir3p68gM8CZc41K6RpNwSUxJYSViM3+n58VsCPC0Fbq58ioVoM0lTHQ RdLq1yJ/ssygXWolr8sOYZqjqcr0ahywbvs5hTkWePwB9L2CihZ3tXtVz40EBtbJxB/w RqUg== X-Gm-Message-State: AOJu0YySj7rvlbQfJxTWe3DhyS99YiRyPgEXmF35VstPPERW0Ac9nbnc t614+J4dyGTyX3SvL1vnVLrwuNV5DsyaKDe4eGe+6xNaK2A4jsOatuy4VA== X-Google-Smtp-Source: AGHT+IH+P+Af+6i0o/SKPip46fTFOx42P56MmNZ9z6W2VBEGytZsGoUO9X0CP+4VfgsP+WiVgIU4kA== X-Received: by 2002:a5d:64c8:0:b0:382:2ba9:9d65 with SMTP id ffacd0b85a97d-3822ba9a39cmr1934094f8f.31.1731706392881; Fri, 15 Nov 2024 13:33:12 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:12 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 2/8] Update io_uring.h Date: Fri, 15 Nov 2024 21:33:49 +0000 Message-ID: <7f84430397941168cd4237590cad20578236184b.1731705935.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 Remove the wait register opcode and add region registration bits. Signed-off-by: Pavel Begunkov --- src/include/liburing/io_uring.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h index 20bc570..b2adc3f 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h @@ -615,7 +615,7 @@ enum io_uring_register_op { IORING_REGISTER_RESIZE_RINGS = 33, - IORING_REGISTER_CQWAIT_REG = 34, + IORING_REGISTER_MEM_REGION = 34, /* this goes last */ IORING_REGISTER_LAST, @@ -637,6 +637,31 @@ struct io_uring_files_update { __aligned_u64 /* __s32 * */ fds; }; +enum { + /* initialise with user provided memory pointed by user_addr */ + IORING_MEM_REGION_TYPE_USER = 1, +}; + +struct io_uring_region_desc { + __u64 user_addr; + __u64 size; + __u32 flags; + __u32 id; + __u64 mmap_offset; + __u64 __resv[4]; +}; + +enum { + /* expose the region as registered wait arguments */ + IORING_MEM_REGION_REG_WAIT_ARG = 1, +}; + +struct io_uring_mem_region_reg { + __u64 region_uptr; /* struct io_uring_region_desc * */ + __u64 flags; + __u64 __resv[2]; +}; + /* * Register a fully sparse file space, rather than pass in an array of all * -1 file descriptors. From patchwork Fri Nov 15 21:33:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877332 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 0FCB91FDF92 for ; Fri, 15 Nov 2024 21:33:20 +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=1731706402; cv=none; b=Gynun1Bie0xrN/ANtCvfDv5LnrWbOT2QW1KLph2jDBro8jUxUzwyJV+D+5XaPBAGkGLz6uVFKmAGN9bw8WWjKi3DHf1jhEd1zpI1WxMAIYr1GC3tcL/N5/6maWxCFm87e1Ph2AoqW4EFRjFmVn8xPc6eIZLolKtKY+zo7LFHoro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706402; c=relaxed/simple; bh=wwGynPXkF20AraUsK2w2sohhhqLepUdz8Q0unalezdg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mopFz7SNIqLgCwbmPy9Ei/14pKiouhU1gpuSCze+SPZIfBivZOiPgEbMAakqUsHDgSGZa1HVVGv0GYJ64VDJIub4hErhcHJk7nIrg/jaWsHzi2CVImuwFyXzzftp6OgpwYw4MoZ/pNpDXjPLfrQyS6m2sWs29+pjqqhMovciRSM= 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=cWE0hcE0; 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="cWE0hcE0" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43158625112so798015e9.3 for ; Fri, 15 Nov 2024 13:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706394; x=1732311194; 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=YNM2WJwBXprOb2QXvwXlSAYOSUSwg9yszuSdSI916n0=; b=cWE0hcE0+Ogqxgiv1Wr8Euafk0J3u04H5kqlKk6VuP2VovN3OeoYERzv6sIJcSka4g HeRUrfz3EjNr4mvjrWOUkZpDL64V45y0v20/k8qoR/p0hia5LLIKbt7HTiVE1z+5itEP btRlwFEnJBSckSFG0vtEFQdJVUVj4OnA3se8nRvRTW+qIjxcaAgTXTJ4kYfBUyK1I5lU pAhI4k0K5gksHuqrnqrT0a8mjTgeUXS+n0om4mYEYn5zolEiQZmEhPqay9TZUIiV4Rxg NtnmrOv6clNGpxqMbIwnXu5KO4XcHnXvGzyHFshC6FnAlebCZvR3Jv2I+b61xB7Eo9Wr H1ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706394; x=1732311194; 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=YNM2WJwBXprOb2QXvwXlSAYOSUSwg9yszuSdSI916n0=; b=lDdgABvcpVkevOhC4dlWCo162gk/R0ZmooY22NeovqPd+EpVUNJcBaoj9y0hoWsX19 CJjdG29idnWQ6uMmm91izLtgZm0uWEkTL39zltgmnLW1FHHWjs8lwFSe6Q+zpNMrxReT bPPNtJXgHpbiSeJPYdBg3vGUsF9JXLAzFpiDiPM/8BUO1SeYc3Q6dCel7LUMbXxSphMT 1Sv/0cBTPbPjZE95dZpj9uteWIgqb4NqL49jnjdRJEsEdTdennyZSp3OLeUO1XEVs1eG RQytFa9b/jbJkZ4XxVJBg80f8sOLbve6ZZXvqRM/NRtyILFQOo3Eos6YyV1+0UUWTh1s IDuw== X-Gm-Message-State: AOJu0YwITRRoWsoQkwMD71NF+TbrVGRdAGtMX5T/4beFp4i5ospOM3TA AlLTePdhwlTKbxckpMupWBeGafgvyeFFJktvvflsp9GW2BQCf14Z/OHtrg== X-Google-Smtp-Source: AGHT+IFr1yNDAeV0E8HJX8oyRBmW6eWQ77dafhJ8oZIW2UrxNZP4AbKAL45fMzRj2yt8Vg3R2d+TVg== X-Received: by 2002:a05:6000:481c:b0:382:d0b:179a with SMTP id ffacd0b85a97d-382258f0beamr3061457f8f.6.1731706394306; Fri, 15 Nov 2024 13:33:14 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:13 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 3/8] queue: add region helpers and fix up wait reg kernel api Date: Fri, 15 Nov 2024 21:33:50 +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 Now the kernel expects a byte offset instead of a struct io_uring_reg_wait index. Also add a helper for registering a region of memory. Signed-off-by: Pavel Begunkov --- src/include/liburing.h | 4 +++- src/liburing-ffi.map | 1 + src/liburing.map | 1 + src/queue.c | 4 +++- src/register.c | 6 ++++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index 4d45dca..81ffe6e 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -285,8 +285,10 @@ int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg, unsigned int nr_args); /* - * Mapped/registered wait regions + * Mapped/registered regions */ +int io_uring_register_region(struct io_uring *ring, + struct io_uring_mem_region_reg *reg); struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring, unsigned nentries, int *err); void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries); diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map index 0985f78..117a46a 100644 --- a/src/liburing-ffi.map +++ b/src/liburing-ffi.map @@ -224,4 +224,5 @@ LIBURING_2.9 { io_uring_free_reg_wait; io_uring_setup_reg_wait; io_uring_clone_buffers_offset; + io_uring_register_region; } LIBURING_2.8; diff --git a/src/liburing.map b/src/liburing.map index 998621d..46edbc9 100644 --- a/src/liburing.map +++ b/src/liburing.map @@ -111,4 +111,5 @@ LIBURING_2.9 { io_uring_free_reg_wait; io_uring_setup_reg_wait; io_uring_clone_buffers_offset; + io_uring_register_region; } LIBURING_2.8; diff --git a/src/queue.c b/src/queue.c index 1692866..5f28e01 100644 --- a/src/queue.c +++ b/src/queue.c @@ -324,6 +324,8 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, unsigned wait_nr, int reg_index) { + unsigned long offset = reg_index * sizeof(struct io_uring_reg_wait); + struct get_data data = { .submit = __io_uring_flush_sq(ring), .wait_nr = wait_nr, @@ -331,7 +333,7 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring, IORING_ENTER_EXT_ARG_REG, .sz = sizeof(struct io_uring_reg_wait), .has_ts = true, - .arg = (void *) (uintptr_t) reg_index, + .arg = (void *) (uintptr_t) offset, }; if (!(ring->features & IORING_FEAT_EXT_ARG)) diff --git a/src/register.c b/src/register.c index d566f5c..0fff208 100644 --- a/src/register.c +++ b/src/register.c @@ -470,3 +470,9 @@ int io_uring_register_wait_reg(struct io_uring *ring, { return -EINVAL; } + +int io_uring_register_region(struct io_uring *ring, + struct io_uring_mem_region_reg *reg) +{ + return do_register(ring, IORING_REGISTER_MEM_REGION, reg, 1); +} From patchwork Fri Nov 15 21:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877333 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 6B2541FDF92 for ; Fri, 15 Nov 2024 21:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706405; cv=none; b=YMOb0Yy79XJwsAy+xrQqIbKrXjFi8clrvDJt6pkeIiB36OEs0MbnLeL/mkrhpvo624kYbSH6BUm4Blgoame+7gukLAf5o17eaWVo2mIcoon863GV7uIYSKWU4k6boLONFrn5j/otawEd6x5jnQXtNzFSlWgTHbJNpKDDZjWUfn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706405; c=relaxed/simple; bh=zBrYdvmR0T1XcG/DyeBSjti4eEZ9Z4IkaqV/O2X47Ew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D3ykOpYr3toJl4imLQ5Mr5Zcl+4u/l4wFW3RUoyuXQLEglipCy17DIOyIvX3w3cLpOnHwsIX0VkLZXUEv1NhyfxWFrZR7aYuMk87lyasXF4K6nOwNDYNnHmjvT2S16Yc0ONa3CF7DFT0Gv3g936CzAiAVmjd0ac/UqSCE0IC6R0= 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=OSYXS2P6; arc=none smtp.client-ip=209.85.221.49 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="OSYXS2P6" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37d518f9abcso1581211f8f.2 for ; Fri, 15 Nov 2024 13:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706399; x=1732311199; 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=hTRlc2vdOeYWq9i9ffDOQgc0z4rPfWnbn+mnV5mimfA=; b=OSYXS2P6DDUoisbPKKOuf05Sb1nhhZjcyeUZoJjihxfCsxtmpcitBuvReKW3vaWG00 VEdWbc2jlVWUS9qbnuELs6LOCoTV/GTAZ4HXjTV1UQSn62h1g3RY06v2mpbK4o8KfT+8 Mjs0LPH2LnxRQJpfpWbGDUkifbcXpEaztBR5rYRIG1A/6meTbiMaO84LJzzqvVkwTfjO gJ/1qW0G2mLSCepTflS+dE52BgZG2K+rqEX8ivTm82yLQ+Ds1i0KvghkixKeBbu7NfUr PYhmV6QOGrDSyDVx3kDg7XrTze41ZoylTmyEWk9EWngm0XQSaCaM1ct9JrCcxKu9TNFK SEJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706399; x=1732311199; 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=hTRlc2vdOeYWq9i9ffDOQgc0z4rPfWnbn+mnV5mimfA=; b=eMCcpS8+SBsxlS0ED1y9TpQAivn2kWZEBHAPPWv6Rmu5DsE53XJ4tf0LzZZQf5YEIx h2/UV4h4Od2tt2PgvK9znpHBO5PAvYIfe5rlCu7XyIqRGRejdfDN5V9XsAhYDq/+kjTs IaRLLNJ2RLlaMaa0TLO9fkUbLOoRyTCKbiH9+ZQn6aDARsZksxvuWsfs2MOP68uoDsss z0RA58gqKQ6clGBrKduhmQdbscZj3SZWemjAQrIAJQhhv1W+Nk/A109yXGYrYPezNog1 NIg27crf6Fvb4r81oZKo/Ui2wcK/C+fsJBwHTFrjZ/b5alUMGAXJR3FzKdBqdV5tSi8L EeDA== X-Gm-Message-State: AOJu0Yx2fwcDSxBDgJSzQeHhzWYMF8SBMVVQL2r+LCb+q1VXzuPvWBbX th9u6INRedHAq/C6qVfZclr46SJFl5yrjurrgh7M59oDP29MTGd7Yx/y9w== X-Google-Smtp-Source: AGHT+IE3dV9YKC/QHTHKwPboyKTZZ/tZIE1wHalGB8mdItxRfZxAzdTiMpy6lgFoEqQyvkAdxt0tFQ== X-Received: by 2002:a5d:47a9:0:b0:382:359f:5333 with SMTP id ffacd0b85a97d-382359f54e6mr3839f8f.22.1731706398700; Fri, 15 Nov 2024 13:33:18 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:14 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 4/8] examples: convert reg-wait to new api Date: Fri, 15 Nov 2024 21:33:51 +0000 Message-ID: <45f88d24de240c3823e6cc04496a54d62d5d6305.1731705935.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 --- examples/reg-wait.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/examples/reg-wait.c b/examples/reg-wait.c index 375538c..0e119aa 100644 --- a/examples/reg-wait.c +++ b/examples/reg-wait.c @@ -38,6 +38,20 @@ static unsigned long long mtime_since_now(struct timeval *tv) return mtime_since(tv, &end); } +static int register_memory(struct io_uring *ring, void *ptr, size_t size) +{ + struct io_uring_region_desc rd = {}; + struct io_uring_mem_region_reg mr = {}; + + rd.user_addr = (__u64)(unsigned long)ptr; + rd.size = size; + rd.flags = IORING_MEM_REGION_TYPE_USER; + mr.region_uptr = (__u64)(unsigned long)&rd; + mr.flags = IORING_MEM_REGION_REG_WAIT_ARG; + + return io_uring_register_region(ring, &mr); +} + int main(int argc, char *argv[]) { struct io_uring_reg_wait *reg; @@ -48,30 +62,43 @@ int main(int argc, char *argv[]) unsigned long msec; struct timeval tv; int ret, fds[2]; + int page_size; if (argc > 1) { fprintf(stdout, "%s: takes no arguments\n", argv[0]); return 0; } + page_size = sysconf(_SC_PAGESIZE); + if (page_size < 0) { + fprintf(stderr, "sysconf(_SC_PAGESIZE) failed\n"); + return 1; + } + if (pipe(fds) < 0) { perror("pipe"); return 1; } - ret = io_uring_queue_init(8, &ring, 0); + ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED); if (ret) { fprintf(stderr, "Queue init: %d\n", ret); return 1; } /* - * Setup wait region. We'll use 32 here, but 64 is probably a more - * logical value, as it'll pin a page regardless of size. 64 is the - * max value on a 4k page size architecture. + * Setup a region we'll use to pass wait arguments. It should be + * page aligned, we're using only first two wait entries here and + * the rest of the memory can be reused for other purposes. */ - reg = io_uring_setup_reg_wait(&ring, 32, &ret); + reg = aligned_alloc(page_size, page_size); if (!reg) { + fprintf(stderr, "allocation failed\n"); + return 1; + } + + ret = register_memory(&ring, reg, page_size); + if (ret) { if (ret == -EINVAL) { fprintf(stderr, "Kernel doesn't support registered waits\n"); return 1; @@ -80,6 +107,12 @@ int main(int argc, char *argv[]) return 1; } + ret = io_uring_enable_rings(&ring); + if (ret) { + fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); + return 1; + } + /* * Setup two distinct wait regions. Index 0 will be a 1 second wait, * and region 2 is a short wait using min_wait_usec as well. Neither @@ -154,6 +187,6 @@ int main(int argc, char *argv[]) * Cleanup after ourselves */ io_uring_queue_exit(&ring); - io_uring_free_reg_wait(reg, 32); + free(reg); return 0; } From patchwork Fri Nov 15 21:33:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877334 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 ED82E1FDF92 for ; Fri, 15 Nov 2024 21:33:25 +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=1731706407; cv=none; b=RKnf3uDZ4SZ5blPfJwxEnID2p+gS/mknbJFOqogbQz3at0g2RQhXGO87377sCybylMrJS0QVawi/5zzW9mbK1L8KjLhcFuBnDlT6+6holOoROAeODwUOJYNizxSskGXOvkS4B7CfIp/7CQ/8HK6bto9femfB1Z4MvIvtas3bdvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706407; c=relaxed/simple; bh=E6JcGxrQ+7CI4dw2g5XIAUujxTwRMxCMZ1VlKh1CyeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YuuMp4aIe46aOlFuaDV/6Vn6JCvC8cI5QSHHTRJ/X/tnaNgDnoIB1ZRurBap955FhE+xDKXIc503v7HP7t7X06ueWxkYzdK5CLHZW+UN1cBHZpfDyZucgkwXPa7VkxszWTLzUUXS6XfxA5CttCFECu8fkJU6WMyJgmsB8OK4cyE= 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=YoqGRVPB; 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="YoqGRVPB" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4316a44d1bbso9456905e9.3 for ; Fri, 15 Nov 2024 13:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706400; x=1732311200; 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=978b0PnZIA0363nKNgqJcGov/ZEBqzZkx8b+53XQc8g=; b=YoqGRVPB4n9ZDNpMcYU1ZwacpXVtb7NtkItzESHKrBG/NUjg35+HyGBd4UGdrTHoje oPyljMZnAxqkjvjhguRqaZICtivgneuDD0+wHS68iJ8FfVF60FWRcge4T6MgM4YnpXqD pXIL+jAreq5mCZBjaXgmjnv5oevhz35UKblxfqwwFnvlTpMTZCl4xxRE+Ye1IiSPdS7x 0eVig6Nn61sxF79CJn0X13TKLu/9OlZljoG620OSf64gyiIy6s0TwmGvP1Sw4AdwZPlm aSSYOLD6FBy4sCv4IJ8e6smwc9nx36+tJzslncXa7eidBMyNZsfXzkTdhKdpX6NG+0Pc rzvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706400; x=1732311200; 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=978b0PnZIA0363nKNgqJcGov/ZEBqzZkx8b+53XQc8g=; b=tkW7i15I5err+oUGdAt0SXlwjPyotscEyfL3kV8kfXaL37Y/zAbqI0wBkA/H0U2dYc lAy16BGOLP2kteZnhE4ke/9sTey0J81X3i3queCdbXT0ODk/QTLRUF7xFbl1t+tL3QRm VcUTGKvS7dYIePS2nLkb1ASxazeIbhSUS7dFLGZv1yygAPzkWIgJkrNSbh4CRWVRxgHZ C8MgJpspmUHVz+3EdbNcmKQA+RpPiP/6GlgI0Nfb43mzE6Fd41n0IShwnZwnOPrg8Hyr wzcokfUSvJM4U56C2xdig52Cloc4yGAahEbQhmqNVLq6JI4q2oEB9bfFhxWZ8xBSjLcP gbCQ== X-Gm-Message-State: AOJu0Yyfl8Sikn9J9UhaPXJNaNM31Jxm80WczLZpMhGIrU+r5GY/Xyaf 5yiaTqZyNRscZ77GdTYbNW9N4tLUKsQWNPund/tXFSiLJTbI4FAybBifrw== X-Google-Smtp-Source: AGHT+IF/QEUbxqRM0biEbM7CJl+6wn6eteBwUsknhptFAdffiwqQIKZiFy43Cy2MOgqfkLgbXoOzkw== X-Received: by 2002:a05:600c:4e4f:b0:430:57f2:bae5 with SMTP id 5b1f17b1804b1-432df792b27mr32720635e9.27.1731706400288; Fri, 15 Nov 2024 13:33:20 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:19 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 5/8] tests: convert reg-wait to regions Date: Fri, 15 Nov 2024 21:33:52 +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 | 217 ++++++++++++++++++------------------------------ 1 file changed, 83 insertions(+), 134 deletions(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index 6a5123a..5f5a62a 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -14,123 +14,9 @@ #include "helpers.h" #include "test.h" +static int page_size; static struct io_uring_reg_wait *reg; -static int test_invalid_reg2(void) -{ - struct io_uring ring; - void *buf, *ptr; - int ret; - - io_uring_queue_init(1, &ring, 0); - - if (posix_memalign(&buf, 4096, 4096)) - return T_EXIT_FAIL; - memset(buf, 0, 4096); - ptr = buf + 4096 - 32; - - ret = io_uring_register_wait_reg(&ring, ptr, 1); - if (ret != -EINVAL) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - ptr = buf + (sizeof(struct io_uring_reg_wait) / 2); - ret = io_uring_register_wait_reg(&ring, ptr, 1); - if (ret != -EINVAL) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - free(buf); - buf = (void *) 0x1000; - ret = io_uring_register_wait_reg(&ring, buf, 1); - if (ret != -EFAULT) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - buf = (void *) 0x1240; - ret = io_uring_register_wait_reg(&ring, buf, 1); - if (ret != -EFAULT) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - buf = (void *) 0x1241; - ret = io_uring_register_wait_reg(&ring, buf, 1); - if (ret != -EINVAL) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - io_uring_queue_exit(&ring); - return T_EXIT_PASS; -} - -static int test_invalid_reg(void) -{ - struct io_uring_reg_wait *ireg; - struct io_uring_cqe *cqe; - struct io_uring ring; - struct timeval tv; - void *buf, *ptr; - int ret; - - io_uring_queue_init(1, &ring, 0); - - if (posix_memalign(&buf, 4096, 4096)) - return T_EXIT_FAIL; - memset(buf, 0, 4096); - ptr = buf + 512; - ireg = ptr; - - ret = io_uring_register_wait_reg(&ring, ireg, 56); - if (ret) { - fprintf(stderr, "register cqwait: %d\n", ret); - return T_EXIT_FAIL; - } - - ireg = ptr; - memset(ireg, 0, sizeof(*ireg)); - ireg->ts.tv_sec = 1; - ireg->ts.tv_nsec = 0; - ireg->flags = IORING_REG_WAIT_TS; - - gettimeofday(&tv, NULL); - ret = io_uring_submit_and_wait_reg(&ring, &cqe, 1, 0); - if (ret != -ETIME) { - fprintf(stderr, "wait_reg failed: %d\n", ret); - return T_EXIT_FAIL; - } - - ret = mtime_since_now(&tv); - /* allow some slack, should be around 1.1s */ - if (ret < 1000 || ret > 1200) { - fprintf(stderr, "wait too long or short: %d\n", ret); - goto err; - } - - memset(ireg, 0, sizeof(*ireg)); - ireg->ts.tv_sec = 1; - ireg->ts.tv_nsec = 0; - ireg->flags = IORING_REG_WAIT_TS; - - gettimeofday(&tv, NULL); - ret = io_uring_submit_and_wait_reg(&ring, &cqe, 1, 56); - if (ret != -EFAULT) { - fprintf(stderr, "out-of-range reg_wait failed: %d\n", ret); - return T_EXIT_FAIL; - } - - free(buf); - io_uring_queue_exit(&ring); - return T_EXIT_PASS; -err: - io_uring_queue_exit(&ring); - return T_EXIT_FAIL; -} - static int test_invalid_sig(struct io_uring *ring) { struct io_uring_cqe *cqe; @@ -164,6 +50,39 @@ static int test_invalid_sig(struct io_uring *ring) return T_EXIT_PASS; } +static int test_offsets(struct io_uring *ring) +{ + struct io_uring_cqe *cqe; + int max_index = page_size / sizeof(struct io_uring_reg_wait); + struct io_uring_reg_wait *rw; + int ret; + + rw = reg + max_index; + memset(rw, 0, sizeof(*rw)); + rw->ts.tv_sec = 0; + rw->ts.tv_nsec = 1000; + + ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, 0); + if (ret != -EFAULT) { + fprintf(stderr, "max+1 index failed: %d\n", ret); + return T_EXIT_FAIL; + } + + 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; + + ret = io_uring_submit_and_wait_reg(ring, &cqe, 1, max_index - 1); + if (ret != -ETIME) { + fprintf(stderr, "last index failed: %d\n", ret); + return T_EXIT_FAIL; + } + + return 0; +} + static int test_basic(struct io_uring *ring) { struct io_uring_cqe *cqe; @@ -192,27 +111,50 @@ err: return T_EXIT_FAIL; } -static int test_ring(void) +static int test_wait_arg(void) { + struct io_uring_region_desc rd = {}; + struct io_uring_mem_region_reg mr = {}; struct io_uring ring; - struct io_uring_params p = { }; + void *buffer; int ret; - p.flags = 0; - ret = io_uring_queue_init_params(8, &ring, &p); + ret = io_uring_queue_init(8, &ring, IORING_SETUP_R_DISABLED); if (ret) { + if (ret == -EINVAL) { + printf("IORING_SETUP_R_DISABLED not supported, skip\n"); + return 0; + } fprintf(stderr, "ring setup failed: %d\n", ret); + return T_EXIT_FAIL; + } + + 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 = page_size; + rd.flags = IORING_MEM_REGION_TYPE_USER; + mr.region_uptr = (__u64)(unsigned long)&rd; + mr.flags = IORING_MEM_REGION_REG_WAIT_ARG; + + ret = io_uring_register_region(&ring, &mr); + if (ret) { + fprintf(stderr, "region reg failed %i\n", ret); return 1; } - reg = io_uring_setup_reg_wait(&ring, 64, &ret); - if (!reg) { - if (ret == -EINVAL) - return T_EXIT_SKIP; - fprintf(stderr, "setup_reg_wait: %d\n", ret); + ret = io_uring_enable_rings(&ring); + if (ret) { + fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); return T_EXIT_FAIL; } + reg = buffer; + ret = test_basic(&ring); if (ret == T_EXIT_FAIL) { fprintf(stderr, "test failed\n"); @@ -225,27 +167,34 @@ static int test_ring(void) goto err; } - ret = test_invalid_reg(); + ret = test_offsets(&ring); if (ret == T_EXIT_FAIL) { - fprintf(stderr, "test_invalid_reg failed\n"); + fprintf(stderr, "test_offsets failed\n"); goto err; } - - ret = test_invalid_reg2(); - if (ret == T_EXIT_FAIL) { - fprintf(stderr, "test_invalid_reg2 failed\n"); - goto err; - } - err: + free(buffer); io_uring_queue_exit(&ring); return ret; } int main(int argc, char *argv[]) { + int ret; + if (argc > 1) return 0; - return test_ring(); + page_size = sysconf(_SC_PAGESIZE); + if (page_size < 0) { + perror("sysconf(_SC_PAGESIZE)"); + return 1; + } + + ret = test_wait_arg(); + if (ret == T_EXIT_FAIL) { + fprintf(stderr, "test_wait_arg failed\n"); + return 1; + } + return 0; } From patchwork Fri Nov 15 21:33:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877335 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 43DBE1FDF8C for ; Fri, 15 Nov 2024 21:33:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706409; cv=none; b=rz6BFgVi0HzLxq+lbjWkGatq+Gv5/jHHyhdaVPWghPaElAer/vO35N131BCaiNAhlVaGv5VGdl8VhlD1mN38hNUwLp9cp7FOcKJ4IgTTWTkcw+YKqTe43mD+Su7T73UdvR19bEGOC7VQggUozBYAxWnWXus5azURxYx+Mmg7XPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706409; c=relaxed/simple; bh=oU/IDIGrC7pHswbHGlacBSqbj8OiD2Vv4/FkTISy8Dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVvlN2nq8dFg2ozRrU226c465uO9C3I/bEaGiK9ZpXq8hsfxcIXtpIQAH/O/e6/GEPR6U4asX5keqfaCP3/mu3w6ciMqJt8LaXy65DGWQF0pMYg4eJ63TLfk8+oIfszuXY7I6TPtOWHXEC7OG5Gs2472jMKDzJCLaLp3BX5reMM= 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=IuqDUir6; arc=none smtp.client-ip=209.85.221.45 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="IuqDUir6" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-37d538fe5f2so783434f8f.2 for ; Fri, 15 Nov 2024 13:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706405; x=1732311205; 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=P3X75yM8kxs9FzTe5Hfb8Yjb7xDP3WlYO8y+5i2/eDs=; b=IuqDUir6Dhd5/QRDs/UwQjg1krcxqQytMVl1vHc0Iq3KTn3moFFtSwyExRvKVDfxcE uZmvkrF7hLz1mQF1pIYJTD5Tr5MY4gr5Y2GwIuhiPxCDMkIcwmuJaHntWv0BP1xKAyo6 epo/TeR9SVncxTRsEBFh6m38Dnjy12OTETLhrqko0joMcmuCL3vEK4+yKJXugUeKhqQk Fu7s/FTby/jGmahHS1z45o/lDIZ9KIBB4QSID2sIPl/dq8O/OFdOcDI5mz9oo7Di2CeC lrLbF1ZF1ecCvNREEytsJR5/zBaX6eyLn4OjMOWzr+ZH6iNp3suZ2GQ8USeQKMtUJwHu yU2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706405; x=1732311205; 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=P3X75yM8kxs9FzTe5Hfb8Yjb7xDP3WlYO8y+5i2/eDs=; b=mtwNH4VTvezrB+hMFNYajfux7BAkF2D/YUwSVPUPPzGX2f74KjBQdIzUXhLeoNGxv+ 4NPD7AIQf+K84rPOe4qYc9Ojj+Sr5jzKiaOX26/aT4TukN2VBhXS4BM866NAhDtbt5zl JFqrXEsKji8r/jQ6+HEPkxQvHi4WSuLVA3zHoHLC8nuzVaCULqQw9uhM8UXiMzXThdXA EkkYoSkjkylpjvP1dENJ0w8s545EkAqNwqiErPtA0osX9G2OqDvbUXJ+1fibm5An5XoB WljRH2e2JI1eVCknSfRgim+uEarbHlg34aU0qStWmPQfvwP+QPAPJ3znHN8rPgyCpETC eUmA== X-Gm-Message-State: AOJu0YxBHdIvK69/HpGu72L4HTIZHOorl8mNlCOAEGkHWJdcQjev3K5n +hWgRgUXfUOAZwDV7d82WA7Lqeit6XqZVSUiRihZ9duWmGLiVDjk66Iy4Q== X-Google-Smtp-Source: AGHT+IHBFyYP+1EOPEwjyGQhEjNqxBLkwGNE5Ofo8/vklaBPe2b/aaaB1j08kHyRWP5oXqhtJhRrvA== X-Received: by 2002:a05:6000:2c6:b0:382:5af:e99a with SMTP id ffacd0b85a97d-38225a9212emr3132999f8f.42.1731706405043; Fri, 15 Nov 2024 13:33:25 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:21 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 6/8] tests: add region testing Date: Fri, 15 Nov 2024 21:33:53 +0000 Message-ID: <806601a1247373694c6336f229c9b7ca168fca65.1731705935.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 | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/test/reg-wait.c b/test/reg-wait.c index 5f5a62a..13f6d51 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -178,6 +178,134 @@ err: return ret; } +static int test_try_register_region(struct io_uring_mem_region_reg *pr, + bool disabled, bool reenable) +{ + 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) { + fprintf(stderr, "ring setup failed: %d\n", ret); + return 1; + } + + if (reenable) { + ret = io_uring_enable_rings(&ring); + if (ret) { + fprintf(stderr, "io_uring_enable_rings failure %i\n", ret); + return 1; + } + } + + ret = io_uring_register_region(&ring, pr); + io_uring_queue_exit(&ring); + return ret; +} + +static int test_regions(void) +{ + struct io_uring_region_desc rd = {}; + struct io_uring_mem_region_reg mr = {}; + void *buffer; + int ret; + + buffer = aligned_alloc(4096, 4096 * 4); + if (!buffer) { + fprintf(stderr, "allocation failed\n"); + return T_EXIT_FAIL; + } + + rd.user_addr = (__u64)(unsigned long)buffer; + rd.size = 4096; + rd.flags = IORING_MEM_REGION_TYPE_USER; + + mr.region_uptr = (__u64)(unsigned long)&rd; + mr.flags = IORING_MEM_REGION_REG_WAIT_ARG; + + ret = test_try_register_region(&mr, true, false); + 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); + return T_EXIT_FAIL; + } + + ret = test_try_register_region(&mr, true, true); + if (ret != -EINVAL) { + fprintf(stderr, "test_try_register_region(true, true) fail %i\n", ret); + return T_EXIT_FAIL; + } + + rd.size = 4096 * 4; + ret = test_try_register_region(&mr, true, false); + if (ret) { + fprintf(stderr, "test_try_register_region() 16KB fail %i\n", ret); + return T_EXIT_FAIL; + } + rd.size = 4096; + + rd.user_addr = 0; + ret = test_try_register_region(&mr, true, false); + if (ret != -EFAULT) { + fprintf(stderr, "test_try_register_region() null uptr fail %i\n", ret); + return T_EXIT_FAIL; + } + rd.user_addr = (__u64)(unsigned long)buffer; + + rd.flags = 0; + ret = test_try_register_region(&mr, true, false); + if (!ret) { + fprintf(stderr, "test_try_register_region() kernel alloc with uptr fail %i\n", ret); + return T_EXIT_FAIL; + } + rd.flags = IORING_MEM_REGION_TYPE_USER; + + rd.size = 0; + ret = test_try_register_region(&mr, true, false); + if (!ret) { + fprintf(stderr, "test_try_register_region() 0-size fail %i\n", ret); + return T_EXIT_FAIL; + } + rd.size = 4096; + + mr.region_uptr = 0; + ret = test_try_register_region(&mr, true, false); + if (!ret) { + fprintf(stderr, "test_try_register_region() NULL region %i\n", ret); + return T_EXIT_FAIL; + } + mr.region_uptr = (__u64)(unsigned long)&rd; + + rd.user_addr += 16; + ret = test_try_register_region(&mr, true, false); + 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); + if (!ret) { + fprintf(stderr, "test_try_register_region() bogus uptr %i\n", ret); + return T_EXIT_FAIL; + } + rd.user_addr = (__u64)(unsigned long)buffer; + + free(buffer); + return 0; +} + int main(int argc, char *argv[]) { int ret; @@ -191,6 +319,15 @@ int main(int argc, char *argv[]) return 1; } + ret = test_regions(); + if (ret == T_EXIT_SKIP) { + printf("regions are not supported, skip\n"); + return 0; + } else if (ret) { + fprintf(stderr, "test_region failed\n"); + return 1; + } + ret = test_wait_arg(); if (ret == T_EXIT_FAIL) { fprintf(stderr, "test_wait_arg failed\n"); From patchwork Fri Nov 15 21:33:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877336 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.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 190F31FDFB4 for ; Fri, 15 Nov 2024 21:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706411; cv=none; b=EPmtyrhO2/DUrIZ5E0wIqonrzBALQMDgji52iLPG+ARCIx1bEUJjbP3CBnVAoR8ZzdGThYBkiZLdy5QHA3eWQWud6oDMTGpf9dRO47Wx1j4YSGPJTWTe3eo+MbsGpfEyKdTuk8vE8bhA+iiHbYD3/7RSX4lY5SSxtTSqsoXbLyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706411; c=relaxed/simple; bh=8lkh7IXVW2x74zu8FZ+tdrwsQfn2yNTgfXQ6r9BOhrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kuVWr+YAmFxlFfMX2fM16rQgnvsMgt65kc3GPYk9awoz2/4gL0kh75I49coXdw6ctx5YDB1keTmzxSzwWdXNk9YFaKF8a38045EqxzMCPpgsOwCSmSI7cTfkpRdVqs8fvdCypeG9bp5XDyRmMNiA7a/1ZbIP0Omxang3yQCbYIQ= 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=FOZDz4qE; arc=none smtp.client-ip=209.85.221.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="FOZDz4qE" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3821e0b2262so20732f8f.1 for ; Fri, 15 Nov 2024 13:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706407; x=1732311207; 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=11e7qU4kQ61tSaPvLT2OJZBarIpf9G++UX8GnZvzR20=; b=FOZDz4qEljgjVyRe71+OPcPsGRUqmBKDOWp9TAYUOC06wGZ+WW2i3Z07lIzmY7NGFl 0Z/f3qp/ZEhfD3hiO2EfaUlWLP1HT66JGxueI04vu6KgdHl8stm5XKZlqAXeiQbRACZ1 zJO4f94gIBOu8KS1e8q+6p5bMemIcje16tgUVKS0jJEvLvG9tjBnsPQ08P5LkuNEX/FZ H6UgsO1wo9BBw6gnRdhWiFVld5ozrqtfK8QrnraZnc5VnVr0uJ/qGmzvUbvLcxSn3E/c 4FIFNar3A0ekptlOtvg8fd4tDsMJt1dtIHZHdVLMNlYNHgQyGRUndKBrTL25r48LeEKZ Rjjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706407; x=1732311207; 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=11e7qU4kQ61tSaPvLT2OJZBarIpf9G++UX8GnZvzR20=; b=tDuNIKjwNNJGwt4bJ7SAdbaZjw7EpFMhmZkYKtg8c77dlqR5JLoM6IhHMXEDpUw2/e Oj4Up86BEX8wYZR3coy1BLmW085DQf9N/EOzM9jrm1JcOypehPDCjL8vZC0+/1fx/46a MTRUaSUCqU4iKf29cBP536zQYz58RT8QkO7d7N9yYCTB7OhPbnfclbXoItM7gtBZODu2 oLoMicX8SXoF1SyAP9BA7r+OuhGxXXxwv6BYk87DYafy2J6aMDDC9fuWyFvhESezWjRS 2Ct+hDndUlpsBNkrDEnp8vQfJfJpKY6c5V0yUM0WGqxvJIyu7qLpLaUzpKF9m1ugymIT 2wUQ== X-Gm-Message-State: AOJu0YzbGq01DizG926lEzngFdgizNQ/y2bZt7Y8PcK4ySw4Iln/4E12 CtLx/qhmtTK97iIfgc004Rqn3603dewuls9o8GCZSDH42bSb7CHND6raEw== X-Google-Smtp-Source: AGHT+IFgR55kj/tQU1Aar9Rk9S9DcaKXaEHcuzteUUaAolJs066MvfcI0C1RnoAvvLTJ0w7BU+iRnQ== X-Received: by 2002:a05:6000:a11:b0:37c:d53a:6132 with SMTP id ffacd0b85a97d-38225a8589cmr3544067f8f.31.1731706406625; Fri, 15 Nov 2024 13:33:26 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:25 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 7/8] tests: test arbitrary offset reg waits Date: Fri, 15 Nov 2024 21:33:54 +0000 Message-ID: <576e9ca1ad794c648af9754ef1c7f4ba5cbed1ab.1731705935.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 The exported io_uring API operates with wait index, which is safer, but the kernel takes byte offsets. Add a local raw syscall helper passing byte offsets and add edge testing of more edge cases. Signed-off-by: Pavel Begunkov --- test/reg-wait.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/reg-wait.c b/test/reg-wait.c index 13f6d51..aef4546 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -13,6 +13,18 @@ #include "liburing.h" #include "helpers.h" #include "test.h" +#include "../src/syscall.h" + +static int test_wait_reg_offset(struct io_uring *ring, + unsigned wait_nr, unsigned long offset) +{ + return __sys_io_uring_enter2(ring->ring_fd, 0, wait_nr, + IORING_ENTER_GETEVENTS | + IORING_ENTER_EXT_ARG | + IORING_ENTER_EXT_ARG_REG, + (void *)offset, + sizeof(struct io_uring_reg_wait)); +} static int page_size; static struct io_uring_reg_wait *reg; @@ -55,6 +67,7 @@ static int test_offsets(struct io_uring *ring) struct io_uring_cqe *cqe; int max_index = page_size / sizeof(struct io_uring_reg_wait); struct io_uring_reg_wait *rw; + unsigned long offset; int ret; rw = reg + max_index; @@ -80,6 +93,36 @@ static int test_offsets(struct io_uring *ring) return T_EXIT_FAIL; } + offset = 0UL - sizeof(long); + ret = test_wait_reg_offset(ring, 1, offset); + if (ret != -EFAULT) { + fprintf(stderr, "overflow offset failed: %d\n", ret); + return T_EXIT_FAIL; + } + + offset = 4096 - 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; + + ret = test_wait_reg_offset(ring, 1, offset); + if (ret != -EFAULT) { + fprintf(stderr, "OOB offset failed: %d\n", ret); + return T_EXIT_FAIL; + } + + 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; + + /* undefined behaviour, check the kernel doesn't crash */ + (void)test_wait_reg_offset(ring, 1, offset); + return 0; } From patchwork Fri Nov 15 21:33:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 13877337 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 154D91FDF92 for ; Fri, 15 Nov 2024 21:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706412; cv=none; b=SS2NIN/CLkvB/gsXfeTwdB6eImK5g6V1OheSZfE2K4pCUdccpTw746gPxbeY0OpdYVfpnCt7b9IqXwSL1CZLv036B7yuwtBGxw4+NcQDVHbTO7LoaQR1IPTztp9zB9DilRXjuSzoHx8NXQMvY5TsHg3H22d3yER5hv+W8y0dPa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731706412; c=relaxed/simple; bh=NeFPRkwmvOW6soOcqIGT9FpG7YZZwdysSVuoqA9P5z8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VZ06kQCIJYNAM6yoKoETffe5ttNeg7/6G7h4ujLbU6XA9N0NYNjg8dXYkINP4rzTldY8R22zpwaWljUafX2Bdew5TpWd2KvwflQx32vrRppv9h01hZFCVAJxNAYZastGHn+ZmztlRhmuwEPqp2A7IJ/hMx90x2QmN4untqAGloo= 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=Qk2sRBUJ; arc=none smtp.client-ip=209.85.221.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="Qk2sRBUJ" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-37ed3bd6114so18849f8f.2 for ; Fri, 15 Nov 2024 13:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731706409; x=1732311209; 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=Q4sux6pWyRAdlHsTgCCZRgw8Yi6YXBTsftdjdD/Maio=; b=Qk2sRBUJZCJ88o5WC+eOHkekgF1IRT/ay957FUM8X82TTEnTmbFGnMkfMjSrh3PSLy obuE7HG4fGlzVtngtVcxV7F3Rgz4UVlZ3qu+JwL7YdmqcKqxeLjB+c9V0AfHWgkACYW9 16Z5uGg2SnQT8sWRwyrsoGSxLFDmQica/RLiSwHgNFKJvv1IbtYf+YNPtRZcgUTndgQ+ y3kDyB1dligbHPC6k2MPanCxl8/d5YdAO+jrKvX0vOVZIn0ILer5mTBbMJE6vAI2K6S0 5vobZ1bB670RzZ5BRQCI0tuzEJbJAFQRBg2EgvcwgXMB/AN6rHIIVQzp9z+blYgPQBBI 5USw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731706409; x=1732311209; 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=Q4sux6pWyRAdlHsTgCCZRgw8Yi6YXBTsftdjdD/Maio=; b=m4aLmaCm/xC9EiBWug2030n9bS3wb01xujCQWBY96I3oRd0oh6jbYB18MEl0DBqrre pVd2ZDgQ4vf2uU3Ac2y2NdbDS57Rxx3H5nIcA1av95mYDq/0XAVQb5wRHkcbzOFCxhLv Illzwghf6x1YOtbL4gWc3F40m5T8IVjynct3bq20Tz2HB8/uuhJUb7OTz7FFJlCFa5Fw yjerTh7iuQwNLGraho2Vj4cx53BYadaFPld3yWNynofyvOppHGbTu7ogOa8urbo9sJl6 FwYVOxGsj5pWdw6NnEFwVFohRopUbPVBpHFn/t9+v28u1mrKxU88NIopPA4NnaKWQHkB Qwag== X-Gm-Message-State: AOJu0Yw1qw+IaoBrWmvTG7ih5DEXStMBAXDJO/2Bk9y+QZRysTgUlE3k oigDOL5CwClpQ8OooxItgs0HUWclu/t6ZUOcKdpbZTnqFsBmN6a1e6qvVA== X-Google-Smtp-Source: AGHT+IFPVKoaLc/qoNtWrBqMcwqO+QcyAsEAYrKKPJ0914eDVkvMvgGRosZj8FigQrvrux8ns/Q+pg== X-Received: by 2002:a05:6000:2c6:b0:381:ebf4:b57a with SMTP id ffacd0b85a97d-38225a925e5mr3723229f8f.44.1731706409049; Fri, 15 Nov 2024 13:33:29 -0800 (PST) Received: from 127.0.0.1localhost ([148.252.132.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-382247849b0sm3397258f8f.97.2024.11.15.13.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 13:33:27 -0800 (PST) From: Pavel Begunkov To: io-uring@vger.kernel.org Cc: asml.silence@gmail.com Subject: [PATCH liburing 8/8] Remove leftovers of old reg-wait registration api Date: Fri, 15 Nov 2024 21:33:55 +0000 Message-ID: <3c0b35b519e0ee52c4fe8ed5aa1c2498a55470e9.1731705935.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 --- src/include/liburing.h | 3 --- src/liburing-ffi.map | 2 -- src/liburing.map | 2 -- src/setup.c | 10 ---------- 4 files changed, 17 deletions(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index 81ffe6e..627fc47 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -289,9 +289,6 @@ int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg, */ int io_uring_register_region(struct io_uring *ring, struct io_uring_mem_region_reg *reg); -struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring, - unsigned nentries, int *err); -void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries); /* * Mapped buffer ring alloc/register + unregister/free helpers diff --git a/src/liburing-ffi.map b/src/liburing-ffi.map index 117a46a..9af1fb9 100644 --- a/src/liburing-ffi.map +++ b/src/liburing-ffi.map @@ -221,8 +221,6 @@ LIBURING_2.9 { io_uring_resize_rings; io_uring_register_wait_reg; io_uring_submit_and_wait_reg; - io_uring_free_reg_wait; - io_uring_setup_reg_wait; io_uring_clone_buffers_offset; io_uring_register_region; } LIBURING_2.8; diff --git a/src/liburing.map b/src/liburing.map index 46edbc9..9f7b211 100644 --- a/src/liburing.map +++ b/src/liburing.map @@ -108,8 +108,6 @@ LIBURING_2.9 { io_uring_resize_rings; io_uring_register_wait_reg; io_uring_submit_and_wait_reg; - io_uring_free_reg_wait; - io_uring_setup_reg_wait; io_uring_clone_buffers_offset; io_uring_register_region; } LIBURING_2.8; diff --git a/src/setup.c b/src/setup.c index 7c0cfab..d4694f5 100644 --- a/src/setup.c +++ b/src/setup.c @@ -686,13 +686,3 @@ int io_uring_free_buf_ring(struct io_uring *ring, struct io_uring_buf_ring *br, __sys_munmap(br, nentries * sizeof(struct io_uring_buf)); return 0; } - -void io_uring_free_reg_wait(struct io_uring_reg_wait *reg, unsigned nentries) -{ -} - -struct io_uring_reg_wait *io_uring_setup_reg_wait(struct io_uring *ring, - unsigned nentries, int *err) -{ - return NULL; -}