Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7025025pxb; Wed, 17 Feb 2021 22:16:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJylVH6nM9BJQXRuDio5h1ASegWc3IiUBsC4zwb0Flami2qxAK5vj7UaIUH+t8L8n0w8H2jf X-Received: by 2002:a17:907:7252:: with SMTP id ds18mr2425622ejc.239.1613628964947; Wed, 17 Feb 2021 22:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613628964; cv=none; d=google.com; s=arc-20160816; b=hHQXiNRzpw6VfmmPBtjtqeJW9w8Q1UxQXyWfnI1G7GcslmE1ZiTEB8t6nqgD8ZiOdV zZ3fXamJrHldWpoyvdcm4KPyxZE2X/QRVBpgwjqDRklzMtsVGL7ARYkBPE7Am20Du+qM fG4HNZQefgBoCNUxLFRD6a5fOyARIR5GV9fiyTFRWweGVGo0KuVvSmU7EpgeW4fdY8OP 9z+T1X56R3dMzfWryvxryxD/2Ja2b9sv+pV38epgETmLnOZ7Cc4+h1dsG6lA4tJDyTaw VqrRVN1B8UXdcA7etAOMPMeDSF2cQazDzdZMa+QfS9o271VC0CC20retmswew/ibFnsQ wuOg== 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:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=1MiXI1ghzyDJbbFlIYODMYli9/N2JgiwurFchZ9firo=; b=g2S96GEgrEexWN/Z4ydMb1Hf57qxVMsDMCEUi2rEijKkMM84Ns0oN/ar3BmlYIvke9 zU6E5wO1oRBcP9u6Nh3vLibVEQUfnaWYoxBVimtoCNa0FjMgxj2Io1u9P4VahzScIYtF BhQ71bq/IkOdq+J+z4hxudcjMuwb9uoRnlJcvLyYvK//v1l0ozs7kP+HRVzFtqCUFv2s BRi7Sx8gbtsXjf5PkLpgF5E7SKenu1rYjJYRUNT3Y27yeW1WRtD5VGJdosRDe70ABwGH EGZMDg7ApJRbHkW3nF9IZqwEyaNuRlBesDa0B7ckiuZd0dWCm8LeIJkxRlpatNllNRTk vWzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dEBmN7pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si3087063edk.115.2021.02.17.22.15.40; Wed, 17 Feb 2021 22:16:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dEBmN7pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbhBRGOO (ORCPT + 99 others); Thu, 18 Feb 2021 01:14:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231384AbhBRFvz (ORCPT ); Thu, 18 Feb 2021 00:51:55 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B87D2C061786; Wed, 17 Feb 2021 21:51:14 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id e2so524070ilu.0; Wed, 17 Feb 2021 21:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-transfer-encoding; bh=1MiXI1ghzyDJbbFlIYODMYli9/N2JgiwurFchZ9firo=; b=dEBmN7prep6VSAQphqNi5WtJV6Fv9Y0sSG8g+DH+WqFF3soIzqH/sc3anKxEM7hqgF oybeCMKfrDFUCehJlWR731HqDZ+AaoF+GSgKRLMvbFjc3ILgnrh9SIqNnEt/gYIck31K 2ymaCUdFyNORx5Dfw3Xub+LTH9JMqzRlRKoQ+bsOjC90fWtvmB9TdWKVnIDvq/vMIpdZ lFtOEJNbyVZj2W6Mr747dHg3aIR+qgKtEly+VdDTZ2DXFJC+fZk0Et5K6UjQMt7VLrV5 ti7l3VZGFz4Ddwhc3nEyp4yhuBRhQyv+akSh3+KVViFaTs6FtF0QhmZ6xNePtHPnRgPZ uyJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version:content-transfer-encoding; bh=1MiXI1ghzyDJbbFlIYODMYli9/N2JgiwurFchZ9firo=; b=eOEf7/cpnpGD+pO3TgYw31zJX0F5Aa0cOVHdLT/XXoeJF5S/ZRzrkENUDrKbI4CJvg mj/e1oXr9TS8Jdiul2hsM+s9Lr5a8mXqayzhaZTDhaLKzUMBDBa5S5+XxnM8dUziW89L 1oD9IetLU4WnEjzZ3P2BW3TWn6v9vKqWOWuAOLnRhHfV4ZMbaWIDpNGg12tp3NIE32su tzNFWoGxPzsEnUSnV5HYW9i3k9L1niqOxIMoPUqXHrBVJGcF2NIwNgoXYVeAOSyqOcAi HLiBOH1/mGOerqSuAjuGsIoAixwt2XQePsQXXuvk3WcnEOp6L0zIJeVK0F/sc5+47i+B t0kQ== X-Gm-Message-State: AOAM5325gGxDzV9ExCvGmB2IcoZKtZ9AjY9GJe9YnVjlGPqaCvsm/l+f RHg2peX47UOZV332Jd8z3FA= X-Received: by 2002:a05:6e02:1a25:: with SMTP id g5mr2470754ile.73.1613627474096; Wed, 17 Feb 2021 21:51:14 -0800 (PST) Received: from localhost ([172.243.146.206]) by smtp.gmail.com with ESMTPSA id e195sm3795840iof.51.2021.02.17.21.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 21:51:13 -0800 (PST) Date: Wed, 17 Feb 2021 21:51:07 -0800 From: John Fastabend To: Xuan Zhuo , John Fastabend Cc: "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jonathan Lemon , Alexei Starovoitov , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Paolo Abeni , Eric Dumazet , Dust Li , Alexander Lobakin , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Alexander Lobakin , Daniel Borkmann , Magnus Karlsson Message-ID: <602e004b4286_1e7da2082a@john-XPS-13-9370.notmuch> In-Reply-To: <1613615475.9629707-1-xuanzhuo@linux.alibaba.com> References: <602db8cc18aaf_fc5420827@john-XPS-13-9370.notmuch> <1613615475.9629707-1-xuanzhuo@linux.alibaba.com> Subject: Re: RE: [PATCH v7 bpf-next 6/6] xsk: build skb by page (aka generic zerocopy xmit) Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xuan Zhuo wrote: > On Wed, 17 Feb 2021 16:46:04 -0800, John Fastabend wrote: > > Alexander Lobakin wrote: > > > From: Xuan Zhuo > > > > > > This patch is used to construct skb based on page to save memory copy > > > overhead. > > > > > > This function is implemented based on IFF_TX_SKB_NO_LINEAR. Only the > > > network card priv_flags supports IFF_TX_SKB_NO_LINEAR will use page to > > > directly construct skb. If this feature is not supported, it is still > > > necessary to copy data to construct skb. > > > > > > ---------------- Performance Testing ------------ > > > > > > The test environment is Aliyun ECS server. > > > Test cmd: > > > ``` > > > xdpsock -i eth0 -t -S -s > > > ``` > > > > > > Test result data: > > > > > > size 64 512 1024 1500 > > > copy 1916747 1775988 1600203 1440054 > > > page 1974058 1953655 1945463 1904478 > > > percent 3.0% 10.0% 21.58% 32.3% > > > > > > Signed-off-by: Xuan Zhuo > > > Reviewed-by: Dust Li > > > [ alobakin: > > > - expand subject to make it clearer; > > > - improve skb->truesize calculation; > > > - reserve some headroom in skb for drivers; > > > - tailroom is not needed as skb is non-linear ] > > > Signed-off-by: Alexander Lobakin > > > Acked-by: Magnus Karlsson > > > --- > > > > [...] > > > > > + buffer = xsk_buff_raw_get_data(pool, addr); > > > + offset = offset_in_page(buffer); > > > + addr = buffer - pool->addrs; > > > + > > > + for (copied = 0, i = 0; copied < len; i++) { > > > + page = pool->umem->pgs[addr >> PAGE_SHIFT]; > > > > Looks like we could walk off the end of pgs[] if len is larger than > > the number of pgs? Do we need to guard against a misconfigured socket > > causing a panic here? AFAIU len here is read from the user space > > descriptor so is under user control. Or maybe I missed a check somewhere. > > > > Thanks, > > John > > > > Don't worry about this, the legality of desc has been checked. > > xskq_cons_peek_desc -> xskq_cons_read_desc -> > xskq_cons_is_valid_desc -> xp_validate_desc Ah OK I didn't dig past the cons_read_desc(). In that case LGTM. Acked-by: John Fastabend