Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3185611pxk; Mon, 7 Sep 2020 05:52:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrOAYo5OMQ1+hAJotnQeEvC4KtH79aQDIBkdX/BxpnXH6UhC6RPP6z9nK/qb2ZW2XLYCYV X-Received: by 2002:a50:e685:: with SMTP id z5mr20665458edm.305.1599483159675; Mon, 07 Sep 2020 05:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599483159; cv=none; d=google.com; s=arc-20160816; b=Msfa/1v/9jzMN3fW6A3QO9ZuvkMl0GwzA5YstJhxKw6IvaEomrOvVw9zGRFDGAaRyy 4J1dBbKy9pWEUhsYHGL3E7nULGsqf1TvKDOi74Tls8d6+PNUmt2huQ+VHYgIwGTqRyin yN8PtmmwuIqoXL4qgKki8yUsJMUakz96DXy5LXxbvnCkeO7JGoN7J+vj6rBayPBBW00G UXeqiRoQV0zFZpQGixUld00Qkl42zJ5DdUdakAWk76RM3Hcs+nbdDGwJU6Jjrq8GjjoK myoFTX/jJKYh8EaMNzbtE8OZEIE6LyDFVP7ox2JxpM67dyKU/bHxXou6A9ZCeKCY306n d8Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Do+ITTDxBPQkRwNINDAMtH/xddQo5kNkcXGmE8sqjYI=; b=dAZg0cYab/wZD1sAjM4J6JJstNv0vYVWPqkMgo5VDTodDzuvl1AGb4lSrtD8+5QlWN PV955d8HNnBiekZZWZMIhCZa0z/C4TXcPWU1dTP6dhRqkyNlamhvyJ5fMjJovvsBG57S ioyxhCZUVw+8xI+dvZyFrkMgmIMAeHBWW1L7KlUnZyMRvr1CBWsJnGNYc8D9S4HanwKI z6NGYcdFk4Etg+kxRNH5QKGKGkTv5RkVbC8ntXzE2eV3bPVMhX7Jajq3UcMQN1OJ8LOI pfYnrdyP3UCKk8c4Dk2ATNcTYYCJusb0mrWhCD+r28HYnj1RsQas+26JzN4CCX4f1AHE Zhyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=T9kSV4Vx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di23si10083642edb.451.2020.09.07.05.52.17; Mon, 07 Sep 2020 05:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=T9kSV4Vx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729162AbgIGMub (ORCPT + 99 others); Mon, 7 Sep 2020 08:50:31 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:11897 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729262AbgIGMor (ORCPT ); Mon, 7 Sep 2020 08:44:47 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 07 Sep 2020 05:44:10 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 07 Sep 2020 05:44:24 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 07 Sep 2020 05:44:24 -0700 Received: from [172.27.12.170] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 7 Sep 2020 12:44:16 +0000 Subject: Re: [PATCH rdma-next 3/4] lib/scatterlist: Add support in dynamic allocation of SG table from pages To: Christoph Hellwig , Leon Romanovsky CC: Doug Ledford , Jason Gunthorpe , , References: <20200903121853.1145976-1-leon@kernel.org> <20200903121853.1145976-4-leon@kernel.org> <20200907072921.GC19875@lst.de> From: Maor Gottlieb Message-ID: <15552707-c9ae-b76b-f6ff-7fedd5b02aed@nvidia.com> Date: Mon, 7 Sep 2020 15:44:08 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <20200907072921.GC19875@lst.de> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599482650; bh=Do+ITTDxBPQkRwNINDAMtH/xddQo5kNkcXGmE8sqjYI=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:Content-Type: Content-Transfer-Encoding:Content-Language:X-Originating-IP: X-ClientProxiedBy; b=T9kSV4Vx3B5KdRjaa2H9jq5hfVpsWyHmHeZo8m9GE/J0ZZnId6jCB8TZmVUpK8Ice FV6Q7vvKlIoIuvv0HhR0I2SMC97KcKbT4TI63pJpKiB1YfbRTYLQ1Mlhsz2Smjy4lj LkqbVDtLtM3sei34IQX41ndOdcRECr7Vx914sJh6x8OpEANC5k86qo5fWtfZ3mvQc1 eWChnZH+yxHmxM2GjSNaZX+7qAiro30JXqv1CyceB+zEXkcWgriINYAPv7OmYI4uiy RAgR1SzsTGGy1pc8SbuSPb5ylRguuYh23V/1+FXIHRXry/GACHeAYnOuah/aiE+e+R Y/q5m1lubwfpw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/7/2020 10:29 AM, Christoph Hellwig wrote: > On Thu, Sep 03, 2020 at 03:18:52PM +0300, Leon Romanovsky wrote: >> +struct sg_append { >> + struct scatterlist *prv; /* Previous entry to append */ >> + unsigned int left_pages; /* Left pages to add to table */ >> +}; > I don't really see the point in this structure. Either pass it as > two separate arguments, or switch sg_alloc_table_append and the > internal helper to pass all arguments as a struct. I did it to avoid more than 8 arguments of this function, will change it to be 9 if it's fine for you. > >> + * A user may provide an offset at a start and a size of valid data in a buffer >> + * specified by the page array. A user may provide @append to chain pages to > This adds a few pointles > 80 char lines. Will fix. > >> +struct scatterlist * >> +sg_alloc_table_append(struct sg_table *sgt, struct page **pages, >> + unsigned int n_pages, unsigned int offset, >> + unsigned long size, unsigned int max_segment, >> + gfp_t gfp_mask, struct sg_append *append) >> +{ >> +#ifdef CONFIG_ARCH_NO_SG_CHAIN >> + if (append->left_pages) >> + return ERR_PTR(-EOPNOTSUPP); >> +#endif > Which makes this API entirely useless for !CONFIG_ARCH_NO_SG_CHAIN, > doesn't it? Wouldn't it make more sense to not provide it for that > case and add an explicitl dependency in the callers? Current implementation allow us to support small memory registration which not require chaining. I am not aware which archs has the SG_CHAIN support and I don't want to break it so I can't add it to as dependency to the Kconfig. Another option is to do the logic in the caller, but it isn't clean. > >> + return alloc_from_pages_common(sgt, pages, n_pages, offset, size, >> + max_segment, gfp_mask, append); > And if we somehow manage to sort that out we can merge > sg_alloc_table_append and alloc_from_pages_common, reducing the amount > of wrappers that just make it too hard to follow the code. > >> +EXPORT_SYMBOL(sg_alloc_table_append); > EXPORT_SYMBOL_GPL, please. Sure