From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f67.google.com (mail-oa1-f67.google.com [209.85.160.67]) (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 5F1EB18FDBD for ; Sat, 24 Jan 2026 15:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769267686; cv=none; b=b98aSWgsbT6kMbfy4d//wWop7M3gFbnw2h64g+oacKhlRTzJHu4fzauTB2AtQsNUj5Zv+Pw7lA8Bkby0Ibwak9NTXV1QMiPua9WrsWv+gqtQVgnDGV5fUXsygfquw8OFLnHbeeERpsZJLiDE9JnEmCypI//AdScW9RA4LdVMvJM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769267686; c=relaxed/simple; bh=mlxg/+Y14geNE63XB5dcfGiprcSJzXI8gCcwNwhvaI0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ocU9dE9iRQCmKdItWEQy8doXBMA9UTxCnuzXTwnGh0yjm2tYEBz1QLrSGShKNMdzVhlY85zsYPXb7kZBYZPp4bACairtrhQ1M7Qu0XfmSDEZ5royZ9yDBmPhNeCYRB5sn+QxM2Z93WLT+WCHcANuw9LzDZQszvUl2t7L/qu2r2Y= 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=pa9yS2Pc; arc=none smtp.client-ip=209.85.160.67 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="pa9yS2Pc" Received: by mail-oa1-f67.google.com with SMTP id 586e51a60fabf-4042fe53946so1015998fac.3 for ; Sat, 24 Jan 2026 07:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1769267683; x=1769872483; 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=twHLCrUFaWNPEY9IZbwbr71SXMraJnqj5vi/Tu8ErvI=; b=pa9yS2PcEj6/sVnYKKbf2vVJdnZvZdiOMaYwN6zzFKOFg+aKbjmUJzCjfo/BY2jCBa bOD3N1+kIObMzZGO0BfSJljxoDB1/nXR3TkqObTpsh2hBQCufsl65KGMeWISfrUIYJjG TxpWwf9P1QAWJRp8kjMWIkzPAERSB8Tce9HUHOtQ/5Yr0xTLG89QGKkpST4uTp7gB38z sUAtrkKW2i+irWqiP4mYbveT07O3wcfn/xXzzEclugnLL+EJS9ae3/lHBZhcn4VbjPWl tUkQbtETmiGREgvyEZf+e76UDCVtn6ENewkK6udLzTAQIOAxV0iMTHNb4VUKBe8AH6UP dLMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769267683; x=1769872483; 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=twHLCrUFaWNPEY9IZbwbr71SXMraJnqj5vi/Tu8ErvI=; b=XM0gLbuuNHQ327NCJq3Iaq2Ay3CJhUgux4MWSBUvg7FLBsTdql3+bZ0u/pxpDBtQQH XFXijN2Ac5FNpve0BwRUY5U4x/jry8NTEfKV3CmVYudbShb37ehwu1osWYa1SdUilct7 JZmQSQPJC/lfuI2V14EVgcUFqls0dcKjQmbjpkwm9YuvX/SQh3l+N80s4/JiNrVdfdcl DOPMcGZFGGhPQRIO6bPAH7AuSCwdXP6mfs6eR37F3nvqpOGWXZA5ijz+KLJbIrdwMn2K nw/GL9ThXzsykpTFdJ13TiJ8k4pToAQwfp0oxrqZJalRN24zTtvfW2IUkIA31sQo7dnO 3egQ== X-Forwarded-Encrypted: i=1; AJvYcCW2nnbBGNPUbKX2jH/Idu9Lp4tLkeBLR9td503jCfaihY6KmYXaj3Bnwl7gRabDhCAgbCXa+JPHksEuB64=@vger.kernel.org X-Gm-Message-State: AOJu0YxUtt6iWX94aUpWqQD5aTf7Ao/i38XSKdCqsWGhddepAqastTPR gL8WSuSMFflbXUfC4mgulALBChWRD7BTjtv/IPfB0haNPW3DWfR28araxXMuUrVfyv4= X-Gm-Gg: AZuq6aI4+0UNIkqQvqCpD3rkcKTMpyRa3mHCFA7EZZzJPdOUH7iiNj6bHeDE9KnsJJG JTAdurLwZGQ4VuVdnF936NHuprecrLTBoUouqJ7BPjAOP22+7ezJxw78lc5ZLBDJWIq3llcGaeY mwL3lJNC2x3SPsW84/hjb/KKQSAR15qIgBbIFadF9qeJAXzkN29eXk2k8CbyVYTbbp0uUjJjJi9 IiH5bpQ0z9E9CWsfzR27xXTwWYpdEDgB9jZcxvYZOhwTImhV01DtpJNSJtuq4VxMcpnQUgFXwZa BR66xBGjmKUaJVmCfi0Aq2kV6805+i2zkJUMrJrs3BZJU7CwHe4SnrtT77KwLKRJq5IUhV1osjQ 6Y7GmF3P8xsOxud17HTpJbwhjIaE3ERnU4wJ/6Xj023qS5/JAwomnM+W+amN6RyRrLWVRlDxvSC i14N3WfilUZTy7Fcv617fbXliRL7z4q53T2NnNdzpFFczZJW9iUQzxhOs7Y6ZfxKFY9fbYWA== X-Received: by 2002:a05:6820:16a5:b0:662:c5c5:4fa8 with SMTP id 006d021491bc7-662cab5253cmr2834549eaf.39.1769267678481; Sat, 24 Jan 2026 07:14:38 -0800 (PST) Received: from [192.168.1.150] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-662cb4e5b2fsm2507135eaf.1.2026.01.24.07.14.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Jan 2026 07:14:37 -0800 (PST) Message-ID: <74f2ec89-ca40-44a0-8df7-de404063a1a3@kernel.dk> Date: Sat, 24 Jan 2026 08:14:35 -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 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> <654fe339-5a2b-4c38-9d2d-28cfc306b307@kernel.dk> <9317bad6-aa89-4e93-b7d2-9e28f5d17cc8@gmail.com> Content-Language: en-US From: Jens Axboe In-Reply-To: <9317bad6-aa89-4e93-b7d2-9e28f5d17cc8@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/24/26 4:04 AM, Pavel Begunkov wrote: > On 1/23/26 16:52, Jens Axboe wrote: >> On 1/23/26 8:04 AM, Jens Axboe wrote: >>> 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. > ... >>> Should've tried 32x32 as well, that ends up going deep into "this sucks" >>> territory: >>> >>> git >>> >>> good luck > > FWIW, current scales perfectly with CPUs, so just 1 thread > should be enough for testing. > >>> git + user_struct >>> >>> axboe@r7625 ~> time ./ppage 32 32 >>> register 32 GB, num threads 32 >>> >>> ________________________________________________________ >>> Executed in 16.34 secs fish external > > That's as precise to the calculations above as it could be, it > was 100x16GB but that should only be differ by the factor of ~1.5. > Without anchoring to this particular number, the problem is that > the wall clock runtime for the accounting will linearly depend on > the number of threads, so this 16 sec is what seemed concerning. > >>> usr time 0.54 secs 497.00 micros 0.54 secs >>> sys time 451.94 secs 55.00 micros 451.94 secs >> > ... >> and the crazier cases: > > I don't think it's even crazy, thinking of databases with lots > of caches where it wants to read to / write from. 100GB+ > shouldn't be surprising. I mean crazier in terms of runtime, not use case. 32G is peanuts in terms of memory these days. >> axboe@r7625 ~> time ./ppage 32 32 >> register 32 GB, num threads 32 >> >> ________________________________________________________ >> Executed in 2.81 secs fish external >> usr time 0.71 secs 497.00 micros 0.71 secs >> sys time 19.57 secs 183.00 micros 19.57 secs >> >> which isn't insane. Obviously also needs conditional rescheduling in the >> page loops, as those can take a loooong time for large amounts of >> memory. > > 2.8 sec sounds like a lot as well, makes me wonder which part of > that is mm, but it mm should scale fine-ish. Surely there will be > contention on page refcounts but at least the table walk is > lockless in the best case scenario and otherwise seems to be read > protected by an rw lock. Well a lot of that is also just faulting in the memory on clear, test case should probably be modified to do its own timing. And iterating page arrays is a huge part of it too. There's no real contention in that 2.8 seconds. -- Jens Axboe