Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2437613rbb; Wed, 28 Feb 2024 01:32:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqwi2GWpcYmRgEMAo07RVbnAyR5WeJT7hargZxF8Ezue3NvomTK3FICobGGEgrac6dvaJPyw3u+UKVdU68COG8jMwH64gv0N294Y+juQ== X-Google-Smtp-Source: AGHT+IFpInW/QOuJBa9umFCoEWg9zg6Zu8wMa8maxqmitD6fZPYLB0z9n4vlpbyhz5VF+Uza2GfI X-Received: by 2002:a17:906:7fd0:b0:a44:113a:8f83 with SMTP id r16-20020a1709067fd000b00a44113a8f83mr394450ejs.68.1709112733639; Wed, 28 Feb 2024 01:32:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709112733; cv=pass; d=google.com; s=arc-20160816; b=NQdt1EvNqyGBQ6VTxY6GLdzSiRUBxd1XnHUQ3eFUjebKge+3z3drox64nKDVrCZJev tnsvpJ+9RRkwBBrc2eRW6aDe13QwRB8flTcQbHommYs8UO5GP43KLCVyk4Z0fM/zrvcq e1Zzi4wTDjKHB+lQHCw5mjDJn8Yv7zTz89fVSPKfUXaLXZ/oYihbSXA8byA8AUERMQaY AlC6eqGxKVLaKN8c8dNnfrZR9x4kqZBF2etuD1akCn7prY//w/jbF0kGfrmvhv/ynlXX GZAv9e2Wp0L9gXs5l5BoKitfimKiiB9G6Uh3Zt34SQsS1vL3gdDWfllCdxeHi9LQeDDF YXLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Lj4ZV1KXXFcbcgj2xJ8FqsFyL/6ecLDUxE0ee1RPZS4=; fh=HPThzKBBKEvr3e8PHIJmxkhpLc0+gIq6vq/lenlm27E=; b=rKCKfX/acK9fWsusqB+UvedbcaFEUYgOHxIPxi60mkrVE2zoWDecc1N3gOAuePwnpM QfcW6HxfNVEma2CcXnlWdiK1rNXVSz2xrF7EBdN4UjXmaTJ0nOJmAAwmoMPxozDwaZvC GqpaflbzrZdfA/XZcimuDod2kKTmBfAkHTq88nUWAi2gtQMo5KIfu6AyG2DJK1Qh7zK4 BpsBuJKKdncMTmZ/1f8a8UnCtuGTdkGGtLfxlv5cE2lKMgVoxSikS+feaqmS7lMEWFhe OTdsaqOd4TCxgRSjnY9ZF9eWMsVris8ErTYS8gpFHc918VY0WAKBBYHqhqvoRRnaFks7 MYYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-84764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h11-20020a17090634cb00b00a4315f2efa6si1561778ejb.689.2024.02.28.01.32.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 01:32:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-84764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 64E351F20B53 for ; Wed, 28 Feb 2024 09:32:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D1B63610A; Wed, 28 Feb 2024 09:31:59 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 AB4F42E657; Wed, 28 Feb 2024 09:31:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709112718; cv=none; b=Iqreri7ye9+/gAaYjJhZ2n0iRs8TV2LuSEk8V+cbjwv5O4nHS4HBXtnRvC1P6Vz7vQuXGeZ3FX5w80yZkXjgLVWQze7kcaPLiI8idSVP0Q0HjLWed/vDUSS9R9FlxSYjDc+b6NiwlVmAkxFLcGTsIud0dwdAq4hQTQBqqWUYitY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709112718; c=relaxed/simple; bh=PdsLjsWcsNlTwhr57K6QgoJxkvcwYSeSGmfoCSQstz4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=l2WDTBVFJSy3/h/2kOc/AhvRqL0bXF1zgdzzn9/Ch4WcVXa5TIg/nWw0TCwMocq/E/A7s10qfY4CeHmBSJpZjSFzemAHqyZWYGzDKc8ml7ooFLQNJ+c7nk/wQBrwQeOb89WhlYS71387onpoudBWo/Wxn4cIFN/zA1OzjoEroYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Tl8Fy1k70z1Q99X; Wed, 28 Feb 2024 17:29:58 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id B377E18005C; Wed, 28 Feb 2024 17:31:46 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 28 Feb 2024 17:31:46 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Matthias Brugger , AngeloGioacchino Del Regno , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , , , Subject: [PATCH net-next v6 0/5] remove page frag implementation in vhost_net Date: Wed, 28 Feb 2024 17:30:07 +0800 Message-ID: <20240228093013.8263-1-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500005.china.huawei.com (7.185.36.74) Currently there are three implementations for page frag: 1. mm/page_alloc.c: net stack seems to be using it in the rx part with 'struct page_frag_cache' and the main API being page_frag_alloc_align(). 2. net/core/sock.c: net stack seems to be using it in the tx part with 'struct page_frag' and the main API being skb_page_frag_refill(). 3. drivers/vhost/net.c: vhost seems to be using it to build xdp frame, and it's implementation seems to be a mix of the above two. This patchset tries to unfiy the page frag implementation a little bit by unifying gfp bit for order 3 page allocation and replacing page frag implementation in vhost.c with the one in page_alloc.c. After this patchset, we are not only able to unify the page frag implementation a little, but also able to have about 0.5% performance boost testing by using the vhost_net_test introduced in the last patch. Before this patchset: Performance counter stats for './vhost_net_test' (10 runs): 305325.78 msec task-clock # 1.738 CPUs utilized ( +- 0.12% ) 1048668 context-switches # 3.435 K/sec ( +- 0.00% ) 11 cpu-migrations # 0.036 /sec ( +- 17.64% ) 33 page-faults # 0.108 /sec ( +- 0.49% ) 244651819491 cycles # 0.801 GHz ( +- 0.43% ) (64) 64714638024 stalled-cycles-frontend # 26.45% frontend cycles idle ( +- 2.19% ) (67) 30774313491 stalled-cycles-backend # 12.58% backend cycles idle ( +- 7.68% ) (70) 201749748680 instructions # 0.82 insn per cycle # 0.32 stalled cycles per insn ( +- 0.41% ) (66.76%) 65494787909 branches # 214.508 M/sec ( +- 0.35% ) (64) 4284111313 branch-misses # 6.54% of all branches ( +- 0.45% ) (66) 175.699 +- 0.189 seconds time elapsed ( +- 0.11% ) After this patchset: Performance counter stats for './vhost_net_test' (10 runs): 303974.38 msec task-clock # 1.739 CPUs utilized ( +- 0.14% ) 1048807 context-switches # 3.450 K/sec ( +- 0.00% ) 14 cpu-migrations # 0.046 /sec ( +- 12.86% ) 33 page-faults # 0.109 /sec ( +- 0.46% ) 251289376347 cycles # 0.827 GHz ( +- 0.32% ) (60) 67885175415 stalled-cycles-frontend # 27.01% frontend cycles idle ( +- 0.48% ) (63) 27809282600 stalled-cycles-backend # 11.07% backend cycles idle ( +- 0.36% ) (71) 195543234672 instructions # 0.78 insn per cycle # 0.35 stalled cycles per insn ( +- 0.29% ) (69.04%) 62423183552 branches # 205.357 M/sec ( +- 0.48% ) (67) 4135666632 branch-misses # 6.63% of all branches ( +- 0.63% ) (67) 174.764 +- 0.214 seconds time elapsed ( +- 0.12% ) Changelog: V6: Add timeout for poll() and simplify some logic as suggested by Jason. V5: Address the comment from jason in vhost_net_test.c and the comment about leaving out the gfp change for page frag in sock.c as suggested by Paolo. V4: Resend based on latest net-next branch. V3: 1. Add __page_frag_alloc_align() which is passed with the align mask the original function expected as suggested by Alexander. 2. Drop patch 3 in v2 suggested by Alexander. 3. Reorder patch 4 & 5 in v2 suggested by Alexander. Note that placing this gfp flags handing for order 3 page in an inline function is not considered, as we may be able to unify the page_frag and page_frag_cache handling. V2: Change 'xor'd' to 'masked off', add vhost tx testing for vhost_net_test. V1: Fix some typo, drop RFC tag and rebase on latest net-next. Yunsheng Lin (5): mm/page_alloc: modify page_frag_alloc_align() to accept align as an argument page_frag: unify gfp bits for order 3 page allocation net: introduce page_frag_cache_drain() vhost/net: remove vhost_net_page_frag_refill() tools: virtio: introduce vhost_net_test drivers/net/ethernet/google/gve/gve_main.c | 11 +- drivers/net/ethernet/mediatek/mtk_wed_wo.c | 17 +- drivers/nvme/host/tcp.c | 7 +- drivers/nvme/target/tcp.c | 4 +- drivers/vhost/net.c | 91 ++-- include/linux/gfp.h | 16 +- mm/page_alloc.c | 22 +- net/core/skbuff.c | 9 +- tools/virtio/.gitignore | 1 + tools/virtio/Makefile | 8 +- tools/virtio/linux/virtio_config.h | 4 + tools/virtio/vhost_net_test.c | 532 +++++++++++++++++++++ 12 files changed, 609 insertions(+), 113 deletions(-) create mode 100644 tools/virtio/vhost_net_test.c -- 2.33.0