Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp525689rdb; Fri, 5 Jan 2024 20:25:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/0v81ylQdTK2HAnYiv7IsxQgZkBUR9CnCRSM7k3ezzW7yk01fzv+6aBAFXW9EyMUrO0pg X-Received: by 2002:ac8:5a42:0:b0:428:1f6c:ef96 with SMTP id o2-20020ac85a42000000b004281f6cef96mr668458qta.88.1704515148610; Fri, 05 Jan 2024 20:25:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704515148; cv=none; d=google.com; s=arc-20160816; b=OzrLWdK7EhwdJ23EuuLVcghSGCVwm9cgOc+kW9qiNZ305UGhxnPKqNLKDO0bC3kjAP YXdISXID9t9begf0UsgMcLSR+J18eM0A81Nr6Z2NIy8kWRC9QhoavI4z63ZMETAWvZrS iyLmi97of5OPu4Gqf+TP6jsa/RQkUnMK1Og9N1DkjQHiQO3QvnEGM3dztmO88MHez7Pa 08+zdmpTmgTnoqVWo8Co4Yn00S0SR7DJrFthTNEuqTGJRIQVqWrXp8wZ1Efs9dqnPxF2 t9KF39ta4edmxnakKPf82PKVVRyqYs7ECNQIbAXSX2JOB19zVjxaC0NRV4HnBVvy20oZ RmNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=cAFj5XS3sMobNhBK9PMmK9Dbj2dZnddewRS7C83W6lQ=; fh=eQ+qIczSSRvz7jVYFyfdSAdSJF6uapvWNDKrT1+uBFM=; b=u7yhBj4vCl6qfk14gPXg79mSGcPgiR6m/rm+kCVOPqkh5kEYqULhyNTqDs/jCHoPS0 LoFt4GwXwoNMB+76dr4KZ9cFx7/aBxxPNu4Vn0ydDiqtYLUID7PgglYNwrSKI/eOSuaU DBlKzOc1H9BxUWSglj4z+kZULNOnOphbhIEPU2CMEgm6oWgcdeFTUrE9gRlVuzXUr3oc SO1A1nsVcHZspIKP8wEBzJkgtOkCrBfl6D3Rx1+7k9E4UvGTJaXkyoXQrRYmamgQWXac tRzJgBh6Qquj+UOwUfzbO57bXnU1is2zxRY6cf8HiJcWtR9R4nixFy/mb9hd8+A88QOn nqAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M24gs8nG; spf=pass (google.com: domain of linux-kernel+bounces-18478-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18478-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c5-20020ac87dc5000000b00428361ea8dcsi3358761qte.190.2024.01.05.20.25.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 20:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18478-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M24gs8nG; spf=pass (google.com: domain of linux-kernel+bounces-18478-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18478-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 46F751C23BC2 for ; Sat, 6 Jan 2024 04:25:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AE641C3D; Sat, 6 Jan 2024 04:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M24gs8nG" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) (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 B718B17E1 for ; Sat, 6 Jan 2024 04:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704515138; x=1736051138; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=K1pFfrfdo49D8TOTL//jcobRos+2Vcr3hksOB7Gvjc8=; b=M24gs8nGim641V7jIMeLiHWgYyPhMz/q79sdE/hpT1iWWkDjD0o72FQt qnYng/9f0ABkOlchxZGRS7eTStLUMAfsPhtmT5QkffK/fxtr3LdML6Z/C /CLfPxEHzICFDPfRcnkILmscQbLirDutO0WhBA6CFubZLH0qYR30vJ6eB Iztmgacj6SinsFr7Fzs3QcPQBpueMRk64dzBhccAkyHTNEO4UtvOO5aSK NufRqXEmdJkWzVTdnshz4rIZ5iew2BJdXJ6Za0O3iaptNczGtGr7Gyp/P W0T5AuupkBZXA9Ru0zDJVhaUMWRP5tQLBm49cPhcPT5Tjy6KzMvEkmGGb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10944"; a="464035040" X-IronPort-AV: E=Sophos;i="6.04,335,1695711600"; d="scan'208";a="464035040" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 20:25:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,335,1695711600"; d="scan'208";a="23022493" Received: from zhaohaif-mobl.ccr.corp.intel.com (HELO [10.93.16.94]) ([10.93.16.94]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2024 20:25:37 -0800 Message-ID: Date: Sat, 6 Jan 2024 12:25:34 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Regression] [iommu/iova] iova_rbtree_lock contended seriously causing performance bottleneck (bisect done; commit found) From: Ethan Zhao To: robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, regressions@lists.linux.dev References: <20240103045506.1077586-1-haifeng.zhao@linux.intel.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/3/2024 12:57 PM, Ethan Zhao wrote: > > On 1/3/2024 12:55 PM, Ethan Zhao wrote: > part of the mail got lost after sent > past here > > Issue: > When network throughput is large (>1GB/s), the performance of > application nginx hits bottleneck, most of cpu cycles are cost > by spin lock, it takes a lot of cycles to aquire iova_rbtree_lock > for  __alloc_and_insert_iova_range(). >> flame graph >> >> >> queued_spin_lock_slowpath-------------\ >> do_raw_spin_lock                       \ >> _raw_spin_lock_irqsave                  \ >> __alloc_and_insert_iova_range            \ >> alloc_iova_fast                           \ >> iommu_dma_alloc_iova                       \ >> __iommu_dma_map                             \ >> iommu_dma_map_page                           \ >> ice_tx_map.isra.0                             \ >> ice_xmit_frame_ring                            \ >> dev_hard_start_xmit                             \ >> sch_direct_xmit                                  \ >> __dev_xmit_skb                                    \ >> __dev_queue_xmit                                   \ >> ip_finish_output2                                   \ >> __ip_queue_xmit                                     \ >> __tcp_transmit_skb                                   \ >> tcp_write_xmit                                       \ >> __tcp_push_pending_frames                             \ >> tcp_sendmsg_locked                                     \ >> tcp_sendmsg                                             \ >> tcp_sendmsg                                              \ >> sock_write_iter                                           \ >> do_iter_readv_writev                                       \ >> do_iter_write                                               \ >> vfs_writev                                                   \ >> do_writev                                                     \ >> do_syscall_64                                                 \ >> entry_SYSCALL_64_after_hwframe                                 \ >> __GI___writev \ >> [nginx] \ >> ngx_linux_sendfile_chain \ >> ngx_http_write_filter \ >> ngx_output_chain \ >> ngx_http_send_response \ >> ngx_http_script_return_code \ >> [nginx] \ >> ngx_http_core_run_phases \ >> ngx_http_process_request \ >> >> Setup: >> 1. configure server nginx with following nginx.conf (appended to the >> tail) >> >> 2. request server with WRK >>     ./wrk -t 64 -c 1024 -d 40 --latency http://$server_ip:10802/1KB.json >> >> Debugging summary: >>   Bisect identified "commit 371d7955e310 iommu/iova: Improve restart >> logic" >>   as cause. >> >> nginx.conf >> user nginx; >> worker_processes 16; >> error_log /var/log/nginx/error.log crit; >> pid /var/run/nginx.pid; >> events { >> worker_connections 4000; >> use epoll; >> multi_accept on; >> } >> http { >> include /etc/nginx/mime.types; >> default_type application/octet-stream; >> log_format main '$remote_addr - $remote_user [$time_local] "$request" ' >>         '$status $body_bytes_sent "$http_referer" ' >>         '"$http_user_agent" "$http_x_forwarded_for"'; >> access_log off; >> sendfile on; >> tcp_nopush on; >> tcp_nodelay on; >> keepalive_timeout 65; >> keepalive_requests 20480; >> gzip_min_length 10240; >> gzip_comp_level 1; >> gzip_vary on; >> gzip_disable msie6; >> gzip_proxied expired no-cache no-store private auth; >> gzip_types >> # text/html is always compressed by HttpGzipModule >>     text/css >>     text/javascript >>     text/xml >>     text/plain >>     text/x-component >>     application/javascript >>     application/x-javascript >>     application/json >>     application/xml >>     application/rss+xml >>     application/atom+xml >>     font/truetype >>     font/opentype >>     application/vnd.ms-fontobject >>     image/svg+xml; >> >> reset_timedout_connection on; >> client_body_timeout 10; >> send_timeout 2; >> include /etc/nginx/conf.d/*.conf; >> server { >>     listen 10802; >>      server_name  localhost; >>      location / { >>          root   /usr/share/nginx/html; >>          index  index.html index.htm; >>      } >>      error_page   500 502 503 504  /50x.html; >>      location = /50x.html { >>          #root   /usr/share/nginx/html; >>          root   /ramdisk; >>     } >>      location /1KB.json { >>                 return 202 '{"status":"success","result":"\ >>                             Hello from  NGINX, 2KB test\ >>                             Nanchang, which was the capital of >> Yuzhang Prefecture during the HanDynasty, \ >>                             now falls under the jurisdiction of >> Hongzhou. It straddles the borderof the \ >>                             influence of the Ye and Zhen >> constellations , and is adjacent to theHeng \ >>                             and the Lu mountains . The three rivers >> enfold it like the frontpart \ >>                             of a garment and the five lakes encircle >> it like a girdle. Itcontrols \ >>                             nature’s jewels. The radiance of its >> legendary sword shootsdirectly upward \ >>                             between the constellations Niu and Dou. >> Its talented peopleare outstanding,\ >>                             and the spirit of intelligence pervades >> the place. This wasthe place where Xu \ >>                             Ru spent the night on his visit to Chen >> Fan (10). The mightyHongzhou spreads \ >>                             meteors chasing one another.\ >>                             "}'; >>            } >>   } >> } > > > Thanks, > > Ethan > Please ignore this report, looks like negtive, a running out of rcache case. Thanks, Ethan