Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp364271rwb; Fri, 4 Aug 2023 14:08:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcKPilcXyPuHxxuvH7eFZJY0suG2ODrgnjoKBB2N8yKPOmglUjinWD1WwpHACDx5f0GXzT X-Received: by 2002:a17:906:8a66:b0:99b:4210:cc76 with SMTP id hy6-20020a1709068a6600b0099b4210cc76mr809169ejc.28.1691183334320; Fri, 04 Aug 2023 14:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691183334; cv=none; d=google.com; s=arc-20160816; b=ZrghGePXFSmazBdenzGl0Epj3PobgggucODEhhzE4tZPpo6XZ6ioWYJOHsME8xyNzS j4mMS3pDudLDvHb+qb+r53YzNgEFlCH5m7gkD4mORKgAe/voRr3OGoZWzkr+Eyj2Vb3W rMO+1qsn8qghas+fCnUwPCDL5cRjnoO/4FLcEzg72zbJR9P3qGyYv7u3UTX/ZqhgSuem uQatfN/EfUEdA1wViq7No4zLzYAG3O81E6mG89ju7FzBzBX1YH+dZZKldjIM0FNVrhC9 8kZLV1mA8USRLiqE86wrB8F0PSwd98XXUo4AxcouDVm+J0BDZMvzescAjhEURE07SuK2 Ix/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=T80/0bYgu30MFU+Wnz/NYgmnl+rOucIVsK7M/7kfuEs=; fh=1kI7Nj7RuV0hUm4Vh2r3qC6Cx2cg6HCG0tvXYL5kc+I=; b=MfsUyEnMn0buj0LYpQRs+WIyd5hgQHZRbrDObK7Jk7gHelQqnfshhPpGBnZ55TPVn6 7lRu0DRbViuaMvuIVEwDTaSrQduJN1iBkoxg4j6cZNFUtCVQ/jESPkI+WPw3Kn13Q1yc GGy4cgKJI9Jv+Bw0NSUKHv9dsvCsmALf5s0y08CYOs5KDzo8NVxx6W4jiTmvQidKJRDp ON1aIKvPSi/dD/0pOnQMwfJiQzzzUPOBXjEk1YQgE052mj4hu39F3yNkC3cC26qel6Ur qHHaYwHeAJCCQvbDBnYKSE55fQGSmg/+UEG9D/UzjKcBdPEP0qGgWKv9pxIzUzsd8TPu ZLqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QjSytdoS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a17090613cc00b0099364d9f0e0si1938424ejc.540.2023.08.04.14.08.27; Fri, 04 Aug 2023 14:08:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QjSytdoS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbjHDVBn (ORCPT + 99 others); Fri, 4 Aug 2023 17:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjHDVBg (ORCPT ); Fri, 4 Aug 2023 17:01:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D97444C37 for ; Fri, 4 Aug 2023 14:01:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D261620DD for ; Fri, 4 Aug 2023 21:01:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1190C433C8; Fri, 4 Aug 2023 21:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691182890; bh=6OIr/MSf9FOl1vGca/ZPHp09IpYJdHQW2UEvmBNfWkw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QjSytdoSgVP0ySkaaCT/sbm+LxdhYJOuAjrjOYcrHCnzNRAOtZ4U7fCav+OZgMwuh Ua5GlXkmjIQekXuv4FQ+ikO9AmykSWYnAWfVTuwDNh9bCvqEhcNKFhVB9Iwq3od6w9 d9nj7BsgRWBGSbRVr8BYFGb7qWw7SG2uXUkW/c4oSiWHBV9NSe4Qmtpfnc3wfGvri0 bp7N8s8jq3WCcFZy5fp20YNmAdm/KE05mRrVG0q69shSWSGCunevEoaETwN7zvDvbW Mi8hU2kVqKSEFjdULsLjRSQsSZOgptFJQwuN5ewBcFeI2tE5VmfrpqmBwUfy8G6EQq WmKe/EXpW+QKg== Date: Fri, 4 Aug 2023 23:01:24 +0200 From: Simon Horman To: "huangjie.albert" Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Pavel Begunkov , Shmulik Ladkani , Kees Cook , Richard Gobert , Yunsheng Lin , "open list:NETWORKING DRIVERS" , open list , "open list:XDP (eXpress Data Path)" Subject: Re: [RFC Optimizing veth xsk performance 06/10] veth: add ndo_xsk_wakeup callback for veth Message-ID: References: <20230803140441.53596-1-huangjie.albert@bytedance.com> <20230803140441.53596-7-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230803140441.53596-7-huangjie.albert@bytedance.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 03, 2023 at 10:04:32PM +0800, huangjie.albert wrote: > Signed-off-by: huangjie.albert > --- > drivers/net/veth.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index 944761807ca4..600225e27e9e 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -1840,6 +1840,45 @@ static void veth_set_rx_headroom(struct net_device *dev, int new_hr) > rcu_read_unlock(); > } > > +static void veth_xsk_remote_trigger_napi(void *info) > +{ > + struct veth_sq *sq = info; > + > + napi_schedule(&sq->xdp_napi); > +} > + > +static int veth_xsk_wakeup(struct net_device *dev, u32 qid, u32 flag) > +{ > + struct veth_priv *priv; > + struct veth_sq *sq; > + u32 last_cpu, cur_cpu; > + > + if (!netif_running(dev)) > + return -ENETDOWN; > + > + if (qid >= dev->real_num_rx_queues) > + return -EINVAL; > + > + priv = netdev_priv(dev); > + sq = &priv->sq[qid]; > + > + if (napi_if_scheduled_mark_missed(&sq->xdp_napi)) > + return 0; > + > + last_cpu = sq->xsk.last_cpu; > + cur_cpu = get_cpu(); > + > + /* raise a napi */ > + if (last_cpu == cur_cpu) { > + napi_schedule(&sq->xdp_napi); > + } else { > + smp_call_function_single(last_cpu, veth_xsk_remote_trigger_napi, sq, true); > + } nit: no need for braces in the above. if (last_cpu == cur_cpu) napi_schedule(&sq->xdp_napi); else smp_call_function_single(last_cpu, veth_xsk_remote_trigger_napi, sq, true); ...