From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 AF6803F6614 for ; Fri, 10 Jul 2026 09:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783677555; cv=none; b=JNrer6l39cozuiimefEC97FCFSlSAZmP8YwT6+Bi8r0u4SwBBEwS+0qpyrFztxWr/7SgC4VZrFXPNa4qvJSivBbq3QSzkJFhT0LKKC70BJzXJ9syAPRNwlTZQTX6IGXw0UwpGx75Qmz5/lzsAXhYJEWXc8C77APMXgMQclR7FuQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783677555; c=relaxed/simple; bh=+z2jQv5OERjUiePae826KN2zBrzJjcXbMTIJZOwzkGM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ezx83oxLQRQr8G0PKJmk8MeRCZG+ESmAYinBBQuydisjm3jlbpqCEZZ+MG5dR+u4bYbhLU+i64TeSyS791JKecVWZ79yAEJ/2ojq6HvVws8fAAMM9O1prTPSydKjqYKTmRoWCspGYFMX4WHbQ2Lfki602WjJ4NSPf5fZ0m9pzNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BLPBnpgq; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=GDKKFzKc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BLPBnpgq"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="GDKKFzKc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783677552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e2pOdwkBhpBjkUlhAXpPxmMK4yMM34DSXxSSkOBQ4Yg=; b=BLPBnpgqHEj98eJAW8rh9hFPRiLbkJZuLcWkdxHMqyd75F+c/sWhs4LPBnJaB+YOi75mx+ /yof9KwKRL8ZogzFbG20mbaDnWNCnZ8AJGpclIDjA/IcLG3tEx02E33cWouv2u9RMmk4dn v6y9C3I2OIiiCFRCdyP9kfI4K8/ZjWo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-507-zQuIQ1vDP5-U2oLTCsrazg-1; Fri, 10 Jul 2026 05:59:11 -0400 X-MC-Unique: zQuIQ1vDP5-U2oLTCsrazg-1 X-Mimecast-MFC-AGG-ID: zQuIQ1vDP5-U2oLTCsrazg_1783677550 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-493caa3c54eso5989105e9.2 for ; Fri, 10 Jul 2026 02:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783677550; x=1784282350; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=e2pOdwkBhpBjkUlhAXpPxmMK4yMM34DSXxSSkOBQ4Yg=; b=GDKKFzKcvA2QMVpwTsZZZ/xm0jDl8K6aquUZ56l8FKdxo0ohqwjwo1nSuF3Cps6m7r HyM66jKpquozYmwKr6ALtYFfcP8xJcIeW45riuLI8hkezUaSu5q7rk9bF/l7A2DbmaEh NMbrGPhASCtJ0gSj9DAqkFR62NvhpsKd87vmdX51JN8yhuH0uwQ4aJ/TKL5grvUpMSVR 48WzZnLTeBEsDCwhRUM25QdZh84A2U4q+Rhd4a0YRQapgrik+QqFI31K5x3WqbeGQ64Z pBYkk1w+dqrVzetm63aW8iGuaBbnkGkAU8Wd542SauhRn1j/1rgSb2NstQurmFDtyFDa Vo+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783677550; x=1784282350; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e2pOdwkBhpBjkUlhAXpPxmMK4yMM34DSXxSSkOBQ4Yg=; b=OT7VZ2PqG77EviTYzjETdDUxrYoYZYfMjhpztOm9riQvTcvUKsc28R6JFzn1iHRlk6 Z5lB9B93bGyQWbb6ks3dPDEobw8WzSrN9X7kAZiHTCyC5N1H+0qnhveTKbhBZpopZoIX Qaum1Ri9UXXqvTBz8YfzBj71KaKy8qy0NinX45Io3JhxeNtjZLI0IK5YTC9+QBfoVlH1 CxkXbre32VZ1EJXNcO8mlfzog2IY7RiRl8v4Th3hY/m/o9RxyhZlBPRrWtGfJMLdyhE7 aqWw/yhd8zWjOohOeDBZKVYA4KF4+VP6R4qApXCRfHCILuO7kJKgYlf6esdEGM9GWkEc Cbig== X-Forwarded-Encrypted: i=1; AHgh+RrrZpUfzh0G+MRBosxVCRkVaGiUsfAtW5Lu+InRVPLWFz/HWkhGYWmvWUgDeHeXucqwDwGdYN/rbkyrpqg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw24O87A5GC+RCj+FgyPcC/2zAzI44xEo26SElUcyPmsP19m8rA duQ2897WOkcZjv6v4ei+eUTmPxFgfjtx81DCXohZc2K70swvV9eX93c4QYAes33lcrgogiHvG00 WBTgmmptKbIHteriHQembMCRJR+PqY1zH/4JH4OCm56DmWiiAJXc47HDNFPTDUveOMQ== X-Gm-Gg: AfdE7clkWmri/yLrd1M9He3Z1IoVBlKXeOXO5ctQl4MahRzxf2+4zFwFJmP9kDa8mGQ TasMPGiLm9IYycjx66PvqzI2J5udR0cz49C/DDgKVcPpv52I/m+i//KYS5uJzWpF6m1sW0QzzLe ALprAQd3znEvT+cGqTyEOuJlilAvtXYlA1Awh9l4cdIhDyG0ljRoPvCvA80AEFQln4kwDidhujO HrI+/DvcGbGPT02z8O0hQEaeb6zMg+WsM5O7BNXPCyAfafzwhYsv0vnXsX0Y45IoLAxDkiioNgI H03S2M8ATJ3jQ60o7/C3s8R29SnNDXkWgkRqPJQO5I6R+TVBvPGGptjDOAIT0k1v0lKLG6pMH1p pdCSjzjgrqGGTIjgKB8jOTrkA6lo9u3TEcASe+uMxtBfDQ5lhrW2Y2pWuMP/aif4ZOwDa2QwzjZ jK1zRNomEP3rtE X-Received: by 2002:a05:600c:4fc6:b0:492:43d2:9e6e with SMTP id 5b1f17b1804b1-493e68391c1mr107994035e9.9.1783677549967; Fri, 10 Jul 2026 02:59:09 -0700 (PDT) X-Received: by 2002:a05:600c:4fc6:b0:492:43d2:9e6e with SMTP id 5b1f17b1804b1-493e68391c1mr107993585e9.9.1783677549421; Fri, 10 Jul 2026 02:59:09 -0700 (PDT) Received: from ?IPV6:2a0d:3344:5521:6b10:58fd:68f:7756:389d? ([2a0d:3344:5521:6b10:58fd:68f:7756:389d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493eb74b3edsm151477245e9.15.2026.07.10.02.59.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jul 2026 02:59:08 -0700 (PDT) Message-ID: Date: Fri, 10 Jul 2026 11:59:07 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net/rps: consolidate RPS dispatch into netif_rps() helpers To: Jemmy Wong , "David S . Miller" , Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org Cc: Simon Horman , Andrew Lunn , Kuniyuki Iwashima , Stanislav Fomichev , Samiullah Khawaja , Hangbin Liu , Krishna Kumar , linux-kernel@vger.kernel.org References: <20260702152830.39065-1-jemmywong512@gmail.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20260702152830.39065-1-jemmywong512@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/2/26 5:28 PM, Jemmy Wong wrote: > From: "Jemmy Wong" > > The RPS steering logic in netif_rx_internal(), netif_receive_skb_internal() > and netif_receive_skb_list_internal() was open-coded three times, each with > its own #ifdef CONFIG_RPS block and manual rcu_read_lock()/unlock() pairs. > > Factor it into two helpers, netif_rps() for the single-skb path and > netif_rps_list() for the list path, and switch the callers to > guard(rcu)/scoped_guard(rcu). Please be aware of: https://elixir.bootlin.com/linux/v7.1.2/source/Documentation/process/maintainer-netdev.rst#L400 > @@ -5695,33 +5727,20 @@ EXPORT_SYMBOL_GPL(do_xdp_generic); > > static int netif_rx_internal(struct sk_buff *skb) > { > - int ret; > + int ret = NET_RX_UNHANDLED; > + unsigned int qtail; > > net_timestamp_check(READ_ONCE(net_hotdata.tstamp_prequeue), skb); > > trace_netif_rx(skb); > > -#ifdef CONFIG_RPS > - if (static_branch_unlikely(&rps_needed)) { > - struct rps_dev_flow voidflow, *rflow = &voidflow; > - int cpu; > - > - rcu_read_lock(); > - > - cpu = get_rps_cpu(skb->dev, skb, &rflow); > - if (cpu < 0) > - cpu = smp_processor_id(); > + scoped_guard(rcu) > + ret = netif_rps(skb); > + if (ret != NET_RX_UNHANDLED) > + return ret; This function is performance critical and RCU lock is not a no-op. I *think* this will add an unneeded rcp barrier when RPS is compile enabled and `static_branch_unlikely(&rps_needed)` evaluate to false. At very least you should prove that the generated code is no worse than the current one. /P