From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.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 1E9E02D8399 for ; Fri, 20 Mar 2026 05:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773984259; cv=none; b=qrtUYWkIXdbEYmv+IhASOAJdraPmRuRqyVizRqDqTWDozVl2r7smBdFinmxwcLaK1k+E9/D8bRWt3QlQaTCp3mESUn3OKWOAbVxzFmk6hq3tZF21k62YpHT8tr3BEZvoO9nMdxZU4OQFTSW9TTtK2V3AZPD/JIXH2ZuYhkRPjUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773984259; c=relaxed/simple; bh=Ah4XhcWdq3LFfRD+iK/PMR58q9yX285hlNdGRu7M0sc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=DzmFKd8biE/n9l2ecGgR3fBdHRGX9D9ZKoPPGxR9uIKgn+wc7Uk2GPQvzj7bv1jqumWHFkSJ3QlImpgTh83U6aiPlAmH+0oqn9G/FNXKJUHnolBU6vhUKKd2Y9ecmMMX9TC+4xOO0kUQYEg30nQN1nx7smucH0jjmklT8O/SuCs= 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=bg237aBR; arc=none smtp.client-ip=209.85.216.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="bg237aBR" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-35b9d29480aso227752a91.1 for ; Thu, 19 Mar 2026 22:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773984257; x=1774589057; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nAjfJJMhGZqUIYBG61Zr1CD60OsC4X03KbvQMqZWBsg=; b=bg237aBRfcSYZq5xOhdkY0NWGlB+ItVyVIVadiD18A0enmKpwAlFKFBok0TQfel7Mg Yj26x2WxFpdB7PZmcw2mghK5hw7d5nMjPpqn0wL8K8L6zeFRUA4EDfPW85Y+zjHCkV7m V6YD1AZw3DWRMjhf8/QUCPdwXx4qks1XVJSoSsiUBHEnMm9fPYCaMf3lYu8aavk1sDSv 5btJLfKMiqvNbD6uk3FEy3IrNLNI3p6qviwuFh/wHZHFlZnMLVYxlbjujec/G4SyQ8AU hI/s8dmzgLg9BK5n1Y2d4e9g02s0kNB6+STDTE4rxpTWhSiJo54JIvPjaTv0KWDuCKYh jtiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773984257; x=1774589057; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nAjfJJMhGZqUIYBG61Zr1CD60OsC4X03KbvQMqZWBsg=; b=ANhleGMk67H9Hrm+/LcrxCLcN/eIAkF6puqMT45fRFWen0oNH4J6BZGtbxHZBNNG3/ kixd6tB02F5IBM0W0sATF5/nXAQnMgaBqAqUGVgnzzw0YkV8wDDFaez5S1EyGI23aW2x hXiUUsKjvFwi9U2hWx74zUlvgAiveGgL7ObKKWTbcvUjRUM6eGDN5NPkjgn3nrIjwdSn z1G6ViLtmJE3V85/bjuoFhtwBrM5PQRwFrxdVmuCNMRX7b8vlBfkB9c/NbM+iIeLpqLI TQnBER/sn7UXFUDN3NaDdzNlFl+JfXT/csxYiJgaqaVbDRDbsZUGeN4CvIwkN/CVKnrs I2rw== X-Forwarded-Encrypted: i=1; AJvYcCWrpdaHrOno9+Q56MyPZdEXQ8EFRAoTYlsCiM7BiFVtxDzPyZRC91/B+rfyKv3EU/GsAuOjc0FgW2qDwvU=@vger.kernel.org X-Gm-Message-State: AOJu0YwvTdUOKOTQSL71CqQzTZP8e2hOrNDOUJA7yAMIORCA0hon0s0a cJCOtYfalfBgmseCDGhgzxDX7Gar8LMuGC88EwL4mwucFIw4gUXZp1bA X-Gm-Gg: ATEYQzxHr2jSrzQTeEi71HDg5nKoWv+Eq/b5e2IKZ9daXgrIXtycePS6snWVLDJRrgA POCWawStfrq+tKZ++5NVGcUXu9afIJddIyD2bAC9RXLdvKayVQxjTnm9kgfx8kMVZoT8slJvxAn EqFz2Lw1mtIqmMnDwihV0JcD1xwke033EbWmou/MrxC+RscKm0UxGW8WLxAHEFihDI+zE4zbhMa ygCpamFnFJpaxlNd2MfLtJH1EuSmcNjkJp2v+nMD97ZC5HaIHRxYL1X//QnLC1XmqTZAfLn41I7 yi2OmsjdT9nOHJqx84AXoN6Wzhn0KRolDhNpU45S4KVPZre/O5fTMK7ui+mVO5wRKMEbw1NrR4E loX5+ViomA8fACw21Hr92JMPtokXDcTGoXnIvplyNJbn8quGAsd+lik3AHwoBjTKuatNaQWubSt MPe9yelrR+YkB65wuUXk+4Ltymx7HSj0ZjhJo= X-Received: by 2002:a17:90b:1e43:b0:35b:a8cf:7960 with SMTP id 98e67ed59e1d1-35bd2c2068bmr1447716a91.3.1773984257336; Thu, 19 Mar 2026 22:24:17 -0700 (PDT) Received: from Modern-15.. ([2401:4900:b471:fd0e:76f1:2fa0:b416:4f73]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35bd40e4bfdsm779344a91.9.2026.03.19.22.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 22:24:17 -0700 (PDT) From: Mathura_Kumar To: brauner@kernel.org Cc: academic1mathura@gmail.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk Subject: [PATCH RESEND v2 0/4] Add new system call for non-destructive peek and inspection to posix ipc mqueue Date: Fri, 20 Mar 2026 10:53:34 +0530 Message-ID: <20260320052340.6696-1-academic1mathura@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch series overview: 1. Add New system call do_mq_timedreceive2() and handler implementation 2. Add system call number in all most common arch. 3. Prepared Documentation and test 4. Add entry in performance tools all most common file This is a fresh patch series starting from v1. It completely replaces the previous series (v1–v5) sent about a month ago, so please do not confuse it with the older thread.I preferred to start a new series instead of continuing the old one, as it had become messy and almost everything has been rewritten. All feedback from the earlier series has been taken into account and incorporated here. Short Description: POSIX message queues currently lack a mechanism to read a message without removing it from the queue. This is a long-standing limitation,when we require inspection of queue state without altering it. Design considerations: Two approaches for copying message data to userspace were evaluated: 1) Refcount-based message lifecycle handling - This can help us Avoids intermediate temp kernel copy - Extends message lifetime -But this may increase writer starvation under heavy load and add unnecessary complication on priority management and delay more time to free space in inode due refcount may prevent 2) Temporary kernel buffer copy - Copies message into a bounded kernel buffer - Reduces time message remains locked - Improves fairness under write-heavy workloads - Simpler lifetime management My implementation adopts the temporary buffer approach to minimize starvation and reduce locking complexity. The design allows future transition if refcounting is deemed preferable. Testing: - 17 functional test cases - Multi-threaded producer/consumer scenarios - concurrent pop and peek - Edge cases: empty queue, FIFO invalid flags, signal interruption etc. Use Case: 1) Observability in distributed systems e.g Monitoring tools can inspect queue contents without interfering with normal processing 2) Check pointing system like CRIU can have a look into queue without consuming and can store messages 3) Resource-aware processing 4) Selective Consumption for Specialized Workers change since v1: - minor update, header guard was removed from include/uapi/linux/mqueue.h - v1 Link: https://lore.kernel.org/all/20260315040827.156558-1-academic1mathura@gmail.com/T/#t note for Thanks for reviewing. Documentation/userspace-api/index.rst | 1 + Documentation/userspace-api/ipc.rst | 222 +++++ arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/tools/syscall_32.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + include/linux/compat.h | 6 +- include/linux/syscalls.h | 6 + include/uapi/asm-generic/unistd.h | 7 +- include/uapi/linux/mqueue.h | 14 +- ipc/mqueue.c | 186 ++++- ipc/msg.c | 2 +- ipc/msgutil.c | 48 +- ipc/util.h | 3 +- kernel/sys_ni.c | 1 + scripts/syscall.tbl | 1 + .../arch/alpha/entry/syscalls/syscall.tbl | 1 + .../perf/arch/arm/entry/syscalls/syscall.tbl | 1 + .../arch/arm64/entry/syscalls/syscall_32.tbl | 1 + .../arch/mips/entry/syscalls/syscall_n64.tbl | 1 + .../arch/parisc/entry/syscalls/syscall.tbl | 1 + .../arch/powerpc/entry/syscalls/syscall.tbl | 1 + .../perf/arch/s390/entry/syscalls/syscall.tbl | 1 + tools/perf/arch/sh/entry/syscalls/syscall.tbl | 1 + .../arch/sparc/entry/syscalls/syscall.tbl | 1 + .../arch/x86/entry/syscalls/syscall_32.tbl | 1 + .../arch/x86/entry/syscalls/syscall_64.tbl | 1 + .../arch/xtensa/entry/syscalls/syscall.tbl | 1 + tools/scripts/syscall.tbl | 1 + tools/testing/selftests/ipc/.gitignore | 1 + tools/testing/selftests/ipc/Makefile | 9 +- tools/testing/selftests/ipc/mq_peek.c | 785 ++++++++++++++++++ 44 files changed, 1278 insertions(+), 43 deletions(-) create mode 100644 Documentation/userspace-api/ipc.rst create mode 100644 tools/testing/selftests/ipc/mq_peek.c -- 2.43.0