From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) (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 32C1E2D8DDF for ; Sat, 28 Feb 2026 04:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772252715; cv=none; b=mGd/UwToODTVxVYi7F8T3CpCgQt9Fk1B1RtBElRLRPguCi/EOYmAtozoBBTGhI4DzKekTrkD9wShQk2oo9xFcNDhSBmeBqukGtD3Q/m5lkrVvZxw6AjhCFMTJeG1+FdZjVadnqWx9cWUBo8jaOjlMn1/yoMHdh6tFDDrMwpy9e8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772252715; c=relaxed/simple; bh=IuxMZBMFrqobeGcVZuf94rOyX+J7U6+ehb2d0jQE/ls=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nGnsyjqUz9nzRm0HGyim93HZvnbUCRZv6aFo4taDSJgBbha6f5nJJHAnOuKxyHAhDZ2PzdYBacgZcBpUHwAERyS5HszQ6+nE1zaPKne67nTIGALUcjrxeLKpL3Yb/xWeuapsNcgzATPlv62HttPBl8iqTO/fSqFsSJAY2eKtBZ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lWZnhru3; arc=none smtp.client-ip=209.85.160.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lWZnhru3" Received: by mail-qt1-f201.google.com with SMTP id d75a77b69052e-5033c483b76so279786371cf.1 for ; Fri, 27 Feb 2026 20:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772252713; x=1772857513; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=m5b1vChdq4tLYF4yAE3zvofZaEJCeckIri/kTwraU9E=; b=lWZnhru3wpxbEdoc6VLfVu+l2rdevQP2L/2XQFGhxjf7S1qGAWfMvC328Y34bHG+Y0 kmFd0oHpWmEuiWthpJrzW2vZUJhxmgc86wmAML3htJYqaWKhSsyovh2h3QU8LnivDUig J5C7ZuMzNcyzYvk27GOR2OC7tVw+Gljbz0N3b4dyWclni/hdFHFCapOEoTE17mnv8Uw4 O0Fw9uu+UYRQk8qAA0GMUeLDFiXk5W1/pCBjFnOME3j3naJrEv+xWalgAUZh+vjm65Gy yTJ8+PU3aRCMDuIOHSfP5ssr94cxd1pl/lCN0ysRbXQT1u9nPLWRiKU38D8Q4nlghjBc 5+4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772252713; x=1772857513; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m5b1vChdq4tLYF4yAE3zvofZaEJCeckIri/kTwraU9E=; b=uR6bnzI5+WrrbGh20De5xqgX068GMG9HIoyoGZc0TeXvh70wH6BS4xCQWiRQWFaK7D 8BZK1I+cVO41L2/Cm467+Drui97DHrRN6rRPTSlBikGt4OBxJTj5hM+IdO7Z8T/T9d7R u0DEfI7l8r5zUZf69QTcFJvoqjEPeoypPbre/p8lWoFIMSwiMQiLiQ8Eh5FpXKhD3tKd 1WW6zOSHunPnwDUnu839QuteIuLwWIGOrSCAeM27dBXdNsnMoARv3uT1Ernmqst64blN ybqcF9V8GGQdzHk/2FxjVhLoQhDXkClxb4D+dYkVkChrRnzaXAe8DWYDDT41JwXCKDfO cZQg== X-Forwarded-Encrypted: i=1; AJvYcCVQxA5/EXo/khDsXCMaWSvAF5Mez1SSePO8RbaENETgXIE8G5hzB64OGBjgw+JrnMqFdGfBZR4=@vger.kernel.org X-Gm-Message-State: AOJu0YzNx0Yz8SujW7PCVTEWYjrKSd7DaVx3M7b7PF4L1+OSeMvMIjP4 Dr0UzNe88O7Yylv9WzU7L27nEZETUEFvZ4StQKv+OF9spz9gaI6/DBu0oNbjJZIZ0bRIcZMeTEF /gTjsY3R9qZ4Xvg== X-Received: from qtbfp6.prod.google.com ([2002:a05:622a:5086:b0:4ee:c07:cab7]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:1445:b0:506:6ec8:835 with SMTP id d75a77b69052e-507529bb500mr63712581cf.54.1772252713127; Fri, 27 Feb 2026 20:25:13 -0800 (PST) Date: Sat, 28 Feb 2026 04:25:01 +0000 In-Reply-To: <20260228042503.3726451-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260228042503.3726451-1-edumazet@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260228042503.3726451-6-edumazet@google.com> Subject: [PATCH net-next 5/7] net-sysfs: get rid of rps_dev_flow_lock From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Kuniyuki Iwashima , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Content-Type: text/plain; charset="UTF-8" Use unrcu_pointer() and xchg() in store_rps_dev_flow_table_cnt() instead of a dedicated spinlock. Make a similar change in rx_queue_release(), so that both functions use a similar construct and synchronization. Signed-off-by: Eric Dumazet --- net/core/net-sysfs.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 07624b682b08b24da790d377f1deec4dc0a84269..52fcf7fa58a808e79c1a17c8719830bcfb7c1674 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -1084,7 +1084,6 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue, { unsigned long mask, count; struct rps_dev_flow_table *table, *old_table; - static DEFINE_SPINLOCK(rps_dev_flow_lock); int rc; if (!capable(CAP_NET_ADMIN)) @@ -1128,11 +1127,8 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue, table = NULL; } - spin_lock(&rps_dev_flow_lock); - old_table = rcu_dereference_protected(queue->rps_flow_table, - lockdep_is_held(&rps_dev_flow_lock)); - rcu_assign_pointer(queue->rps_flow_table, table); - spin_unlock(&rps_dev_flow_lock); + old_table = unrcu_pointer(xchg(&queue->rps_flow_table, + RCU_INITIALIZER(table))); if (old_table) call_rcu(&old_table->rcu, rps_dev_flow_table_release); @@ -1161,8 +1157,8 @@ static void rx_queue_release(struct kobject *kobj) { struct netdev_rx_queue *queue = to_rx_queue(kobj); #ifdef CONFIG_RPS + struct rps_dev_flow_table *old_table; struct rps_map *map; - struct rps_dev_flow_table *flow_table; map = rcu_dereference_protected(queue->rps_map, 1); if (map) { @@ -1170,11 +1166,9 @@ static void rx_queue_release(struct kobject *kobj) kfree_rcu(map, rcu); } - flow_table = rcu_dereference_protected(queue->rps_flow_table, 1); - if (flow_table) { - RCU_INIT_POINTER(queue->rps_flow_table, NULL); - call_rcu(&flow_table->rcu, rps_dev_flow_table_release); - } + old_table = unrcu_pointer(xchg(&queue->rps_flow_table, NULL)); + if (old_table) + call_rcu(&old_table->rcu, rps_dev_flow_table_release); #endif memset(kobj, 0, sizeof(*kobj)); -- 2.53.0.473.g4a7958ca14-goog