Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1496906rdb; Mon, 19 Feb 2024 19:20:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFduUfTW7eB335LMnJfBJLR+rXPhit2IjmryHQamXTHocckjyUMnnxSSSP/nFqNT851DUeO4wCfThHI4YespiJDoZ7wSMRlXOObjfabw== X-Google-Smtp-Source: AGHT+IGEONIFogV0cdhHIIZ+n9f98siO2+BQgIo5Hc4ErectLFJzxgxw6eJxvHq4bqK/0Cxdq4/3 X-Received: by 2002:a05:6a20:9399:b0:19c:90fc:f0d3 with SMTP id x25-20020a056a20939900b0019c90fcf0d3mr18746351pzh.46.1708399212214; Mon, 19 Feb 2024 19:20:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708399212; cv=pass; d=google.com; s=arc-20160816; b=BBiVmuXrY2Q+fyRS9dQgnNubqFH2ymfHEdzHsxzCENcYw3KiLOwd+Nb3QiD4EnXpcw PD1CkdmEeRXbOKJy57K04b2ssP7Doe79ZDzRlmgiKhLKqnbTgarH5a7V2oefKEvSeih4 9LznV6wR9SR13Jp9h7519QGQj3MUFgBepdi/aX+ARR+RzjsWVO2SzdpwQetNnSx0B9ng 2RQYk8i/5L7U4U8R7kNHsZodfxIiO1srpE89iK6tTGom19On/s3SQDT8bPujE4Z5bhvB veFXVPYUfh+P8uZaldLkxVtbXNM0dcJ1Q1mj5IPc6pgCB6rnuXceoiDJ6hd4Ktu3ESka 68XQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=vm9DUpMOnO65MkiOu9sTrxR8ynvGT3k7f5D5XqK7Uko=; fh=R2LJav7NUBRX2CoWPDckhn3zRz8dtV6E4Qed6PygHq8=; b=SViBajZP5hxPPVHaPiSAIaGFuTlAcl0mTdrKU5QnDpOZABnAZ4aVR9YJItoR8aG+9R ITVQ68nUaBiFlXmJ0/fv3tdri5RH0bni3hJKd2bzHhk0gr1KZigA7Gc4aosH9QqAcCy1 AOXGORmlrpDrCJOyuGegmeo4Y0Xiu6KiYwbhEHzCrZQocR6JWnZ24hgDn+4d/kQsJah7 yY1i6mdIzFh/ZneE9pWZOrB5mFXIAZc0tiT5fgYVR1cNkTvBkvrunC6d1wFjSW67MCEG 0MGm+SBXB6mlZDfquDHtpor6FEn41aN/J8yx1iiP077AqIILCtn9U0UyhhGvc3g8paJo ocnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b="p3/QCOep"; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-72257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h9-20020a170902f70900b001dbd690d937si4225322plo.227.2024.02.19.19.20.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 19:20:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b="p3/QCOep"; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-72257-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72257-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0B8922842A9 for ; Tue, 20 Feb 2024 03:20:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0076C45BE9; Tue, 20 Feb 2024 03:19:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="p3/QCOep" Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 D128951C2C; Tue, 20 Feb 2024 03:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399196; cv=none; b=ink1I0h2x7AIVR1hzfQsSnvw3gNpvggeaBKfv3SGC6YjRMKLUr2NqJZAlXtP7PNGK5+mC2F02bw/cK71/U3aQwkc5FFOVoleFUhSro2MnKO9qMpt+8Kz/RkrwJKMRL+xnPy8KoOOUrFkfNyNEm1VeOTOmKGomEKou3df91zbt5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708399196; c=relaxed/simple; bh=trry4QTxdMtEqrS6zmYMXjvclDjxf7/p5OQ5P5jueNU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ll6TGBKXZS40aJ2gP2rlZpobKcjdnaAqfRA3Z6vGISFa+5Na4R2TyvkK2lP44R9W/1ihU2AtCOOuTK2CpDJ1rwZ/VEx4B5vACgr5/Cs8L3ITxeWLuWfSDo+X5S8rgJhx0HGxT63ilfG08lyrgI93ac5BbuhVgfVgwmMHV8XCKb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=p3/QCOep; arc=none smtp.client-ip=115.124.30.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1708399190; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=vm9DUpMOnO65MkiOu9sTrxR8ynvGT3k7f5D5XqK7Uko=; b=p3/QCOepmb/S2eHI1wVAv6q0gwSsITnDgaaxWMA2teEa1LySeaNO+s8aiXwdyirJi5j/C5aX8kzn9dxj5AoPWMjQ3f7i2mwLWpqBAvf04Jsh3qm8g34MvCZmQaaKx4FJBcHNiLuoUCTSJL15IPZrZtoXmzgPQpQVVyalIaKhSNU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0W0vE3Uz_1708399188; Received: from 30.221.128.233(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0W0vE3Uz_1708399188) by smtp.aliyun-inc.com; Tue, 20 Feb 2024 11:19:49 +0800 Message-ID: <442061eb-107a-421d-bc2e-13c8defb0f7b@linux.alibaba.com> Date: Tue, 20 Feb 2024 11:19:48 +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: [PATCH net-next 13/15] net/smc: introduce loopback-ism DMB type control To: Wenjia Zhang , wintera@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jaka@linux.ibm.com, Gerd Bayer Cc: borntraeger@linux.ibm.com, svens@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240111120036.109903-1-guwen@linux.alibaba.com> <20240111120036.109903-14-guwen@linux.alibaba.com> <350f1cb8-b205-47be-a296-c610b9afe5fc@linux.ibm.com> From: Wen Gu In-Reply-To: <350f1cb8-b205-47be-a296-c610b9afe5fc@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/2/16 22:25, Wenjia Zhang wrote: > > > On 11.01.24 13:00, Wen Gu wrote: >> This provides a way to {get|set} type of DMB offered by loopback-ism, >> whether it is physically or virtually contiguous memory. >> >> echo 0 > /sys/devices/virtual/smc/loopback-ism/dmb_type # physically >> echo 1 > /sys/devices/virtual/smc/loopback-ism/dmb_type # virtually >> >> The settings take effect after re-activating loopback-ism by: >> >> echo 0 > /sys/devices/virtual/smc/loopback-ism/active >> echo 1 > /sys/devices/virtual/smc/loopback-ism/active >> >> After this, the link group and DMBs related to loopback-ism will be >> flushed and subsequent DMBs created will be of the desired type. >> >> The motivation of this control is that physically contiguous DMB has >> best performance but is usually expensive, while the virtually >> contiguous DMB is cheap and perform well in most scenarios, but if >> sndbuf and DMB are merged, virtual DMB will be accessed concurrently >> in Tx and Rx and there will be a bottleneck caused by lock contention >> of find_vmap_area when there are many CPUs and CONFIG_HARDENED_USERCOPY >> is set (see link below). So an option is provided. >> > I'm courious about why you say that physically contiguous DMB has best performance. Because we saw even a bit better > perfomance with the virtual one than the performance with the physical one. Hi Wenjia, you can find examples from here: https://lore.kernel.org/all/3189e342-c38f-6076-b730-19a6efd732a5@linux.alibaba.com/ https://lore.kernel.org/all/238e63cd-e0e8-4fbf-852f-bc4d5bc35d5a@linux.alibaba.com/ Excerpted from above: " In 48 CPUs qemu environment, the Requests/s increased by 5 times: - nginx - wrk -c 1000 -t 96 -d 30 http://127.0.0.1:80 vzalloced shmem vzalloced shmem(with this patch set) Requests/sec 113536.56 583729.93 But it also has some overhead, compared to using kzalloced shared memory or unsetting CONFIG_HARDENED_USERCOPY, which won't involve finding vmap area: kzalloced shmem vzalloced shmem(unset CONFIG_HARDENED_USERCOPY) Requests/sec 831950.39 805164.78 " Without CONFIG_HARDENED_USERCOPY, the performance of physical-DMB and virtual-DMB is basically same (physical-DMB is a bit better), and with CONFIG_HARDENED_USERCOPY, under many CPUs environment, such as 48 CPUs here, if we merge sndbuf and DMB, the find_vmap_area lock contention is heavy, and the performance is drop obviously. So I said physical-DMB has best performance, since it can guarantee good performance under known environments. By the way, we discussed the memory cost before (see [1]), but I found that when we use s390 ISM (or not merge sndbuf and DMB), the sndbuf also costs physically contiguous memory. static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr, bool is_dmb, int bufsize) { <...> if (is_dmb) { <...> } else { buf_desc->cpu_addr = kzalloc(bufsize, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | __GFP_NOMEMALLOC); if (!buf_desc->cpu_addr) { kfree(buf_desc); return ERR_PTR(-EAGAIN); } buf_desc->len = bufsize; } <...> } So I wonder is it really necessary to use virtual-DMB in loopback-ism? Maybe we can always use physical-DMB in loopback-ism, then there is no need for the dmb_type or dmb_copy knobs. [1] https://lore.kernel.org/netdev/d6facfd5-e083-ffc7-05e5-2e8f3ef17735@linux.alibaba.com/ Thanks!