# git rev-parse -q --verify b8d5109f50969ead9d49c3e8bd78ec1f82e548e3^{commit} b8d5109f50969ead9d49c3e8bd78ec1f82e548e3 already have revision, skipping fetch # git checkout -q -f -B kisskb b8d5109f50969ead9d49c3e8bd78ec1f82e548e3 # git clean -qxdf # < git log -1 # commit b8d5109f50969ead9d49c3e8bd78ec1f82e548e3 # Author: Linus Torvalds # Date: Sun Jul 3 14:40:28 2022 -0700 # # lockref: remove unused 'lockref_get_or_lock()' function # # Looking at the conditional lock acquire functions in the kernel due to # the new sparse support (see commit 4a557a5d1a61 "sparse: introduce # conditional lock acquire function attribute"), it became obvious that # the lockref code has a couple of them, but they don't match the usual # naming convention for the other ones, and their return value logic is # also reversed. # # In the other very similar places, the naming pattern is '*_and_lock()' # (eg 'atomic_put_and_lock()' and 'refcount_dec_and_lock()'), and the # function returns true when the lock is taken. # # The lockref code is superficially very similar to the refcount code, # only with the special "atomic wrt the embedded lock" semantics. But # instead of the '*_and_lock()' naming it uses '*_or_lock()'. # # And instead of returning true in case it took the lock, it returns true # if it *didn't* take the lock. # # Now, arguably the reflock code is quite logical: it really is a "either # decrement _or_ lock" kind of situation - and the return value is about # whether the operation succeeded without any special care needed. # # So despite the similarities, the differences do make some sense, and # maybe it's not worth trying to unify the different conditional locking # primitives in this area. # # But while looking at this all, it did become obvious that the # 'lockref_get_or_lock()' function hasn't actually had any users for # almost a decade. # # The only user it ever had was the shortlived 'd_rcu_to_refcount()' # function, and it got removed and replaced with 'lockref_get_not_dead()' # back in 2013 in commits 0d98439ea3c6 ("vfs: use lockred 'dead' flag to # mark unrecoverably dead dentries") and e5c832d55588 ("vfs: fix dentry # RCU to refcounting possibly sleeping dput()") # # In fact, that single use was removed less than a week after the whole # function was introduced in commit b3abd80250c1 ("lockref: add # 'lockref_get_or_lock() helper") so this function has been around for a # decade, but only had a user for six days. # # Let's just put this mis-designed and unused function out of its misery. # # We can think about the naming and semantic oddities of the remaining # 'lockref_put_or_lock()' later, but at least that function has users. # # And while the naming is different and the return value doesn't match, # that function matches the whole '{atomic,refcount}_dec_and_test()' # pattern much better (ie the magic happens when the count goes down to # zero, not when it is incremented from zero). # # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux-gcc --version # < /opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux-ld --version # < git log --format=%s --max-count=1 b8d5109f50969ead9d49c3e8bd78ec1f82e548e3 # < make -s -j 32 ARCH=um O=/kisskb/build/linus_um-allmodconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 allmodconfig # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_KCOV=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=n # Added to kconfig CONFIG_GCC_PLUGIN_SANCOV=n # Added to kconfig CONFIG_GCC_PLUGIN_LATENT_ENTROPY=n # Added to kconfig CONFIG_GCC_PLUGIN_STRUCTLEAK=n # Added to kconfig CONFIG_GCC_PLUGIN_RANDSTRUCT=n # Added to kconfig CONFIG_UML_NET=n # Added to kconfig CONFIG_UML_NET_ETHERTAP=n # Added to kconfig CONFIG_UML_NET_TUNTAP=n # Added to kconfig CONFIG_UML_NET_SLIP=n # Added to kconfig CONFIG_UML_NET_DAEMON=n # Added to kconfig CONFIG_UML_NET_VDE=n # Added to kconfig CONFIG_UML_NET_MCAST=n # Added to kconfig CONFIG_UML_NET_PCAP=n # Added to kconfig CONFIG_UML_NET_SLIRP=n # Added to kconfig CONFIG_GCOV_KERNEL=n # Added to kconfig CONFIG_DEBUG_INFO_BTF=n # Added to kconfig CONFIG_BPF_PRELOAD=n # < make -s -j 32 ARCH=um O=/kisskb/build/linus_um-allmodconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 help # make -s -j 32 ARCH=um O=/kisskb/build/linus_um-allmodconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 olddefconfig .config:12358:warning: override: reassigning to symbol GCC_PLUGIN_SANCOV .config:12363:warning: override: reassigning to symbol UML_NET_ETHERTAP .config:12365:warning: override: reassigning to symbol UML_NET_SLIP .config:12368:warning: override: reassigning to symbol UML_NET_MCAST .config:12370:warning: override: reassigning to symbol UML_NET_SLIRP # make -s -j 32 ARCH=um O=/kisskb/build/linus_um-allmodconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 In file included from /kisskb/src/arch/x86/um/asm/processor.h:41:0, from /kisskb/src/include/linux/mutex.h:19, from /kisskb/src/include/linux/kernfs.h:11, from /kisskb/src/include/linux/sysfs.h:16, from /kisskb/src/include/linux/kobject.h:20, from /kisskb/src/include/linux/pci.h:35, from /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:26: /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In function 'kfd_cpumask_to_apic_id': /kisskb/src/arch/um/include/asm/processor-generic.h:103:18: error: called object is not a function or function pointer #define cpu_data (&boot_cpu_data) ^ /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1610:9: note: in expansion of macro 'cpu_data' return cpu_data(first_cpu_of_numa_node).apicid; ^ /kisskb/src/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:1614:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: all warnings being treated as errors make[5]: *** [/kisskb/src/scripts/Makefile.build:249: drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.o] Error 1 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [/kisskb/src/scripts/Makefile.build:466: drivers/gpu/drm/amd/amdgpu] Error 2 make[3]: *** [/kisskb/src/scripts/Makefile.build:466: drivers/gpu/drm] Error 2 make[2]: *** [/kisskb/src/scripts/Makefile.build:466: drivers/gpu] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [/kisskb/src/Makefile:1843: drivers] Error 2 make: *** [Makefile:219: __sub-make] Error 2 Command 'make -s -j 32 ARCH=um O=/kisskb/build/linus_um-allmodconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus_um-allmodconfig_um-x86_64 # Build took: 0:07:36.718373