From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795961269; b=quAIyn1r9v9soynhKIlEFqm2fpkrJmnWur2wsYBdLXqFrM2YuVyywkzUom8o6OB9SDIz B9ztNGNrHxS0AUmQGO071xE0Dhtvf/iN2n/5BDc0ZHaU2olPoRvZSEaoHtSpp/l/AcuHV aLYXcsYzkJ2INhiDLjMG5YwdnLBL7aBXnd3wz/o+RThJ4+1wBhVYV4ckSHncFFWbhBjlc SW42+kFuIJv3BzNcyvfEx6Vy40cpj5jNE5jHEfacztpv/bjyjw9YoAZFUg0vN6wTlipVG BVC70mvsOGU0h0ULL4TfUGzVzWvyo13dFgo+4m/+Eb1TfzKBm5jyQPigmC17+cUreQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795961269; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:From:To:Cc:References: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=uc0eRs7cL4MuuyK0U9neWwyUTjOk3/ISGik4Od22sfc=; b=2HYPaC0TqxikYQ+i5wVr3PoHNURxgmgc/O1T3/6j8eRV/h165tjzIgdqGD16jMjggpKm JMjEhbXKUenwzjNcJlkgYerZvOJH7NE0v9A705WHb/LWmU7Jw7+wy1wYO6gOEWf1jAMQx CuruKaVN1ISw06PzJHeskpBUHgkURsf5EfWt77UBrkAVxN0Y1fLV1H4/D6PiWZ7ti6GGq wOguXnDU6dxf6jDpIlBkPhnoI0gG9xaFTdtKz2B2Fnq+UDTVK+lvkRExSqhALNazIOGZY gYCHPYd4Qqk5xEtU4MFwIUayEnsxh/vbaiZyNRko23Fqx8cRubVx/M4uefPRM67Gk0A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="WAZggp/e"; arc=none smtp.remote-ip=209.85.208.172 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0317B606A329 for ; Sun, 29 Nov 2026 14:07:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0317B606A329 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.a=rsa-sha256 header.s=20260707 header.b=WAZggp/e Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-3ab3b29a298so78524411fa.3 for ; Sun, 29 Nov 2026 06:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795961267; x=1796566067; darn=vger.kernel.org; h=content-transfer-encoding:content-type: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:content-type; bh=uc0eRs7cL4MuuyK0U9neWwyUTjOk3/ISGik4Od22sfc=; b=WAZggp/ejq26sNsPvBGX04nd8e6Y6cMOmemyZvRjAulND8GWSB/8yt8IthrIeFMe9k zmDQSSGqClD6W2klDMKKSbgufXqv6fKn3kVyH+c9/uZW1E8Ex31ZSnsD0W2AguaqCe0p rOFeGnDgxgVg8rkELnGW45/MvnVn7fHQjCiDoCKqON2terzUVreDSXB+3pcj6FSvuhdN Yw/oUwl+vDZMRckLQjiBtKY6zpmPj/j3IXDX6pl7UmUFCT/5wZdsvzkIuuN1gj1XJ1Ga OqnK4etYu4nh6oPqlVDFzL4EyR4C2RGWalTM+1WBp91L3/Vso3+dFjA62UxKcTTGp05H ZILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795961267; x=1796566067; h=content-transfer-encoding:content-type: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:content-type; bh=uc0eRs7cL4MuuyK0U9neWwyUTjOk3/ISGik4Od22sfc=; b=oqugIPqQ5cM1i0v9PCHRHPOQTBk91EV/Cx017PDkfJSPIu2ADfP7HNo1aZRJwrIvgQ pnWcg+qKi16saAbD0zEzkLakEdLOJwpRa4kERciVyDW/JMW78ZBZGdhqhCAU09HYlv6U CFy8ioXDY2ReZUm/riOBkFfZ7POdUWLRGKd5w0SfGhbPSQPEsX8eA89ySWsbRYfzamS0 8sSsDY8/7ZEZBLxwTZWGw2cj4wVBH4lEVDbU3uNmH7/83f9altiJWFM9pmKCn4SPcS7i 7TeHhEVy0nXzLhHHZACzlbqTuDxSfsXM/GE1M4rQsogL+Mg7qo0UtM7O0kfcI8UUwZ69 qAXw== X-Forwarded-Encrypted: i=1; AL+hErEuq5uJk283lwCnOr3O9bBGhsvufp0wQahKwBXAhokVkiI2AUUxg3sr7dorHRb2ZgNMaW+/WaSCwUJwbMc=@vger.kernel.org X-Gm-Message-State: APuU4Z/OVGFrbWBPCAxjWv05FS9FjqlaH7M26RUuuXn94mCpY73K2Cn2 l7bIqlEYZAnJcLUZcarpCoyzXGy7M9q6HZYEYZci/SO5wf8iXpgysyyM X-Gm-Gg: AZFdTZclVdh6OgYJsPT747zutFa2YjISHGhYtLGviok3E3geR0+4WEQR/fKegoPKSW0 Gmxq0A8r+g02O6VxrVW5LagxR4joKnOn7QsThS/h2FvBSS5e6GOW779GNyO4/afor4mO9azwMq0 TJQotCkURz+1jIFWI4wzcJqe2Zk9LHtz/EQ64BaOIHY99IBxlLN+o0SEvxlrPjVWM866sIS42Nr q6frGxiT8yr3tYZUh+a8OPs3yf38tEmQBW86N/yVHe9ZGPgaOk1SqDO7+g+lJLLyzyyw8jU8lad 26/egXKhrMZDgL1TsGyhrbio/dMDQa00R9mJ1m75IbvZrg7MhPsUfagehfuxBzpSjQ+A3GHr9Jh w92mpYJMI0nOfdntABHfPKbGRcu78114CPtjQ+kpS6HiZ7DiV6kdMBIjnAO76QWroC9m7Ny2DKC qL+2n2qtDKFzjd6aahxaC/uImlNvO6tO+3eVOdJFkfCshoAMjPaHmJzZBRvJUcCuF1z7iQWVWeh WPn6xVXkbnk9wHDoq4A7LHsG3PDrjuO6VNebSj5kK8DMlIRu2kshirfUpzl2ruv4w3PzIWyewSw cAqmGd6CNrofS5CUKgyHRgC82mReDcuW2Vm2F1RpGfuIfOmgKpClMC4ZquDDQ0texN1ebkkRS7+ Rsl2448bqVg== X-Received: by 2002:a05:6512:23aa:b0:5bf:d127:b83c with SMTP id 2adb3069b0e04-5c1bc844b8emr9129840e87.10.1795961267197; Sun, 29 Nov 2026 06:07:47 -0800 (PST) Received: from [192.168.68.162] ([87.237.44.52]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c34341bdcfsm1481871e87.78.2026.11.29.06.07.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 06:07:46 -0800 (PST) Message-ID: <022c87a8-a640-4d18-ad7e-0df02f21ae9f@gmail.com> Date: Sun, 29 Nov 2026 17:07:45 +0300 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] percpu_ref: make percpu_ref_switch_lock per percpu_ref From: Egor Shalashnov To: Andrew Morton Cc: linux-mm@kvack.org, dennis@kernel.org, tj@kernel.org, cl@gentwo.org, zhengqi.arch@bytedance.com, linux-kernel@vger.kernel.org References: <01612865-faa0-4fe5-8184-a177f104843f@gmail.com> <6c943754-05b5-4017-9145-0d145766909a@gmail.com> <20261125113537.bdb168bfe8962ef1aefc097b@linux-foundation.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 26/11/2026 00:46, Egor Shalashnov wrote: > This might be a better approach. I'll compare it with the global-lock > and per-reference-lock variants and report the results. I compared the global switch lock, per-reference locks, and hashed lock arrays with 16, 32, 64 and 128 cacheline-separated locks. The machine has 128 logical CPUs and runs Fedora kernel 7.3.3-200.fc44.x86_64. Volumes were prefilled before each run. To increase lock contention, fio 3.40 used io_uring with 128 jobs, one pinned to each logical CPU. Each job discarded a separate, non-overlapping range; together they covered the entire volume. The maximum discard request size was 4095 MiB. Full-volume fio discard completion times, in seconds: Volume Global Per-ref Hash16 Hash32 Hash64 Hash128 1 TB 3.393 0.675 0.838 0.759 0.722 0.719 2 TB 5.039 1.315 1.470 1.423 1.399 1.399 4 TB 8.705 1.406 1.555 1.471 1.471 1.485 8 TB 16.955 2.667 2.991 2.835 2.834 2.832 16 TB 34.056 5.263 6.122 5.015 4.997 5.172 32 TB 67.177 9.755 12.680 10.145 9.467 9.646 64 TB 134.081 21.421 24.058 19.539 20.311 19.009 128 TB 263.881 40.170 48.588 38.663 40.135 39.236 256 TB 543.297 80.053 91.324 78.679 83.590 77.425 I also tested full-volume discard using a single blkdiscard process. Volume Global Per-ref Hash16 Hash32 Hash64 Hash128 1 TB 2.722 1.018 1.268 1.167 1.117 1.017 2 TB 7.085 1.871 2.573 2.373 2.121 1.821 4 TB 14.354 3.025 4.932 4.179 3.878 3.427 8 TB 28.391 6.186 9.544 8.342 7.441 6.687 16 TB 56.520 11.655 19.124 16.265 14.561 13.311 32 TB 92.209 20.629 27.544 22.931 21.123 26.303 64 TB 162.383 39.483 54.974 48.209 43.342 40.180 128 TB 321.230 90.283 115.726 102.877 87.113 94.157 256 TB 556.408 181.729 231.681 210.062 177.198 165.985 The 64-lock implementation gives results close to the per-reference implementation. I have prepared that version for the next revision.