From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 570862222C5 for ; Sun, 29 Mar 2026 17:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774804816; cv=none; b=tc4Iu2XF9yP++OnqPZ/uPbqCeJi9lqC3D5n95HJoepr8oXrP/pgUTL0aGW2z1Hd5jiVhFhwXz36VLHsKg9ZUdcrJMdV4YpLhBG6yi3D5yocG0MaB0I1kNq/hYthQzLtTxeqKbRWIgQOvE4UMuyWnEWCsZTAwo7N40c3rW5JSBW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774804816; c=relaxed/simple; bh=6R+9nd88tZ3TlYfp/qqHQHU2Es9EiRsRPP1CEhhHxP0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RjPHXx65ejtBNWcAm0kwSasE51bqlW42x3fECC1brGNWr7573Fix7U9dbwsCaxGLlqN/UbxfXsBfdW47TVqJiUpDhz4jqbyrJccK+XNJ53u1Vz0R+6ySWTuF0GMXdPi20il/zsmkbAyy3LPUn1riQLHrw0O7HZK9JYv2IvQRXJY= 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=M+aG3cpM; arc=none smtp.client-ip=209.85.128.44 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="M+aG3cpM" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4852e9ca034so35841675e9.2 for ; Sun, 29 Mar 2026 10:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774804814; x=1775409614; 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=Uzw4iBHMRARSh5usnBy+gH9KubUL5EZBuRXquFbr29E=; b=M+aG3cpM/mPBdVreOAUXQEBrxrTEFPyJKItBPkvGf7FWPT9mG+hsPT0P7d1V3qVTQf u/tzBAB/l909uk9DWONC/f4hNeJSDm6/Y7tx0bKFGF3QmR9mOf2/oIiWsL5vh872r+t6 MPXm6EBma0sCiYqot13+dd1RDUbBsgAaQEAxkeSFOEcUxI4zHQsO1B4jPQZG9BqRzbry TqstTXEb6765bKVSpN+Z6oIWD8Y/tNjMvgNhU726W9hrIxURUW6FaAKsLsDMuu2Xmd9v +ZfguMTsQiA6wPZsGGmoKsxQQ63wCOmuck+Zgsk+lHTbScjk7DN36Ciazqy26eNxqbY3 Cy2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774804814; x=1775409614; 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=Uzw4iBHMRARSh5usnBy+gH9KubUL5EZBuRXquFbr29E=; b=UQJTnblMUNmPgLJIqsimOSGuGLPA6locXih9sOJDeHfWYNY6iMQTv//YmbePAhYmgk X66p3Y4jmTJyN5AH4oQ6LS9QUWQPRCIb+mCr3xDV8pFgxRHAwt3MkEEES4xoQmf+X33A eiDkLgjCblmoToVj7hpD6zuf0YC6X4MX43rcGRAyIETcFG/EmkR0zJCweRDaRT+I8MQV RbNtCcXKPtTVYCfG1FwsQIiM6Sr8qMjQHabsW4OPZ1bjCeHaH8XVAdMs6qdsdDcvTYyS wWhNmzWVkgGjPlKCGObEuYu5r8bWYsvUG4k9kTcm/+LJYXob31vzETs4ZrN+gO2bvnQx qcRg== X-Forwarded-Encrypted: i=1; AJvYcCWfq3NpUkrV0lik31PQXYqib7HQrr4CTLt/UxH3Y+24tyllAcQ1HWPpmua1EPW2ZKD2rHV4MzWixo0AzYA=@vger.kernel.org X-Gm-Message-State: AOJu0YzYY9DaMJh9hbY7vwaDd37y9w/cxazejhhauuBo9zm+Kn2qXdYX TgfCC2oIMLL83cZ9W+68kMvAn2mbltmYKd2JwqszNBDC1yWSC7zbXIG0 X-Gm-Gg: ATEYQzyQrraatvySmKX/DA12GIBstrdmDnHe01ygAKaGKgWhNkS/jUAvZzDGtg0OhoN qTL9/Nc4XLXKYDYHCWukcX6xkPBO+nkRvcjISutyM4iFlWaL29trzqCb17A6w6qPg34ltlvlD7P a8phTT1oS2GQuw2Juyn4meNkRxaIzTvN2/mNIv7hC2/ugC9d3hLwhsPTS3jH0EEnYP8KFz1rrKd TB2jtFrb1v/jww+Z/MciqWsEkpgtVDMOhOeziVhCX0G8E7/jAn3pBP/BOv4GBuXAPfWmuCDkqdy mfTaf2smoJUxaOrloEl97m49qeAthRPNzo4oKVMb7sGcQCPIlyQvz7XgsY2EFWTXVXH7MYe0Wko 2PsfPUh+1YUP489BgkCC8SIwQ6bTDZPlmdqpcebLNzD3zYVHs+lCnqQwOZU2p3habVaRsS8sJEH M1cwAo0Ez65ltTTk3b9hJ1aXMzghZWLRZIy19jlpLI/Sajo1zcCFQv6qRasAXfdPfStMMLIWI1X w== X-Received: by 2002:a05:600c:8b70:b0:47e:e952:86c9 with SMTP id 5b1f17b1804b1-48727d317f6mr167084705e9.0.1774804813402; Sun, 29 Mar 2026 10:20:13 -0700 (PDT) Received: from f.. (cst-prg-89-171.cust.vodafone.cz. [46.135.89.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4873cd7d039sm9776805e9.15.2026.03.29.10.20.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 10:20:12 -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 v3 0/7] assorted ->i_count changes + extension of lockless handling Date: Sun, 29 Mar 2026 19:19:55 +0200 Message-ID: <20260329172002.3557801-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. There is a future-proofing change in iput_final(). I am not going to strongly insist on it, but at the very least the problem needs to be noted in a comment. v2: - tidy up ihold - add lockless handling to the hash Mateusz Guzik (7): fs: add icount_read_once() Use icount_read() and icount_read_once() as appropriate. fs: enforce locking in icount_read(), add some commentary fs: relocate and tidy up ihold() fs: handle hypothetical filesystems which use I_DONTCACHE and drop the lock in ->drop_inode fs: locklessly bump refs in igrab as long as it does not transition 0->1 fs: locklessly bump refs in the inode hash when possible 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 | 114 ++++++++++++++++++----- 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, 122 insertions(+), 37 deletions(-) -- 2.48.1