From nobody Sun Feb 8 13:09:03 2026 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 98F93349AE0 for ; Wed, 7 Jan 2026 15:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767798951; cv=none; b=Q1oAQy2eq9gVx14oy8lpS71qrDxbJgj2GwzvLXXDsufobsJzvTOsF01kEE4MDAP1aVdrlZ3mkeEvSQvUvWc+SQQycdj9UkjUflaFl4cBSoV7EGHkg357dLlkU8DyiqTEd2p2uFFqt4JhD0q1BajApYZZ/jTsKS18yWTHyiIR2zQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767798951; c=relaxed/simple; bh=MEYCAJTP+gciIEx+Dxm8aAPbsaociGWG+GPRUZbDF6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fqo/TWQuxKQ495UDDw7oIvV1rgkz67RlIoCRaB8tPAhEiFna+t2jkSjBQWFbv0UxnGk4wZtwou1XA84UBNlD5BqS0ThzEodJ7iDq4p1suglGlLUbUo/1kcV5bXKEDHaIGnTx581ESLj32JBRTbdogT+KD6uGELEEYo83HOSyD0E= 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=Z+Mw3owt; arc=none smtp.client-ip=95.215.58.174 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="Z+Mw3owt" 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=1767798947; 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: in-reply-to:in-reply-to:references:references; bh=1Hk4lLHbn+xMSZg4HI2VBIcbSjPr/5SQlwXAZJ1OODQ=; b=Z+Mw3owt42SxUKLYjnexpJDieK+ZyEgU4us+lurEGaL3dHoHWxIhQ4TP0nhCYxmp2aRgLq B/JuQq2ugwSkqhdkXmI5oHzhFWAZsXyh/ZS3vohctRNEzcnH4N29zc+cBsgB0+r5mwJAA7 YUnZoAY2WfM+Tqmr0A0TjgNNUuPT2As= 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 , Saket Kumar Bhaskar , "David S . Miller" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-patches-bot@fb.com Subject: [PATCH bpf-next v3 2/5] bpf: lru: Factor out bpf_lru_node_reset_state helper Date: Wed, 7 Jan 2026 23:14:53 +0800 Message-ID: <20260107151456.72539-3-leon.hwang@linux.dev> In-Reply-To: <20260107151456.72539-1-leon.hwang@linux.dev> References: <20260107151456.72539-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: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Introduce the helper bpf_lru_node_reset_state to set type and clear ref. No functional change intended. Signed-off-by: Leon Hwang --- kernel/bpf/bpf_lru_list.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c index f4e183a9c28f..b17b05f41900 100644 --- a/kernel/bpf/bpf_lru_list.c +++ b/kernel/bpf/bpf_lru_list.c @@ -41,6 +41,12 @@ static void bpf_lru_node_clear_ref(struct bpf_lru_node *= node) WRITE_ONCE(node->ref, 0); } =20 +static void bpf_lru_node_reset_state(struct bpf_lru_node *node, enum bpf_l= ru_list_type type) +{ + node->type =3D type; + bpf_lru_node_clear_ref(node); +} + static void bpf_lru_list_count_inc(struct bpf_lru_list *l, enum bpf_lru_list_type type) { @@ -85,8 +91,7 @@ static void __bpf_lru_node_move_in(struct bpf_lru_list *l, return; =20 bpf_lru_list_count_inc(l, tgt_type); - node->type =3D tgt_type; - bpf_lru_node_clear_ref(node); + bpf_lru_node_reset_state(node, tgt_type); list_move(&node->list, &l->lists[tgt_type]); } =20 @@ -347,8 +352,7 @@ static void __local_list_add_pending(struct bpf_lru *lr= u, struct bpf_lru_node *node) { node->cpu =3D cpu; - node->type =3D BPF_LRU_LOCAL_LIST_T_PENDING; - bpf_lru_node_clear_ref(node); + bpf_lru_node_reset_state(node, BPF_LRU_LOCAL_LIST_T_PENDING); list_add(&node->list, local_pending_list(loc_l)); } =20 @@ -513,8 +517,7 @@ static void bpf_common_lru_push_free(struct bpf_lru *lr= u, goto check_lru_list; } =20 - node->type =3D BPF_LRU_LOCAL_LIST_T_FREE; - bpf_lru_node_clear_ref(node); + bpf_lru_node_reset_state(node, BPF_LRU_LOCAL_LIST_T_FREE); list_move(&node->list, local_free_list(loc_l)); =20 raw_spin_unlock_irqrestore(&loc_l->lock, flags); @@ -559,8 +562,7 @@ static void bpf_common_lru_populate(struct bpf_lru *lru= , void *buf, struct bpf_lru_node *node; =20 node =3D (struct bpf_lru_node *)(buf + node_offset); - node->type =3D BPF_LRU_LIST_T_FREE; - bpf_lru_node_clear_ref(node); + bpf_lru_node_reset_state(node, BPF_LRU_LIST_T_FREE); list_add(&node->list, &l->lists[BPF_LRU_LIST_T_FREE]); buf +=3D elem_size; } @@ -588,8 +590,7 @@ static void bpf_percpu_lru_populate(struct bpf_lru *lru= , void *buf, again: node =3D (struct bpf_lru_node *)(buf + node_offset); node->cpu =3D cpu; - node->type =3D BPF_LRU_LIST_T_FREE; - bpf_lru_node_clear_ref(node); + bpf_lru_node_reset_state(node, BPF_LRU_LIST_T_FREE); list_add(&node->list, &l->lists[BPF_LRU_LIST_T_FREE]); i++; buf +=3D elem_size; --=20 2.52.0