Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp368566rwb; Fri, 4 Aug 2023 14:13:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz86MV+fLGVuzzHuNqThkuH2eSL1eWpnBQ6oVdaMtxb+zHznedHRrBhSKKimfTNNSmEcwz X-Received: by 2002:a05:6a20:96ce:b0:12f:1f1f:b506 with SMTP id hq14-20020a056a2096ce00b0012f1f1fb506mr2399125pzc.21.1691183600947; Fri, 04 Aug 2023 14:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691183600; cv=none; d=google.com; s=arc-20160816; b=JUNW2Sy6+m2Skr6fr6xmqgxkD51/u034Uekqfjxv3HcfyH/TEQdsvOSuWAMguG6ZF8 pddBAvb18erVileT4zeFkqx4AH6fSvmYQVsescPRDsgcpKn0OwnDXlhRoHZTQnbJpfYI jV3MvJNsN9ELae4O+jQmm5AUYANl88WjIINU0QCfXbS71k3YU8arYXqXhKqXmOXQHSUn zm6y1M3b5Pu2Ca4yxkFYQOPykltP1ozhDjahrUUFw6CE9yq+0BsRzlRo5ZdUfb40qmJR hGtp7TxCq0g7zHiBpu13xuBzonEVQlWt1z5TbUStWSGtToOCdugix9DLyoOs3O4vAOai DwAg== 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=jwqhRNY1+sc7omksT+BxrKnXlbe0ux5sSPvK4s8l46w=; fh=Aibuik4wEM3sK0HQiUPuXI5z9bCKn0Rsjobik9Fc7to=; b=xL3EcOvoklZzjbkRZGSjhHMnT9WTpfaoTlYqFPUJ24ccCX7uXB0+cuOqGPShDAt9jA dxsDA5TFIbz+Ai+Itg1SL6wC13cs+YDfFcDrwGCVNIrOPjJetQbpANDSMN1crv4OFNK9 nBH8bqvv3GM2ykcWxyCiXCJCgzdeOW6Ffu5eJHYtzLQKTryJxB6blcHGgw7c9BYTY/Sp nmQGhUTuDsQlY6Wqv+fFeh297Nv2sRDIbUzqp7XZ4m9jEni2eWO+eDLGXGPuTom3fMZC JYf/7NZ6dTnKXXGtSx7YHMQhEktKuxrqjWMh05mPz374eV5/zvzOI+GLDGkokgzOAI7K Ldjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E16slqox; 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 k191-20020a6384c8000000b005503f25aac2si2186517pgd.241.2023.08.04.14.13.08; Fri, 04 Aug 2023 14:13:20 -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=E16slqox; 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 S230353AbjHDVFn (ORCPT + 99 others); Fri, 4 Aug 2023 17:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230398AbjHDVFe (ORCPT ); Fri, 4 Aug 2023 17:05:34 -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 6BD475592 for ; Fri, 4 Aug 2023 14:05:09 -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 00D28620DD for ; Fri, 4 Aug 2023 21:05:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B429AC433C8; Fri, 4 Aug 2023 21:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691183108; bh=gJt669rsfGxg9edElmNCRVGPd1QDKDSpXCM3ZtENT2M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=E16slqox7a3VQa4utXPuURhDCW1McbB9kCRJaIIHQqNEWriaHXjOMhwmMsmKV7jiN uRakANi+tNkYAPlU2THvsLNpwBAwzyS2oeshEuj/nFSMVR1pgqSouihj5JOqKAH1Dy j9XKloVg2zGbqI0+gQX1ybOBB4fhR+2KDk9ujyEgsjk8CbndAVK2vPrXFwmNQZQz21 U0uWPIw3GfwAGpOSDj8Y9xStDDthanaNGeC/qslT3UE5M9KhfOY4H0bCE0mi+tsMal aH7vu8rul4eAR1ztuTQX6c4I/dGW14tf/ayiPG/sqKY4iRgQisRmipSex2LKTB837n X3JOz9kBX/A/A== Date: Fri, 4 Aug 2023 23:05:02 +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 , Yunsheng Lin , Kees Cook , Richard Gobert , "open list:NETWORKING DRIVERS" , open list , "open list:XDP (eXpress Data Path)" Subject: Re: [RFC Optimizing veth xsk performance 09/10] veth: support zero copy for af xdp Message-ID: References: <20230803140441.53596-1-huangjie.albert@bytedance.com> <20230803140441.53596-10-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230803140441.53596-10-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:35PM +0800, huangjie.albert wrote: ... > +static struct sk_buff *veth_build_skb_zerocopy(struct net_device *dev, struct xsk_buff_pool *pool, > + struct xdp_desc *desc) > +{ > + struct veth_seg_info *seg_info; > + struct sk_buff *skb; > + struct page *page; > + void *hard_start; > + u32 len, ts; > + void *buffer; > + int headroom; > + u64 addr; > + u32 index; > + > + addr = desc->addr; > + len = desc->len; > + buffer = xsk_buff_raw_get_data(pool, addr); > + ts = pool->unaligned ? len : pool->chunk_size; > + > + headroom = offset_in_page(buffer); > + > + /* offset in umem pool buffer */ > + addr = buffer - pool->addrs; > + > + /* get the page of the desc */ > + page = pool->umem->pgs[addr >> PAGE_SHIFT]; > + > + /* in order to avoid to get freed by kfree_skb */ > + get_page(page); > + > + hard_start = page_to_virt(page); > + > + skb = veth_build_skb(hard_start, headroom, len, ts); > + seg_info = (struct veth_seg_info *)kmalloc(struct_size(seg_info, desc, MAX_SKB_FRAGS), GFP_KERNEL); There is no need to explicitly case the return value of kmalloc, as it returns void *. seg_info = kmalloc(struct_size(seg_info, desc, MAX_SKB_FRAGS), GFP_KERNEL); ...