Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp392906lqh; Tue, 7 May 2024 02:22:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqISw8Tntd8DuOKMh9xmXg88kUMWPXMippRgVZvkPOIrssNyf4IewQvf0IIY6o00V4syVudwTG0OZLIjbTbSvDKSOtrk8eiUTkYWf2rw== X-Google-Smtp-Source: AGHT+IGnT2osMlF4MM1i3gvOy9tfwxdgNb84j5qpFgoeIrQwKfutLr70h3WZjglfHF60eaN1Y9cW X-Received: by 2002:a05:6359:45a9:b0:192:75c4:2edc with SMTP id no41-20020a05635945a900b0019275c42edcmr1346032rwb.25.1715073759230; Tue, 07 May 2024 02:22:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715073759; cv=pass; d=google.com; s=arc-20160816; b=wmTh0a06qn51KPdDdkXf2GDc9q8NpulPmpnIMw0US8fkqknrGOJcBZce48TCIIPMgo QrBDOqsEXOtX3cB8DiiGZWO4mKc7hpgD0weezhIBIFQljFPcPZnIx/ocNPiGUTOL/OaC DaPUgowzmKC/96CwQ4r0LK+vAyx2C6SpGViIa3wOYzVY9cpnqzWHydUTThZaxc30Nk0G Y/fSXQtfFblISlXgkcOpvTx64IxdUvzsAw/ulgbkU4pQw/rkBadKV2MaRVfp1Dzhb+0J O/6jcxgYwJYEPL/+VooDVbxn7KFTY3e4Q1TDSv4sCgqkia3m1GZZl69AdiOMQVkc4nnu CN8g== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=iPXwk2wYF/NZ65j0H2ITJ+6cyU1nKvMFXdmnUwBv4zM=; fh=orW+y8ThIcRUt1tmION/EI7bKbq6t59N4aaBWg+eeSQ=; b=OFRxKlIujJovutSpDqAAzOzrlpLBeQFOo7nOvC6N611C8feq71lbxogIral4bKao/7 3uFDmR4HTG5mubxMBkGSFx6L4NJc8JhLAF4vGlSVD1XheuaXJ5gt1E2EANvanwkv+hv6 B4cOHyB5wIIxMWNgc9wRKD105uPAXCQ0aZJeKtEzzypUEy65Cj6jUi31e96T2J39sFOL SyZ8BRWDGBK7okludN1+twyHyBbbXy+8XES4X9UcZlupQj0KMqBaBvYVpCExCC+xSGFP bRmxRIsVC6E2lVOzl7RATtxZ3X/Xg6zdsWgO8fC15VqTgboZn9KEuV2Y60JlhTbh+Cg1 qtcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hisilicon.com dmarc=pass fromdomain=hisilicon.com); spf=pass (google.com: domain of linux-kernel+bounces-170934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o3-20020a637303000000b005e437941b3dsi9720797pgc.874.2024.05.07.02.22.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hisilicon.com dmarc=pass fromdomain=hisilicon.com); spf=pass (google.com: domain of linux-kernel+bounces-170934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.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 AE2F0285261 for ; Tue, 7 May 2024 09:22:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5EE714E2CB; Tue, 7 May 2024 09:22:22 +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 9BFFC14D703; Tue, 7 May 2024 09:22:17 +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=1715073742; cv=none; b=gYqvzMQP1zt3diRoY1VPvrqouRDULgu/ePaiwuvLCerICCZSwUusC+MNDcTE0RG4vZxv7PG2mPFofgJIEhJjjW8IJI2dizb2CZU23zAeZb7d3RFyN7N2UETfFW+/bV3RBVJtYjDDH/KAgm0SBL3PYIyfv5iikcaeZh1XhbtbrXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715073742; c=relaxed/simple; bh=wfcedzwG+EhgUy8lT3Z1ANBJKqDx/DtvFKy2hoN5u6I=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=u/KynaxKCa4+xA1tQYUB+NKD1JIbPbC2/RIfNFlRh9SfjkIP0TOL4QCDUm+AUfo6xj/KnS78sIqPNIckZZYAmAAvSGz6BZhJEwYCeYQ/qRM3a2p0ZLOURSew/MA8ompUwBj85BGxad6VRUpvValJ4nZmKwztoAYyH3crwkoTDX0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com; spf=pass smtp.mailfrom=hisilicon.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hisilicon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hisilicon.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VYXlN55pfz1R9sh; Tue, 7 May 2024 17:18:56 +0800 (CST) Received: from kwepemi500006.china.huawei.com (unknown [7.221.188.68]) by mail.maildlp.com (Postfix) with ESMTPS id 1C8B918007D; Tue, 7 May 2024 17:22:15 +0800 (CST) Received: from [10.67.120.168] (10.67.120.168) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 7 May 2024 17:22:14 +0800 Message-ID: Date: Tue, 7 May 2024 17:22:13 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH for-next] RDMA/hns: Support flexible WQE buffer page size To: Jason Gunthorpe CC: , , , References: <20240430092845.4058786-1-huangjunxian6@hisilicon.com> <20240430134113.GU231144@ziepe.ca> Content-Language: en-US From: Junxian Huang In-Reply-To: <20240430134113.GU231144@ziepe.ca> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500006.china.huawei.com (7.221.188.68) 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? > > Jason Hi Jason. Sorry for the late response. WQE buffer of hns HW actually consists of 3 regions: SQ WQE, RQ WQE and ext SGE. Userspace and kernel driver both computes buffer size and start offset of these 3 regions based on the page shift. Kernel needs to obtains the page shift from userspace to ensure the buffer size and start offset are the same between kernel and userspace and avoid invalid memory access. The "tools of umem" you said refers to ib_umem_find_best_pgsz() I assume. This API cannot ensure returning the same page size as userspace, and kernel cannot determine the start offset of the 3 regions in userspace in this case. Junxian