From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 2FBA63A8F7 for ; Mon, 4 May 2026 06:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777874796; cv=none; b=CeK07IaBMWDbF15kEeLSAhyVKUYjf82jzzLjoDL+IaIIQpHQ1rpksOHt6X6+iUEfxAd0yopqe7Hs3LkfN1ZfOb8nHQ/GDAYcc/bjGU6lz9ZLLzaa9vX/FP/TM3geyXgaIJmMGL5a3dK+xlvxFS/yKz/woWwooU87Z/CPFuCYwcg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777874796; c=relaxed/simple; bh=kbHoB9C+D2GQnydHnIzp4LqU9LidIbrPHCrPxtTdyc0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=U/Mjh45Pl6yqdJ1bMEp1T+BLyjAqSdQef9lstOmEBze8q13Swlcj/3W9Jxp04irKZAWVvgbHkN2tZxhFPaBk0jb4A98bJJPqc2BwZtcJOLc5w7FCUQMILz3YgShZxLLbz9UPGd83GGe1Mg9C6xnev1eRDTmT4ZfkcYNFgNywMHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20251104.gappssmtp.com header.i=@kernel-dk.20251104.gappssmtp.com header.b=B8MGQQsA; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20251104.gappssmtp.com header.i=@kernel-dk.20251104.gappssmtp.com header.b="B8MGQQsA" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4891f625344so37770235e9.0 for ; Sun, 03 May 2026 23:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20251104.gappssmtp.com; s=20251104; t=1777874793; x=1778479593; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vexHEjpsGwv7RjQ+ZQ7Gpo1ZgY4PcGih8daCe2nrVyU=; b=B8MGQQsA1hCEur8sWE8I8AOS0R0r26CJxwRbauPuQslkYLvTZHjS1jazbpJoiLy0n7 O3gUz3SVVZcNGN9LI0B8pSCJ9d5XgyXuX7NrDmYqCTfohbENs/yKoxkU2S/vE7D3+O/b 7cso+0tegD3RIVLvGmsEzjsR0I0+npbcjanWT1USq/fOELbpfzV6AerI2rYFWY0B3Vyn yssbEhAjburdOaKgfoLuNoWH1ypVz/f2lMrcCJDpTmgcGr5+jcwz9MRk3CUdVNirwOYY 8l0xyakrmPiK4sp/Hkd+KJcMIEodRL57YQRovcWB1WF8BoA/tF5I0/RLw9i7Z7ssLfpG tKHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777874793; x=1778479593; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vexHEjpsGwv7RjQ+ZQ7Gpo1ZgY4PcGih8daCe2nrVyU=; b=TmKC+2o0GmtpFEDx6RvtSnkjsgnDHPggKguUtbQIRg3r4TCHVrK1kDnRIiaOK8aQWL qMDm8tc1XRsi6X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fxY1hPy5EwLp X-Received: by 2002:a05:600c:620a:b0:488:aa33:dc8f with SMTP id 5b1f17b1804b1-48a970171bamr125119845e9.0.1777874792488; Sun, 03 May 2026 23:06:32 -0700 (PDT) Received: from [10.211.8.175] ([213.147.98.98]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a81ed6bafsm531948635e9.2.2026.05.03.23.06.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 May 2026 23:06:31 -0700 (PDT) Message-ID: Date: Mon, 4 May 2026 00:06:30 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: io_uring: should IORING_TIMEOUT_ABS honour the submitter's time namespace? To: Xie Maoyi , Pavel Begunkov Cc: Andrei Vagin , "io-uring@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <85b63dbc-1fb3-4913-9419-90908c5b6358@gmail.com> Content-Language: en-US From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/3/26 9:12 AM, Xie Maoyi wrote: > On <5/2/26>, Maoyi Xie wrote (correcting my own earlier reply): >> Under SQPOLL, the parse path runs in the SQPOLL kernel thread. That >> thread is in the initial time namespace. So timens_ktime_to_host() >> through "current" silently misses the offset for SQPOLL submitters. > > Apologies, that paragraph in my previous reply was wrong. I have > tested it. > > Vanilla v7.0, SQPOLL ring inside a fresh CLONE_NEWTIME with a -10s > monotonic offset, ABS deadline = now + 1s: > > [child] SQPOLL TIMEOUT_ABS elapsed=1 ms (bug fires immediately) > > Same kernel with your conversion logic applied: > > [child] SQPOLL TIMEOUT_ABS elapsed=1000 ms (offset honoured) > > The reason is in create_io_thread(). It is called with CLONE_THREAD > and no CLONE_NEW* flag. copy_namespaces() therefore shares the > submitter's nsproxy by reference rather than allocating a fresh one. > Inside the SQPOLL kthread current->nsproxy->time_ns is the submitter's > time_ns. timens_ktime_to_host() resolves correctly. So the SQPOLL > follow-up I floated is unnecessary, your draft covers both paths. > > While verifying SQPOLL, I also noticed io_uring/wait.c around lines > 230-234. The IORING_ENTER_ABS_TIMER path on io_uring_enter() parses > ext_arg->ts inline rather than going through io_parse_user_time, so it > does not pick up your fix. Same shape of bug, separate code path. PoC > on vanilla shows elapsed = 1 ms, patched shows ~1000 ms. I can send > the small follow-up patch for that path as a separate thread once your > IORING_OP_TIMEOUT side has landed, or fold it into the same series. > Whichever you prefer. Might make sense to refactor a helper that does the time translation, and then patch 1 would basically be Pavel's fix and patch 2 would be sorting out the io_cqring_wait() translation as well. Both should be able to use the refactored helper. -- Jens Axboe