From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 048D4364EB1 for ; Tue, 21 Apr 2026 18:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776795966; cv=none; b=qxvyDh7rBS0H806fohsaH84b5CSm3rw4QXIky/nGlCKcvb1lfr8h9R+kxiOI7Fw1fLlftkho4T/oSMZqmRFULidX9N6xqxRlkprTIB9OwOhfeqCPix13FhcC6MquEcbEd403NfyzNJjc0POSLGYHIqYT/UFtVde+qdQo7MvXa54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776795966; c=relaxed/simple; bh=fG/Smu8c4Fbz698J/8LIZMpA/DvI7evtlvs57A4nnZc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bdq5XDtgXmO2VUHa2jFTpTGGRpLRZcCl0jgqTgFfGKlzqaPDRHchXEhsnvSITUY0FQCz6cLuVifs/qjq6iO6Etfsi7ecs+YpWenv4DBVYDMq3S65uvB+c1CjADpgyH0y5JZ7CNXXGAcvWZdhemvjV/lMRISqsgmTvcHkhcG6+go= 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=pNcYY3kt; arc=none smtp.client-ip=209.85.221.54 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="pNcYY3kt" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-441209fb77eso652200f8f.1 for ; Tue, 21 Apr 2026 11:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776795949; x=1777400749; 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=Vn7Ydh4WOilQSxdiTFvb+YkeL8VBZsiG7EJ/UuoUcpg=; b=pNcYY3ktRsLgtPXC+Y8i9CaIJm9G79T2MViMuILZFvlF8VjlNBaaON00lJyXizz0NG j5OT3dqrUa1j40L3zA7BoRY2GP8MIJ9iKOJXgovgdJFA1/rqwoFdVmjo3c/FdNXsmCvC QgB3q6hHecMcXISh1bKKPFaJXb/YtCkU3Gr9kZCRhwsw+ABC6MfK9g6idYfpmn1R7608 Te/MbALktvrfDaxcrdAtrFLBgYUFiOP+yNMLR6/woF41vdLtsVBy9JjfmfmIcD/Ld9Rd 4tJY2l6SN9gYZU0QIYbyCNp7nWtDJUgNyIn2oeaK5bOExLcnN9PQYTJtFoDrR9vVQ1N5 V/bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776795949; x=1777400749; 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=Vn7Ydh4WOilQSxdiTFvb+YkeL8VBZsiG7EJ/UuoUcpg=; b=LABrh11LNneD5N5REqHGCNd0aBFfbA1gA5OUrQSMSAEOhaXYlqHvEByVcc5Ipr9VOn FkwcJwgD5DR/6dOlck0mLRihgEyOWYc844w80+FLIIGBxOHbPRZfseSe+dW0VhOoTVhe sGnoJJ371cMVKvGBSd0zHXuGQL6iR1Q1OVn8+3Cv3kth6dVDoqyolCKvb1sCMV6ZGOHt O5Ln47paDsxBosw6tIy9E4XX53snb7cQkc7bqMNNMFJQbh4QZALJfP+nL998FacndAmD k85gfl3Q+vD8PvUJWceoPxYkgMkFbQM8e1PyYIzRdRTsy2y6fxDx6hFAo98KpyoNORGH La7Q== X-Forwarded-Encrypted: i=1; AFNElJ+hVwHbS+/Y4EFU4PlLkTGICb1yOLDVg0vxJQd3sAzoytyA/Y2vZ7AJRzTXd8xqc2rY+ohnR+vHnBRdfIg=@vger.kernel.org X-Gm-Message-State: AOJu0YwY7b4Qeg3HLJWNKj1MARqxGGytRgTeWQ1DqoWwrjmyMTzas7c+ LCS1+PBKO/8pIAlisK50r4+4Lpzy4aXYw+P18/vYroTu+VLWY6xJ4Dfa X-Gm-Gg: AeBDieuSuYC5ikZO0WP2pbddm/f7aG26Oef4Mm79XjjxfDNAQriv3JMmiveO5YAoZW+ qZBeIxsMdZZhdCtj2l7cy1WGs+B8m+43zk1crQt2lrUvzhmbz5fdbSOb2m4G+8fIPZuUS+C5yVy QQIVFJwqYCTSPbsR8m9hKRQClMr9iQYUT7aOvvdEl9VHVzlgw+55zBaaRNp3s9LuVHcZAuZMN7H HDBpGtX3014hNk8ROmpgMioXOXK0a2oiz3170u2bRmlQbKRapjQi6Oj1+unyeeDCOykqFDlPCJR gCLBGHwUUqAxJyfyFqD4A2onpCFjsWVlngaQEyaHqcsWx4Nnc2SNlYSNiOwY55Oh4UvtL8rw4bF WVIQEgkApo2CHlF7hrVzEkk+bb9lOpLs1GfbXSo6CjdM1vO+GoIfNsb8HBOUnDTg/ttADtVvizO nNJNRqYvm9F+NZqUXAZV65xYg82hRZGkkx8Ss5g8rPILdkiTzNJ1yM3FS7a6kp14AqJjFpDXcjJ JQzv3F84A== X-Received: by 2002:a05:6000:15d2:b0:43f:e571:184d with SMTP id ffacd0b85a97d-43fe5711898mr19129355f8f.28.1776795948775; Tue, 21 Apr 2026 11:25:48 -0700 (PDT) Received: from f.. (cst-prg-4-152.cust.vodafone.cz. [46.135.4.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4cb1405sm38694053f8f.4.2026.04.21.11.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 11:25:47 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Mateusz Guzik Subject: [PATCH v6 0/3] assorted ->i_count changes + extension of lockless handling Date: Tue, 21 Apr 2026 20:25:35 +0200 Message-ID: <20260421182538.1215894-1-mjguzik@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-Transfer-Encoding: 8bit The stock kernel support partial lockless in handling in that iput() can decrement any value > 1. Any ref acquire however requires the spinlock. With this patchset ref acquires when the value was already at least 1 also become lockless. That is, only transitions 0->1 and 1->0 take the lock. I verified when nfs calls into the hash taking the lock is typically avoided. Similarly, btrfs likes to igrab() and avoids the lock. However, I have to fully admit I did not perform any benchmarks. While cleaning stuff up I noticed lockless operation is almost readily available so I went for it. Clean-up wise, the icount_read_once() stuff lines up with inode_state_read_once(). The prefix is different but I opted to not change it due to igrab(), ihold() et al. v6 - remove the DONTCACHE vs drop patch for the time being - s/igrab_try_lockless/igrab_from_hash/ v5: - reword some commentary - add unlikely to the new icount check in iput_final() v4: - squash icount_read patches - use icount_read_once in the new ihold assert, reported by syzbot - squash lockless ref acquire patches, rewrite new comments v3: - tidy up ihold - add lockless handling to the hash Mateusz Guzik (3): fs: add icount_read_once() and stop open-coding ->i_count loads fs: relocate and tidy up ihold() fs: allow lockless ->i_count bumps as long as it does not transition 0->1 arch/powerpc/platforms/cell/spufs/file.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/mds_client.c | 2 +- fs/dcache.c | 4 + fs/ext4/ialloc.c | 4 +- fs/hpfs/inode.c | 2 +- fs/inode.c | 96 ++++++++++++++++++++---- fs/nfs/inode.c | 4 +- fs/smb/client/inode.c | 2 +- fs/ubifs/super.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_trace.h | 2 +- include/linux/fs.h | 13 ++++ include/trace/events/filelock.h | 2 +- security/landlock/fs.c | 2 +- 15 files changed, 112 insertions(+), 29 deletions(-) -- 2.48.1