[RFC,Optimizing,veth,xsk,performance,02/10] xsk: add dma_check_skip for skipping dma check
Message ID | 20230803140441.53596-3-huangjie.albert@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1182722vqx; Thu, 3 Aug 2023 07:21:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlErA+avRXETQ0GR2DQuMNxYcVpiodMTZJfPYrB5V6zXgVkapfnaXkn3wlB388s2iAtd3T19 X-Received: by 2002:aa7:d5ca:0:b0:522:2019:2020 with SMTP id d10-20020aa7d5ca000000b0052220192020mr7134565eds.17.1691072480188; Thu, 03 Aug 2023 07:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691072480; cv=none; d=google.com; s=arc-20160816; b=bzegPd0E5+yjFzT+L/wZIVq9/mIHFXHRgDbpfU/0iVsSkTA6aTLTLNaLVUYcU0Xvc1 PzludMwbijEOC6AwEjn3LwkfaPIIJoFRKrTcW+gvmyeAAMmWsZqTPLhFXIM2B9WUTgYV s3aDMsSsP81xec5xzLnz1jaAriXWBX4rdP1lYZ4LsfTx8HZVTeKxSClIv6awJdhwgVZr ArsVQctiRnsYtNShzxrPLYnbWCqtY4ndRQJRpFY26AJlLAsVqY+49tx9x9jJ0EtHznDg 1aDUtslMqpB3ufYKd8upF2x7aOdehM7FiqX3T9aK5+VaF/Nya/u+w/BcZa3Pgv6OJ6Mc kLPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U+EKFuLLGda3oiEd1qoWkJ3WKIdEe7yI+fFIgxoez3I=; fh=pQMjDmBpkga//+9OKrKQl28a8lyKhz4s+dSSuCJIV1I=; b=cLm6zktH1WWMmmkdk6IyF/I4W2waNVoQ0/+PBa5/R1AbFuamq+eWXQOWKyYL/M3EQd 1NxadRYVMFXykh/KRJZ8kBnUE9Mo9nSxqoMAFJe0lasEM1TDG4fkTU9Kqo/omFXMRtFI AnoG1GGKdGyQbG52wLsor2SP1R9599Q70wjuJcISZ+Xq8R49B/vSjS3gDlkLXugp0wZs rU5RB4ATfx8/jh+7NojoAWozaWz8jS8Oi+52xhxy0cizhxiNr9tr9xLSnMLrGiBnh1gJ YM5M3tJwUuZ0azUIzFqZ7MwFLPVRmp5kezkIH6qQjeoz6anp5D5y5cQRWD+U+yVwfZUs Ioog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="fwe4/jwU"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a50fb0b000000b0052228f8c22csi11962735edq.58.2023.08.03.07.20.52; Thu, 03 Aug 2023 07:21: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=@bytedance.com header.s=google header.b="fwe4/jwU"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235494AbjHCOHJ (ORCPT <rfc822;guoshuai5156@gmail.com> + 99 others); Thu, 3 Aug 2023 10:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233957AbjHCOGv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 3 Aug 2023 10:06:51 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28EA4422A for <linux-kernel@vger.kernel.org>; Thu, 3 Aug 2023 07:05:35 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bba48b0bd2so6835505ad.3 for <linux-kernel@vger.kernel.org>; Thu, 03 Aug 2023 07:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1691071534; x=1691676334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U+EKFuLLGda3oiEd1qoWkJ3WKIdEe7yI+fFIgxoez3I=; b=fwe4/jwUmizIlQByLG/O10dPGK2dq5O1KyDOna7TN71l452ImeRZyualxarybGdLTE KSINW/D7yJGI/aFLQkhxK3+64JQiodpZvCwoGQg9YTTRbW5UIBKGDIGqSCDZc0josq2d 2P9Mp7v9JLZYEnKdld7C+HuTI+F9QlP+06UlKoisZWQYVZTBEVOxhHgulrtl2LX2dsLj T14TWHGsmOO/0dAKlV2/RtTPFXi7/aWi6ccZCUGBq76s4ZGEvQgdo9wugFVEtweVmFCk koL+jVBuohHproWlNCAlhWsk57vd+MbRFaTzJhLqjDR+JpizjbmPbOzaXkgS2AvXJWJo PDtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071534; x=1691676334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U+EKFuLLGda3oiEd1qoWkJ3WKIdEe7yI+fFIgxoez3I=; b=BYo54lsZlZjxW7uQxz/tcpXWf4OjgXMIL7rt6yFgBBOLeHOcVf4WSNcMdizREqNuIt yyb5ipNO10S7J7hmhvZLWp6Sj3ns5amRKWMjLz7PwHiABtMxerMTcNSyqjJ59nIE+BJa B4WFSSChzv28Xzl5FMPB8ZJkCxS7uBrPncUNUaaM7PW+ms/xL5Aj85mphBQbLI7HhCuv tb764DDI9kTVHLz3wTMwBaCDLLnArYqVbuT30pOCKNeREcMSkl4ciiglrMoO2+UYeMmL LCyYRmKo76gp/Im9N1Csv8USKxEv228j5A2WBmrSMomLCJ838mLcTFsHPx4xZf67biZE 5a4g== X-Gm-Message-State: ABy/qLZwBYvjH7F10AFG3bYZ5W1LxpCso2sqjzySijWIC6ocgVcCG7BT R5djjrK3eAI+pvI60jKL42uEBw== X-Received: by 2002:a17:902:e811:b0:1bc:2c79:c6b5 with SMTP id u17-20020a170902e81100b001bc2c79c6b5mr7539181plg.4.1691071533982; Thu, 03 Aug 2023 07:05:33 -0700 (PDT) Received: from C02FG34NMD6R.bytedance.net ([2001:c10:ff04:0:1000::8]) by smtp.gmail.com with ESMTPSA id ji11-20020a170903324b00b001b8a897cd26sm14367485plb.195.2023.08.03.07.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:05:33 -0700 (PDT) From: "huangjie.albert" <huangjie.albert@bytedance.com> To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: "huangjie.albert" <huangjie.albert@bytedance.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@kernel.org>, Magnus Karlsson <magnus.karlsson@intel.com>, Maciej Fijalkowski <maciej.fijalkowski@intel.com>, Jonathan Lemon <jonathan.lemon@gmail.com>, Pavel Begunkov <asml.silence@gmail.com>, Shmulik Ladkani <shmulik.ladkani@gmail.com>, Kees Cook <keescook@chromium.org>, Richard Gobert <richardbgobert@gmail.com>, Yunsheng Lin <linyunsheng@huawei.com>, netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list), bpf@vger.kernel.org (open list:XDP (eXpress Data Path)) Subject: [RFC Optimizing veth xsk performance 02/10] xsk: add dma_check_skip for skipping dma check Date: Thu, 3 Aug 2023 22:04:28 +0800 Message-Id: <20230803140441.53596-3-huangjie.albert@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230803140441.53596-1-huangjie.albert@bytedance.com> References: <20230803140441.53596-1-huangjie.albert@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773218016703609648 X-GMAIL-MSGID: 1773218016703609648 |
Series |
|
|
Commit Message
黄杰
Aug. 3, 2023, 2:04 p.m. UTC
for the virtual net device such as veth, there is
no need to do dma check if we support zero copy.
add this flag after unaligned. beacause there are 4 bytes hole
pahole -V ./net/xdp/xsk_buff_pool.o:
-----------
...
/* --- cacheline 3 boundary (192 bytes) --- */
u32 chunk_size; /* 192 4 */
u32 frame_len; /* 196 4 */
u8 cached_need_wakeup; /* 200 1 */
bool uses_need_wakeup; /* 201 1 */
bool dma_need_sync; /* 202 1 */
bool unaligned; /* 203 1 */
/* XXX 4 bytes hole, try to pack */
void * addrs; /* 208 8 */
spinlock_t cq_lock; /* 216 4 */
...
-----------
Signed-off-by: huangjie.albert <huangjie.albert@bytedance.com>
---
include/net/xsk_buff_pool.h | 1 +
net/xdp/xsk_buff_pool.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
Comments
On Thu, Aug 03, 2023 at 10:04:28PM +0800, huangjie.albert wrote: > for the virtual net device such as veth, there is > no need to do dma check if we support zero copy. > > add this flag after unaligned. beacause there are 4 bytes hole nit: beacause there are 4 bytes hole -> Because there is a 4 byte hole.
diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h index b0bdff26fc88..fe31097dc11b 100644 --- a/include/net/xsk_buff_pool.h +++ b/include/net/xsk_buff_pool.h @@ -81,6 +81,7 @@ struct xsk_buff_pool { bool uses_need_wakeup; bool dma_need_sync; bool unaligned; + bool dma_check_skip; void *addrs; /* Mutual exclusion of the completion ring in the SKB mode. Two cases to protect: * NAPI TX thread and sendmsg error paths in the SKB destructor callback and when diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c index b3f7b310811e..ed251b8e8773 100644 --- a/net/xdp/xsk_buff_pool.c +++ b/net/xdp/xsk_buff_pool.c @@ -85,6 +85,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs, XDP_PACKET_HEADROOM; pool->umem = umem; pool->addrs = umem->addrs; + pool->dma_check_skip = false; INIT_LIST_HEAD(&pool->free_list); INIT_LIST_HEAD(&pool->xskb_list); INIT_LIST_HEAD(&pool->xsk_tx_list); @@ -202,7 +203,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool, if (err) goto err_unreg_pool; - if (!pool->dma_pages) { + if (!pool->dma_pages && !pool->dma_check_skip) { WARN(1, "Driver did not DMA map zero-copy buffers"); err = -EINVAL; goto err_unreg_xsk;