From patchwork Thu Feb 20 14:34:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13984081 Received: from server-vie001.gnuweeb.org (server-vie001.gnuweeb.org [89.58.62.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE9F51FC7F1; Thu, 20 Feb 2025 14:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.58.62.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062374; cv=none; b=QNKrfZj3id0YyJBU0PryTeBoKseigipqwkQbES4B9pXV2+mTvkRSRieLbfW880Un7ojG1y0rP5j0CCZ67xeHwl51JQLAx4ABQO6+BKHnIsB45pz2PGONckR2LZkAQXImKghBdv3ISJLMzc0LRmJKQ7to73gDU3VD/BjbfeoSB1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062374; c=relaxed/simple; bh=NXzmlJbcyvCFApkcvBVHzM26nc8bwg9PTyW6PRPeox4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F4CUAKc1aZPgV6vRNkbBSVhzAdaatng3ASJc+0uJBAKxSGrMARoUmbn9x7zM0OPitE4XEfutO2vZs08YxC6E2N0nJkj0CprkcLeXz1hmlZ6K8wXlzY9qushvzKOfXFOBSjhhByquuu9AjB/WjiHVLrJ9p1Ut+j2k9270JqygMs4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org; spf=pass smtp.mailfrom=gnuweeb.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b=rl6CRDA9; arc=none smtp.client-ip=89.58.62.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b="rl6CRDA9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1740062095; bh=NXzmlJbcyvCFApkcvBVHzM26nc8bwg9PTyW6PRPeox4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=rl6CRDA9zzbIVO5XlJXKxJ9ifgO0vgYJmlRFNbINzNSaIK6Nwi3wawzFZ6cuRiqCs ToclivVe6TTC0Oqfu+TTQe1BUPH8kB6SymxNgc+osWFh1ktrMYyX7JQjfzBHw1pmcW zb8wuelI130vzcbeDuQVFRfTBcCRawrSPnNax5YlOPy6JdRHKXYZ0zDo7Dl5/ISwOu jonfT+8200Zw5Eopq5ztwSWKkHqESFUIPK43gnJ0IcOg2JVKovAhJwBfJIPzeDZlVS i959gG2ORFC1JfzBnFA9Zj5GYfugmmAlX/8aP299O9se8/W973vRDAZH34QL2FrTyW OrMViV/d0EmtA== Received: from integral2.. (unknown [182.253.126.96]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id F1D3720744A4; Thu, 20 Feb 2025 14:34:53 +0000 (UTC) From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v1 1/3] liburing.h: Remove redundant double negation X-Gw-Bpl: wU/cy49Bu1yAPm0bW2qiliFUIEVf+EkEatAboK6pk2H2LSy2bfWlPAiP3YIeQ5aElNkQEhTV9Q== Date: Thu, 20 Feb 2025 21:34:20 +0700 Message-Id: <20250220143422.3597245-2-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> References: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The `enabled` variable is already a boolean, so applying the negation operator twice has no effect. Remove it to improves clarity and simplicity. Signed-off-by: Ammar Faizi --- src/include/liburing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index 6393599cb3bf..b2d76f3224e2 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -1410,25 +1410,25 @@ IOURINGINLINE bool io_uring_cq_eventfd_enabled(const struct io_uring *ring) return !(*ring->cq.kflags & IORING_CQ_EVENTFD_DISABLED); } /* * Toggle eventfd notification on or off, if an eventfd is registered with * the ring. */ IOURINGINLINE int io_uring_cq_eventfd_toggle(struct io_uring *ring, bool enabled) { uint32_t flags; - if (!!enabled == io_uring_cq_eventfd_enabled(ring)) + if (enabled == io_uring_cq_eventfd_enabled(ring)) return 0; if (!ring->cq.kflags) return -EOPNOTSUPP; flags = *ring->cq.kflags; if (enabled) flags &= ~IORING_CQ_EVENTFD_DISABLED; else flags |= IORING_CQ_EVENTFD_DISABLED; From patchwork Thu Feb 20 14:34:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13984082 Received: from server-vie001.gnuweeb.org (server-vie001.gnuweeb.org [89.58.62.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE9231FC0E4; Thu, 20 Feb 2025 14:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.58.62.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062374; cv=none; b=bzzw8UBV02+snS5JLuSP9tZr73+pr0Amcj6X1XZEWyucrVckzTrCYSlShPeVbO5NLZljtpTk3khjfMKFF6YT93agVE8MTw5rKBwbhOxHqGYO8vP7uFl6uYVWzYXhLsumll3dTJTIbmdOis9rgGvPwMZiHa4KF6ZM6itSZNi6Q2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062374; c=relaxed/simple; bh=LbQkwTDIu9g+6v+t8LjVmjJshSoNf7WjKV5AFx6vUuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ClWqQsU5BTXRHMaV0PHg6b7XuxdSQD8R3HaocMsCYZDr/B4NKBUQCj9M/EXRqTdZlID2eKjewZa1GnNQJusTjvrmKTnqi5dkP5elzXUiWtvnZ4//yaLTroX1qYFmr/lHRHaen/0oYL7r4+TDKfm+5ui4AT8JjYkLM38ogi+wVLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org; spf=pass smtp.mailfrom=gnuweeb.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b=LPtvd8tl; arc=none smtp.client-ip=89.58.62.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b="LPtvd8tl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1740062098; bh=LbQkwTDIu9g+6v+t8LjVmjJshSoNf7WjKV5AFx6vUuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=LPtvd8tlVb2viqcehzfDj2Z5F19wvvm861uzy2+3IEa644XN3neHmVWYcCH5+pIOg ByT7QcKSE90hNTDJIivsuiXH+vL1TrdazRsLrf7+7P8H2D645yb0/JNkA2lDdzJ1XV OMPzyhOuojCRByx6+0TlCQMg0u6pI5O0HFtReDFHzdC4oZYS4mPRklwWJwuSAB71v7 nhmd5mvwOuFpITeGmkJzAp6ie2DtUkkyQPoQZ7A/yyCemKSX27Rs76hQfnQqIMm4cD M1odogMBwWoEYIA9XQZ5MVdutgt/XqENO4kaehxRfusxpmxxRNmsl+q+MgS5/wCb+8 yJAUK5QkE8OPg== Received: from integral2.. (unknown [182.253.126.96]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id DF02A20744A5; Thu, 20 Feb 2025 14:34:56 +0000 (UTC) From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v1 2/3] liburing.h: Explain the history of `io_uring_get_sqe()` X-Gw-Bpl: wU/cy49Bu1yAPm0bW2qiliFUIEVf+EkEatAboK6pk2H2LSy2bfWlPAiP3YIeQ5aElNkQEhTV9Q== Date: Thu, 20 Feb 2025 21:34:21 +0700 Message-Id: <20250220143422.3597245-3-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> References: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a comment for `io_uring_get_sqe()` to provide historical context and prevent misunderstandings, as seen in Pull Request 1336. Link: https://github.com/axboe/liburing/pull/1336 Signed-off-by: Ammar Faizi --- src/include/liburing.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/include/liburing.h b/src/include/liburing.h index b2d76f3224e2..98419e378f72 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -1622,24 +1622,43 @@ IOURINGINLINE int io_uring_buf_ring_available(struct io_uring *ring, unsigned short bgid) { uint16_t head; int ret; ret = io_uring_buf_ring_head(ring, bgid, &head); if (ret) return ret; return (uint16_t) (br->tail - head); } +/* + * As of liburing-2.2, io_uring_get_sqe() has been converted into a + * "static inline" function. However, this change breaks seamless + * updates of liburing.so, as applications would need to be recompiled. + * To ensure backward compatibility, liburing keeps the original + * io_uring_get_sqe() symbol available in the shared library. + * + * To accomplish this, io_uring_get_sqe() is defined as a non-static + * inline function when LIBURING_INTERNAL is set, which only applies + * during liburing.so builds. + * + * This strategy ensures new users adopt the "static inline" version + * while preserving compatibility for old applications linked against + * the shared library. + * + * Relevant commits: + * 8be8af4afcb4 ("queue: provide io_uring_get_sqe() symbol again") + * 52dcdbba35c8 ("src/queue: protect io_uring_get_sqe() with LIBURING_INTERNAL") + */ #ifndef LIBURING_INTERNAL IOURINGINLINE struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring) { return _io_uring_get_sqe(ring); } #else struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring); #endif ssize_t io_uring_mlock_size(unsigned entries, unsigned flags); ssize_t io_uring_mlock_size_params(unsigned entries, struct io_uring_params *p); From patchwork Thu Feb 20 14:34:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ammar Faizi X-Patchwork-Id: 13984077 Received: from server-vie001.gnuweeb.org (server-vie001.gnuweeb.org [89.58.62.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D6581D5AD4; Thu, 20 Feb 2025 14:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.58.62.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062105; cv=none; b=fHsRTbdd/gWBGlZiW3gCsRvp90fU0+JTKS0TSBXvciNWi+somUVDg6XJ8EbhNkjVVjmREeD+1/dlcioA+EfgjN4NE2oMJzxTZxa6QSbEzDSk7SRq7IngNQY7qFYIOkP1b7QdCSN2SxxCTPmc12WghrJ7GY2Yi0Bdcs50TrT5H80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740062105; c=relaxed/simple; bh=xxoB+UIOPvZk4BVlBN52bLxBYkRLA3Dg2MLLG17vDCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ngz0MDM+sMIDKS4d6Bu7BhaMEucDrwXBVb6/ZBVyLexk+87KrweSsFC7IJ8nw2+eeJrtsqV9kn21TpyDjIL9ZKcRm2Di+YkbkXGMVcefGzYYn8mDqJC+aD8ipYiNr0yNKt/sfDqII1ykzlfjL/K5WAr5ccHW0Ljd6gBvZrbZtS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org; spf=pass smtp.mailfrom=gnuweeb.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b=IgLFjm+4; arc=none smtp.client-ip=89.58.62.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gnuweeb.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gnuweeb.org header.i=@gnuweeb.org header.b="IgLFjm+4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1740062101; bh=xxoB+UIOPvZk4BVlBN52bLxBYkRLA3Dg2MLLG17vDCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=IgLFjm+4B5/jg7TpCYIrAhgnHeU9KYvsGApQEOzTGIK+JJh/50NFZiosrQ8ja1nHj RglqIjevgcqDo8TNjzQEUgFLZKsJZlCi9AxQuXikFa/BUuCdZDWS7aRmP5qFZts9EB uvX64oOvBSisPg5HlVhMxD+miPHftldtwfzLD62Gf4nnuMUptuSXx1nAuHNGOICjZr wvnAQMxqGY8dfXoHkJpArWr9juJKsdRLKZRfO+YZcoZxht/5tCZlfxKo7D+Wny3rbO oQTc3LQx66we3Lksx9wzRjVa2X0sqpwy22LXbxY5kScO+8A5RoE+5MRoQBjfUCZA2v MGkS3Q1TvvPgA== Received: from integral2.. (unknown [182.253.126.96]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 59E8320744A7; Thu, 20 Feb 2025 14:34:59 +0000 (UTC) From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , io-uring Mailing List , Linux Kernel Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v1 3/3] Fix missing `aligned_alloc()` on some Android devices X-Gw-Bpl: wU/cy49Bu1yAPm0bW2qiliFUIEVf+EkEatAboK6pk2H2LSy2bfWlPAiP3YIeQ5aElNkQEhTV9Q== Date: Thu, 20 Feb 2025 21:34:22 +0700 Message-Id: <20250220143422.3597245-4-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> References: <20250220143422.3597245-1-ammarfaizi2@gnuweeb.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some Android versions lack `aligned_alloc()` in ``. Compiling on Termux 0.118.0 yields this error: ``` cmd-discard.c:383:11: warning: call to undeclared library function \ 'aligned_alloc' with type 'void *(unsigned long, unsigned long)'; ISO \ C99 and later do not support implicit function declarations \ [-Wimplicit-function-declaration] buffer = aligned_alloc(lba_size, lba_size); ^ ``` To avoid making large changes in tests, define a helper function that wraps `posix_memalign()` as our own `aligned_alloc()`. Just another day of working around platform quirks. Co-authored-by: Alviro Iskandar Setiawan Signed-off-by: Alviro Iskandar Setiawan Signed-off-by: Ammar Faizi --- examples/helpers.c | 10 ++++++++++ examples/helpers.h | 7 +++++++ examples/reg-wait.c | 2 ++ test/helpers.c | 10 ++++++++++ test/helpers.h | 8 ++++++++ 5 files changed, 37 insertions(+) diff --git a/examples/helpers.c b/examples/helpers.c index b70ce7c1f314..59b31ecb4aeb 100644 --- a/examples/helpers.c +++ b/examples/helpers.c @@ -51,12 +51,22 @@ int setup_listening_socket(int port, int ipv6) if (ret < 0) { perror("bind()"); return -1; } if (listen(fd, 1024) < 0) { perror("listen()"); return -1; } return fd; } + +void *aligned_alloc(size_t alignment, size_t size) +{ + void *ret; + + if (posix_memalign(&ret, alignment, size)) + return NULL; + + return ret; +} diff --git a/examples/helpers.h b/examples/helpers.h index 9b1cf34f9b0d..d73ee4a5bc1a 100644 --- a/examples/helpers.h +++ b/examples/helpers.h @@ -1,7 +1,14 @@ /* SPDX-License-Identifier: MIT */ #ifndef LIBURING_EX_HELPERS_H #define LIBURING_EX_HELPERS_H int setup_listening_socket(int port, int ipv6); +/* + * Some Android versions lack aligned_alloc in stdlib.h. + * To avoid making large changes in tests, define a helper + * function that wraps posix_memalign as our own aligned_alloc. + */ +void *aligned_alloc(size_t alignment, size_t size); + #endif diff --git a/examples/reg-wait.c b/examples/reg-wait.c index 0e119aaf4f03..ff61b8d10387 100644 --- a/examples/reg-wait.c +++ b/examples/reg-wait.c @@ -4,24 +4,26 @@ * * (C) 2024 Jens Axboe */ #include #include #include #include #include #include #include #include +#include "helpers.h" + static unsigned long long mtime_since(const struct timeval *s, const struct timeval *e) { long long sec, usec; sec = e->tv_sec - s->tv_sec; usec = (e->tv_usec - s->tv_usec); if (sec > 0 && usec < 0) { sec--; usec += 1000000; } diff --git a/test/helpers.c b/test/helpers.c index e84aaa7aee15..0718691174de 100644 --- a/test/helpers.c +++ b/test/helpers.c @@ -354,12 +354,22 @@ unsigned long long utime_since(const struct timeval *s, const struct timeval *e) sec *= 1000000; return sec + usec; } unsigned long long utime_since_now(struct timeval *tv) { struct timeval end; gettimeofday(&end, NULL); return utime_since(tv, &end); } + +void *aligned_alloc(size_t alignment, size_t size) +{ + void *ret; + + if (posix_memalign(&ret, alignment, size)) + return NULL; + + return ret; +} diff --git a/test/helpers.h b/test/helpers.h index 9e1cdf5ec05c..d0294eba63e4 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -4,36 +4,44 @@ */ #ifndef LIBURING_HELPERS_H #define LIBURING_HELPERS_H #ifdef __cplusplus extern "C" { #endif #include "liburing.h" #include "../src/setup.h" #include #include +#include enum t_setup_ret { T_SETUP_OK = 0, T_SETUP_SKIP, }; enum t_test_result { T_EXIT_PASS = 0, T_EXIT_FAIL = 1, T_EXIT_SKIP = 77, }; +/* + * Some Android versions lack aligned_alloc in stdlib.h. + * To avoid making large changes in tests, define a helper + * function that wraps posix_memalign as our own aligned_alloc. + */ +void *aligned_alloc(size_t alignment, size_t size); + /* * Helper for binding socket to an ephemeral port. * The port number to be bound is returned in @addr->sin_port. */ int t_bind_ephemeral_port(int fd, struct sockaddr_in *addr); /* * Helper for allocating memory in tests. */ void *t_malloc(size_t size);