From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f66.google.com (mail-oo1-f66.google.com [209.85.161.66]) (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 CFA9133BBAF for ; Fri, 23 Jan 2026 15:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180694; cv=none; b=pND8XnvhBpKIa8TdOs7byo6yscGKeeQHUygqb0uUMJoCjmeVFLTOc4PD+mSrfsS4wGayszCNKrOTmXN0uJ0nG3WKaHJbyJBxEC0kOCzy5c6jDBSz80bS0839WxYmi7ld3w+t6RA2NK9LElc6wvp0HG1/gPPspYRxNh2FqgU94BA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769180694; c=relaxed/simple; bh=GtoJMAV3JMEw5u0PkRh1Ohg8essRu+nn9weTSPQUFWI=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=he0ojjKWBUhAjCbXvkbK3h6vzwcLajahw1zdJ7gCWR+PMQMPIgnv09vEqjZHnvOM2s+Bdl3gn7WgTVXpeH3t0GoAIbPQftkzXMop4V/eccb4Q7M5oYz6obREp8W/T7ru3gZd71bqyEbxqApGmAwsx7ospnLA9K2j9BZdA2PNVAw= 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.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=yyv7UixE; arc=none smtp.client-ip=209.85.161.66 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.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="yyv7UixE" Received: by mail-oo1-f66.google.com with SMTP id 006d021491bc7-65e94e128beso1508049eaf.0 for ; Fri, 23 Jan 2026 07:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1769180691; x=1769785491; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=C0mzcb/MlZDJODBRwhXegE9ctUcOjJ+6el+uFNaQtwg=; b=yyv7UixECEK1530EPpPZ6ZwUqCS5nMJyEKh8XLR/p0iyyUSEpkvRl+kkirnpsHCN2b 8aA1pja0aN5fMt5gYrUdKMDoa4B+rOyBSmzht8ir9qGygxRt9q0mN+mELzJVS6BmM8sU 6TucC2tJxq/TWhlOG4NdamkeDW9d1ZbFk+9SbIz06qe6BuIKyc00cyLUozJvYmJifQrJ J/P3VknwE7TMtaBvWMg4262KhfwboJk/x7bgQ5DU6ew02mWti9MM/uRHa1v2o/xP4WqZ C5APD2S3LLyBZ5SS3AvQT1fZVieun7zrJlbDuSFI8Er9S2LOGwlZH5z8jwa19jukIfGf LE7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769180691; x=1769785491; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from: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=C0mzcb/MlZDJODBRwhXegE9ctUcOjJ+6el+uFNaQtwg=; b=nLZgp8zKBW6vKMLGmZ6sLu3uojgrxXFkxBPbdQGQ2IpVPstgYWmFT5davUW/W3W+W3 lgXRIxayy8mBRzTmyCgDhC4ZUZubfVSfrWzYtfRMkw2JsvUJbPZ/giANAaIbR9A2G/11 5GBh4k8abkG5Lc8UwtlajtQ+TDsl5qRzmkxZfiQxlFq+v2Fm1SIR66HI6cSaUx4sifq+ yWLYHeRD3c/C8cJ53JSvLUOWgXHFm25QFSqzd1iG/S5Co6c5HANB9eZrF9FW/04jWAAn rKGZyD2onRWyFCtTEI6yAyf2YHhU3LkrvEhEEuTUqABgBHNAlMWV5SxE2BbvowJrdNUR Q40w== X-Forwarded-Encrypted: i=1; AJvYcCUagnwt7nzPz4iCmdns9XTJpVG2sBEZzIKXvIWAJK86Lwj9r6dN926bWVH6tb64e+135PxdWhWjHG8g/Hc=@vger.kernel.org X-Gm-Message-State: AOJu0Yyh2fJ3suNcWuCHI4cqT44pDEFZDLVzP/ZgCmwDWfiwnpKJKc8z 6N8QkkbI/Jr1nvu80R/U/qZGBsPxoUuWdsrm+ukLraLvmBxxLTYWSTPcMZbewKXzCsE= X-Gm-Gg: AZuq6aKLRu7eIRv0FdjRXzK9gDWH2nPg/hqlBOdDhkjBWOZbanD7mvU20GfdcD65O4i oJtmqAd4SCQWtFapemlCCalO8qUkoduI6RC18PMwTy+xDgmT/TUWhmDIIUgMM6TNdiMUqPlh+3o T3N3bJaYcfEqgMnjRWU2iYCZDlv5rhRuRFC3qcDTc3GYAEGbOMzaAK+NcwX1Y06eFMbeMOJjRGO HjKe7m8I7e7u6gBz+PSoQ+IpY0pL6qGpuyX6cxyRlqgglgDth4FcgYpJQ3InfOO8sXmLWM9oAtN XtCB/Q3nR9nrt/585+BDoLNsDrSQJRwEbkZE1PIuuo/Joz7M13+0QgbsWNIkvd+BSOH6aVOtkbs qz0Bscat3BiczYJTXMlUxsGoHMflBhTlrEcjpnocICVPhR0GJzcQnHK/ugDrlOdbvt6tHahYDDE byavo30qud8wyNmtDknA0SCwcMltXuq18BB/OxCqN95VB5PWfhdeQiCCP7xN8tfr3S/4b5/s14R ozQXTs= X-Received: by 2002:a05:6820:4d4c:20b0:661:1580:bf84 with SMTP id 006d021491bc7-662caf90a02mr1265746eaf.34.1769180690515; Fri, 23 Jan 2026 07:04:50 -0800 (PST) Received: from [192.168.1.102] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-662cb651194sm1245674eaf.12.2026.01.23.07.04.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jan 2026 07:04:50 -0800 (PST) Message-ID: <654fe339-5a2b-4c38-9d2d-28cfc306b307@kernel.dk> Date: Fri, 23 Jan 2026 08:04:49 -0700 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: [PATCH v2] io_uring/rsrc: fix RLIMIT_MEMLOCK bypass by removing cross-buffer accounting From: Jens Axboe To: Pavel Begunkov , Yuhao Jiang Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260119071039.2113739-1-danisjiang@gmail.com> <2919f3c5-2510-4e97-ab7f-c9eef1c76a69@kernel.dk> <8c6a9114-82e9-416e-804b-ffaa7a679ab7@kernel.dk> <2be71481-ac35-4ff2-b6a9-a7568f81f728@gmail.com> <2fcf583a-f521-4e8d-9a89-0985681ca85b@kernel.dk> <3b7e6088-7d92-4d5c-96c7-f8c0e2cc7745@kernel.dk> <596bc7ac-3d24-43a7-9e7e-e59189525ebc@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/23/26 7:50 AM, Jens Axboe wrote: > On 1/23/26 7:26 AM, Pavel Begunkov wrote: >> On 1/22/26 21:51, Pavel Begunkov wrote: >> ... >>>>>> I already briefly touched on that earlier, for sure not going to be of >>>>>> any practical concern. >>>>> >>>>> Modest 16 GB can give 1M entries. Assuming 50ns-100ns per entry for the >>>>> xarray business, that's 50-100ms. It's all serialised, so multiply by >>>>> the number of CPUs/threads, e.g. 10-100, that's 0.5-10s. Account sky >>>>> high spinlock contention, and it jumps again, and there can be more >>>>> memory / CPUs / numa nodes. Not saying that it's worse than the >>>>> current O(n^2), I have a test program that borderline hangs the >>>>> system. >>>> >>>> It's definitely not worse than the existing system, which is why I don't >>>> think it's a big deal. Nobody has ever complained about time to register >>>> buffers. It's inherently a slow path, and quite slow at that depending >>>> on the use case. Out of curiosity, I ran some stilly testing on >>>> registering 16GB of memory, with 1..32 threads. Each will do 16GB, so >>>> 512GB registered in total for the 32 case. Before is the current kernel, >>>> after is with per-user xarray accounting: >>>> >>>> before >>>> >>>> nthreads 1: 646 msec >>>> nthreads 2: 888 msec >>>> nthreads 4: 864 msec >>>> nthreads 8: 1450 msec >>>> nthreads 16: 2890 msec >>>> nthreads 32: 4410 msec >>>> >>>> after >>>> >>>> nthreads 1: 650 msec >>>> nthreads 2: 888 msec >>>> nthreads 4: 892 msec >>>> nthreads 8: 1270 msec >>>> nthreads 16: 2430 msec >>>> nthreads 32: 4160 msec >>>> >>>> This includes both registering buffers, cloning all of them to another >>>> ring, and unregistering times, and nowhere is locking scalability an >>>> issue for the xarray manipulation. The box has 32 nodes and 512 CPUs. So >>>> no, I strongly believe this isn't an issue. >>>> >>>> IOW, accurate accounting is cheaper than the stuff we have now. None of >>>> them are super cheap. Does it matter? I really don't think so, or people >>>> would've complained already. The only complaint I got on these kinds of >>>> things was for cloning, which did get fixed up some releases ago. >>> >>> You need compound pages >>> >>> always > /sys/kernel/mm/transparent_hugepage/hugepages-16kB/enabled >>> >>> And use update() instead of register() as accounting dedup for >>> registration is broken-disabled. For the current kernel: >>> >>> Single threaded: >>> 1x1G: 7.5s >>> 2x1G: 45s >>> 4x1G: 190s >>> >>> 16x should be ~3000s, not going to run it. Uninterruptible and no >>> cond_resched, so spawn NR_CPUS threads and the system is completely >>> unresponsive (I guess it depends on the preemption mode). >> The program is below for reference, but it's trivial. THP setting >> is done inside for convenience. There are ways to make the runtime >> even worse, but that should be enough. > > Thanks for sending that. Ran it on the same box, on current -git and > with user_struct xarray accounting. Modified it so that 2nd arg is > number of threads, for easy running: Should've tried 32x32 as well, that ends up going deep into "this sucks" territory: git good luck git + user_struct axboe@r7625 ~> time ./ppage 32 32 register 32 GB, num threads 32 ________________________________________________________ Executed in 16.34 secs fish external usr time 0.54 secs 497.00 micros 0.54 secs sys time 451.94 secs 55.00 micros 451.94 secs -- Jens Axboe