From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9676E64A80 for ; Tue, 3 Dec 2024 11:23:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A8F56B0085; Tue, 3 Dec 2024 06:23:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 758B86B0088; Tue, 3 Dec 2024 06:23:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6487A6B0089; Tue, 3 Dec 2024 06:23:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4709C6B0085 for ; Tue, 3 Dec 2024 06:23:55 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E90241208CB for ; Tue, 3 Dec 2024 11:23:54 +0000 (UTC) X-FDA: 82853412810.24.B12B96F Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf17.hostedemail.com (Postfix) with ESMTP id E9DE140013 for ; Tue, 3 Dec 2024 11:23:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of zuoze1@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=zuoze1@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733225019; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SEPmyt/iJ4Rlz4cvdi6528CYQ8op1qFwbHhDEILk6Pk=; b=7/c0MXAqioIUowa6I8R1E/ZAFAS7NydeNvLB1CVnByO6w1/6MwrlHATQesvpXRinlu8Mcl loHjJYXe5UpF6BNc+qa1l7jn3WnXF8/R5aEvPescUvhGCyoUe2syzPk+Bgzo95r2ooddwR cUCmr83nPBlg+92+uXjrVzoJjhr9iHY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733225019; a=rsa-sha256; cv=none; b=g1OEQkmGtUzpiop/Lew8FepFg1GuZgKa/EbgabJVIpSvCIJ9CRXsY+Ij3oBTLDRAHLVb+O NQU+AOynbwBu5N2xRvNwzRtiVaBwtN5ga69ueKc+0l0UN8KG9WjM40Nu8BsakH5y5BYvPD 6bt6ubcN00ZeGIeA5BFGGc5PG1JfZFs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of zuoze1@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=zuoze1@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Y2dWt0s6sz1T6LP; Tue, 3 Dec 2024 19:21:30 +0800 (CST) Received: from kwepemg500008.china.huawei.com (unknown [7.202.181.45]) by mail.maildlp.com (Postfix) with ESMTPS id 4B6091402CB; Tue, 3 Dec 2024 19:23:46 +0800 (CST) Received: from [10.174.177.186] (10.174.177.186) by kwepemg500008.china.huawei.com (7.202.181.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 3 Dec 2024 19:23:45 +0800 Message-ID: <57f9eca2-effc-3a9f-932b-fd37ae6d0f87@huawei.com> Date: Tue, 3 Dec 2024 19:23:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH -next] mm: usercopy: add a debugfs interface to bypass the vmalloc check. To: Matthew Wilcox CC: , , , , , , References: <20241203023159.219355-1-zuoze1@huawei.com> From: zuoze In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.186] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemg500008.china.huawei.com (7.202.181.45) X-Rspamd-Queue-Id: E9DE140013 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: u1ze98iq99fy9uqr6zj4hu433h58mbh4 X-HE-Tag: 1733225020-515115 X-HE-Meta: U2FsdGVkX196c2EgxMkdNQUYd0jj27eVLX3vzoNpg+N57rRDqxbvGzrg8G4niUAtbDAZv5GpaUCpma+ncW6AfjX2hmnf35s/Caiwr/fq+CszosjDH7C9nxMbCoi1uldavdMZcQKtvC2RffJE/YPw3WDM8rWI4ruxOvoplBA3uKBgtAqy88okPauMkcgZ7QgiDPDRBwZPRTRVCPx/f9qE3PO1386zBLuY6lMEdxN1gV5OIzJ62g7ZvQ1EY0af0evOc3MV6HoQ1ZLh1VSW0AdSo+MVvldbYexLCyWLj8RxzYIrRyN5jh1h4QQSRH6ufwySC2g58wKMy4JRKDPSYNxPfeejk5zOOalDXim41Ak8jsbfjWGPvyEeAy0QXF+N0Qo0Crx9GiHS+echDs1u0WBV4WrDXv+vNWV3PZFdmkDLzcOp1SOb5QigOpuG2OvC79NeoW4OE7ijkjW5Gu/+MwrziBoyiRx2PU0dfbDzV6v57wTitSNO10ilSV9xyvXx1hZihsGcK5bT+SfQVVdmi4+QT3pSOhjL1bHJfRw++hNpX2hV+DnUN07r+F1Qol+UAfSyYIqte8VlBe+4J8PQSvEbIVSoib2xajqbxiseHhqwxGv4Xd24ndjCdjL+WtPVP3S2VCio47mvzTOCfhUZffAYu69WwTBmzT30RtX9FyBhkt0Y+FZcobHZkQVI9p5wfm9U+Jg+34qJBTL9ZVfyz4bkk69YzC6q1SakpwIz2W3t2wgeWsYb3OVj/pB1glgfMGrI2eLirsRwjAdaKaoeqfQxVVGJUvBAPYk6Vf5lhQxZqpt4N3H9VHhZKoxxl3IO1Tz+N6rhfOnfh6p7gV0UYNlbmr5KWYjkzrK1FmnWfgh96n2utQGl9M58MDTxdCwFSAtbjVELyymfoX7e7N4Hw+FI14IsvtjUFjwTGOiSbaOsfcf3Zc96yYfsvKqDv+erigsARRnn2kjSbeqeXmIVbNc iMiokVbR DBYJmTM3wxf7GtV/6PGlM9Ukmab1/QwlM7zKX9p4ihTzGesMXvwfKGOCrcGBIeRZi1j8OzMTQjSxzKAgnF0xNSPMg0IWXmMj1ixolKS2mYVKYm5KGJQZ3g7qW3i1ksczTEMsoNd73DQQeyxNFJQX+Nbfbb7ZJFKxA27zWBjejOUo7gfY3d28l3vp91jNGjYYjht6vcAqhXa9xri9MIXiSipSUJPzl+THzLPtb X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We have implemented host-guest communication based on the TUN device using XSK[1]. The hardware is a Kunpeng 920 machine (ARM architecture), and the operating system is based on the 6.6 LTS version with kernel version 6.6. The specific stack for hotspot collection is as follows: - 100.00% 0.00% vhost-12384 [unknown] [k] 0000000000000000 - ret_from_fork - 99.99% vhost_task_fn - 99.98% 0xffffdc59f619876c - 98.99% handle_rx_kick - 98.94% handle_rx - 94.92% tun_recvmsg - 94.76% tun_do_read - 94.62% tun_put_user_xdp_zc - 63.53% __check_object_size - 63.49% __check_object_size.part.0 find_vmap_area - 30.02% _copy_to_iter __arch_copy_to_user - 2.27% get_rx_bufs - 2.12% vhost_get_vq_desc 1.49% __arch_copy_from_user - 0.89% peek_head_len 0.54% xsk_tx_peek_desc - 0.68% vhost_add_used_and_signal_n - 0.53% eventfd_signal eventfd_signal_mask - 0.94% handle_tx_kick - 0.94% handle_tx - handle_tx_copy - 0.59% vhost_tx_batch.constprop.0 0.52% tun_sendmsg It can be observed that most of the overhead is concentrated in the find_vmap_area function. [1]: https://www.kernel.org/doc/html/latest/networking/af_xdp.html 在 2024/12/3 12:11, Matthew Wilcox 写道: > On Tue, Dec 03, 2024 at 10:31:59AM +0800, Ze Zuo wrote: >> The commit 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") introduced >> vmalloc check for usercopy. However, in subsystems like networking, when >> memory allocated using vmalloc or vmap is subsequently copied using >> functions like copy_to_iter/copy_from_iter, the check is triggered. This >> adds overhead in the copy path, such as the cost of searching the >> red-black tree, which increases the performance burden. >> >> We found that after merging this patch, network bandwidth performance in >> the XDP scenario significantly dropped from 25 Gbits/sec to 8 Gbits/sec, >> the hardened_usercopy is enabled by default. > > What is "the XDP scenario", exactly? Are these large or small packets? > What's taking the time in find_vmap_area()? Is it lock contention? >