Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1456665lqh; Mon, 6 May 2024 08:14:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFveUgXvyXZ5oOUMW6DUc+8uR0v82XbnZNKWYGL4FmUavseZ6SOLNVxjAJiedVo3UxjoikbmelniaCKWG7DYOowCP/fUuLhjZGHN2CSw== X-Google-Smtp-Source: AGHT+IHotcStWUqFNS3MUhg3MeBlGTcy6Uli5BwCEALNFgI/+pNYMe3GOwAqE2U2BX8F8vh7Tm9I X-Received: by 2002:a17:906:4103:b0:a58:9a67:967b with SMTP id j3-20020a170906410300b00a589a67967bmr9843971ejk.27.1715008456267; Mon, 06 May 2024 08:14:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715008456; cv=pass; d=google.com; s=arc-20160816; b=eVHpG4wXevlrvVESyJ5Y/YUnVAR8T5syTPocaQHWj4Y/fe4FTY7pehg6xUY8XEGH/M HLSMusox1KPfV0WeKfvRjftFHpSr4dMMmvOVkQRust6wrnkgMEm1bPJq+jlBl3jIbDha hcF9CIoFk+DISikfyCtX5Qws4CeuA/nZj3GLqJWcypGu3VW/zAClGp+Ka7pnbTAuglsr b8eA5BSHMIeaFtY3f2FCZOT2v3DOy3nXBuPFmaWoqY7/5eI5ulemzLYf476CAw8y0vc8 2P48YdrF8m4cKVd5RMtaJ2XLYTfCCrChQ1jGU86746EFGks3qFH6Ll3s56I7kvye4c66 VQkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MBh6+cizIio2X4bEih+MrNlX8KtZG6Oq+pv2Gn+dV+M=; fh=0eCtW+72c36jPIFRn9TJdEyZfL5X3fsGO+cVuxDEhKw=; b=SlSAxdvHD7tyXFq2SIljNvT/rTmSMQ2D8gEjzeI98/zjPUMDJg2A9/QXddsl2m2bnl ELqnk74k02awQdVo95+21y+TungqPN310hla3uQraFMsx8/Cyj8N9xPnnTt7cBEM++hu MbShleAZE9VbEKDYPiyJF6GaApcUCTEGpjqhRagNJyoPTmL83tR0jGEQZ3zvYNZKcyYn nxQn5jhmIzb9S2j5Sb1evwQr0YiS5gNP4FTTIiCG83UD/+0XDHoZUIFwFS+43zxlettL OpFJKDaXNiWC8Rh9aXgo5dC4Xq7+fMkH+ws7E4KqpirSPL8oYcoJXZWoQ6vTCxMkO0rq iRmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=eWGGKiES; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-170060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170060-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ga38-20020a1709070c2600b00a599ee3a698si3379420ejc.1049.2024.05.06.08.14.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170060-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; dkim=pass header.i=@ziepe.ca header.s=google header.b=eWGGKiES; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-170060-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170060-linux.lists.archive=gmail.com@vger.kernel.org" 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 CE6441F215E0 for ; Mon, 6 May 2024 15:14:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18DCE155A4D; Mon, 6 May 2024 15:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="eWGGKiES" Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 030B3155359 for ; Mon, 6 May 2024 15:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008279; cv=none; b=Qjuhas4u+aQ7N+zpVkvMNfcRdiq+/W8+Zz8EzH1LxgPtBGHXk0GhR5grNTNiWOVAsMJ0nWu0HTusww1wMuKiIdcEoTuiUUH0TIQKDa6gmp1V38Si4Cu/z/IO1HU4FHyI/TrLzClpGLepW1NQd/9jDBX56Pllo/BsaNAkG7ElDwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715008279; c=relaxed/simple; bh=H8vt6scH7BoMUK/SlOWE4m46KlKCzDhGUHOMEm3175I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UMLorKYseks0r9LDs3ZyYmvsYM717PeYAFgblh5gbzNCwQ6QT7/EcxI7lA84Hg3zheyvuMp5FbJ/15acI4cGoXox7X8y52IadrMT2Kgpx9ffr8oZq4Uc6rg8Zo0bgmDSIWeNhcA6d9SoMkO3Kdj1RnW8WAkDdVqKQHkKSp5F+rQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=eWGGKiES; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3c96c1e27a3so609257b6e.2 for ; Mon, 06 May 2024 08:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1715008275; x=1715613075; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=MBh6+cizIio2X4bEih+MrNlX8KtZG6Oq+pv2Gn+dV+M=; b=eWGGKiESrk19T+Ves+3x1o2gjEC9rEOaaeLe2D7bPP+/gicUlm58z8I7XF8MmyHoSf 7fVRw4S7IQ6xiL7R1riB6+gfm56SQjawGZAoEinkNDRrIruh2aHanxMXgZZ//CJhTxd6 hTV45sOCFQlHPOkkN4fkkWh8fx3K3pwGVScZbnHrLzIKrB1Wf1o+j/a1OFYjYjp+JY7X f5lQ11b/QBGqTX1I0STzEgXLYMvGlobA4rrYpCRMF4X92P1wJBv6r4ZhLKP6kGCHSjoP Ou0gHoBczXXrWNi5nXT8nlDG54r7PaCmz9fkpGkKy1bm7/h3dnJkCqm6X+0a3Yaw/oJO TdXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715008275; x=1715613075; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MBh6+cizIio2X4bEih+MrNlX8KtZG6Oq+pv2Gn+dV+M=; b=gkikije9aA47E3/ViFRpXPUY0nwQIN5my9X9WAWnExjrsQ9hLzTd8d+KiMmyUrjGfb Cx9xD2wXVckUWrr/bK/f2OBiE+T+wRwpfjUf3UlTNqIY1HBEl011y0Csfwudbmmc9fok FeQtcXP8AB7KW5Rtm5uUM7B/Y+D9JUMigyww9r7+/HtvTCuo/TZmg9eB7N4xwYDBPAcz YdQvgQFOgpH1gYaUCx088oKnpAa8YxfRh0onkoMvpRsA5UEKXMvE0U/ydCMUypulTHO9 S5nBf/usbORO9zRTWGHHs+Cw3OW05bg7QlRNYx3kOEAU2Krz/E8h6+7uXSbCdJbEGfwv ko1Q== X-Forwarded-Encrypted: i=1; AJvYcCUhTA+lBR7/bPRDmmRQnZ8U0pPC3QTSodrCi0/dtWq0uMSadsYfN3VEZqACvIuJmonOAFk2kWrxc5ykiXY9J+dwCuZSEKLNaRbNIYTx X-Gm-Message-State: AOJu0YwxZ7RGbkHaMXqfxgbjM5lSorEo2m4LyXJnyPSbpZ+scms2iNoX CwhcHHDvMvuqGXvVcTVkTdLea4UOw0bnIeKSl6GhXGoxjLQ5zOftC80MneNmR1k= X-Received: by 2002:a05:6808:b24:b0:3c9:6fad:25cd with SMTP id t4-20020a0568080b2400b003c96fad25cdmr2492419oij.22.1715008274880; Mon, 06 May 2024 08:11:14 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-80-239.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.80.239]) by smtp.gmail.com with ESMTPSA id k12-20020a54440c000000b003c7443c0efasm1450390oiw.1.2024.05.06.08.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 08:11:14 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1s3zzk-002y7a-R6; Mon, 06 May 2024 12:11:12 -0300 Date: Mon, 6 May 2024 12:11:12 -0300 From: Jason Gunthorpe To: Chengchang Tang Cc: Junxian Huang , leon@kernel.org, linux-rdma@vger.kernel.org, linuxarm@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH for-next] RDMA/hns: Support flexible WQE buffer page size Message-ID: <20240506151112.GE901876@ziepe.ca> References: <20240430092845.4058786-1-huangjunxian6@hisilicon.com> <20240430134113.GU231144@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, May 06, 2024 at 02:47:01PM +0800, Chengchang Tang wrote: > > > On 2024/4/30 21:41, Jason Gunthorpe wrote: > > On Tue, Apr 30, 2024 at 05:28:45PM +0800, Junxian Huang wrote: > >> From: Chengchang Tang > >> > >> Currently, driver fixedly allocates 4K pages for userspace WQE buffer > >> and results in HW reading WQE with a granularity of 4K even in a 64K > >> system. HW has to switch pages every 4K, leading to a loss of performance. > > > >> In order to improve performance, add support for userspace to allocate > >> flexible WQE buffer page size between 4K to system PAGESIZE. > >> @@ -90,7 +90,8 @@ struct hns_roce_ib_create_qp { > >> __u8 log_sq_bb_count; > >> __u8 log_sq_stride; > >> __u8 sq_no_prefetch; > >> - __u8 reserved[5]; > >> + __u8 pageshift; > >> + __u8 reserved[4]; > > > > It doesn't make any sense to pass in a pageshift from userspace. > > > > Kernel should detect whatever underlying physical contiguity userspace > > has been able to create and configure the hardware optimally. The umem > > already has all the tools to do this trivially. > > > > Why would you need to specify anything? > > > > For hns roce, QPs requires three wqe buffers, namely SQ wqe buffer, RQ wqe > buffer and EXT_SGE buffer. Due to HW constraints, they need to be configured > with the same page size. The memory of these three buffers is allocated by > the user-mode driver now. The user-mode driver will calculate the size of > each region and align them to the page size. Finally, the driver will merge > the memories of these three regions together, apply for a memory with > continuous virtual addresses, and send the address to the kernel-mode driver > (during this process, the user-mode driver and the kernel-mode driver only > exchange addresses, but not the the sizes of these three areas or other > information). So you get a umem and the driver is slicing it up. What is the problem? The kernel has the umem and the kernel knows the uniform page size of that umem. > Since the three regions share one umem, through umem's tools, such as > ib_umem_find_best_pgsz(), they will eventually calculate the best page size > of the entire umem, not each region. That is what you want, you said? Each region has to have the same page size. So the global page size of the umem is the correct one? > For this reason, coupled with the fact > that currently only the address is passed when the kernel mode driver interacts > with the user mode driver, and no other information is passed, it makes it more > difficult to calculate the page size used by the user mode driver from the > kernel mode driver. Even if it is difficult, this has to be done like this. You can't pass a page size in from userspace, there is no good way for userspace to do this correctly in all cases. It sounds like you have it right, just get the page size from the shared umem. Jason