From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0D6E35CB6B for ; Mon, 19 Jan 2026 14:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768832637; cv=none; b=F1L2cmj0aLqoTpYNeCeLGIRHEhPAFaM4fKKfVHn0LFxKwymPtCDrZiSboHeLZTNIB7ZNfy4rc1dmYK1eTa+zF0VMns7N6AFeVXrgEHO83UFV6INW82GX7PjZ1r3wMFC0wcUg78tdOT/AyRUgVnEVokv3OCegSLudAMmEKjE4pI0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768832637; c=relaxed/simple; bh=zVGZh7eFDDPz8YwCWOxi/FDxpsyLCNTp4r0ypycyE+0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YZRvkzc9favahn2AlnZT84HJTntL57wMPkrIZl8aDl8H34FccTiS2gjholB+TalQ7kR6Kme6GBd2SM1+y/672jdg0YrlBoFWTVTO5RoXuRTxcgXnrTnlzyUM//kOOD/YovtmOf4LC7ZlD7OB1wRK7cTgSLvFmoPodbWwlvLVD6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=KoPGdF5E; arc=none smtp.client-ip=91.218.175.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="KoPGdF5E" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768832623; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3T80oN8F5GALi0Utz+Tw6OTmbiEVk1RUB4ZQwlgHphc=; b=KoPGdF5EZZ7HlwpXKoAv0qVESjP/Sbh4uL6L/VcRMqyJ0mgCXmUnFjCynxsilJEMJK17it pF5xBNu4tGBGv27+tBe8LKcApkPQT7ZHGghcn8PhJDpqpFUgJXFsQSLZJcMeEQI53fXbS9 ldaR2YmCGNdWdFgk3bjX7wnCITiW2OY= From: Leon Hwang To: bpf@vger.kernel.org Cc: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Leon Hwang , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-patches-bot@fb.com Subject: [PATCH bpf-next 0/3] bpf: Avoid deadlock using trylock when popping LRU free nodes Date: Mon, 19 Jan 2026 22:21:17 +0800 Message-ID: <20260119142120.28170-1-leon.hwang@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Switch the free-node pop paths to raw_spin_trylock*() so callers don't block on contended LRU locks. This is a narrower change than Menglong's approach [1], which aimed to eliminate the deadlock entirely. The trylock-based approach avoids deadlocks in long-lived critical sections, while still allowing locking in short-lived ones. Although it does not completely eliminate the possibility of deadlock, it significantly reduces the likelihood in practice. LRU-related deadlocks have been observed multiple times, including: - [syzbot] [bpf?] possible deadlock in bpf_lru_push_free (2) [2] - Re: [PATCH bpf v3 0/4] bpf: Free special fields when update hash and local storage maps [3] - Raw log of CI failure [4] BTW, this series also factors out the bpf_lru_node_set_hash() helper, along with a comment describing the required ordering and locking constraints. Links: [1] https://lore.kernel.org/bpf/20251030030010.95352-1-dongml2@chinatelecom.cn/ [2] https://lore.kernel.org/bpf/69155df5.a70a0220.3124cb.0018.GAE@google.com/ [3] https://lore.kernel.org/bpf/CAEf4BzbTJCUx0D=zjx6+5m5iiGhwLzaP94hnw36ZMDHAf4-U_w@mail.gmail.com/ [4] https://github.com/kernel-patches/bpf/actions/runs/20943173932/job/60181505085 Leon Hwang (3): bpf: Factor out bpf_lru_node_set_hash() helper bpf: Avoid deadlock using trylock when popping LRU free nodes selftests/bpf: Allow -ENOMEM on LRU map updates kernel/bpf/bpf_lru_list.c | 35 ++++++++++++++----- .../bpf/map_tests/map_percpu_stats.c | 3 +- 2 files changed, 28 insertions(+), 10 deletions(-) -- 2.52.0