Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3028073pxk; Mon, 7 Sep 2020 00:30:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAtoNQp+3J8TF/AFqnMu/+WOuGEECphkT9Z9Kdz86ypPm50SH5H8DSr0VFfDBB8Ws/IYkk X-Received: by 2002:a17:906:7d0d:: with SMTP id u13mr20684332ejo.448.1599463848984; Mon, 07 Sep 2020 00:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599463848; cv=none; d=google.com; s=arc-20160816; b=iDzDpsJbm9ENSjwb1B2wcsj2BLMK0FJNZ9B9QUkkblsTSrn3ie1gEq3PzliVE1TIvJ saTdQC9UmqjJV6wIhAMke5L3fvjcCsraTLys6srB5FpxjULe5809zGrsOOUPGMeqrK4U xsk1OtLkT9fkzsQb37+gjEWc95WSGAvROI1asYVa9HrmB6mWQKMF2yUnL+bandoHcSTS nu3mArYbB22X60v07V+flA3F9eg13ntUPZmyp+6lX4oiU58oAHfP43Ix/ILtq5VqbFgf 3F3+js2k0RrDKe8V3i8LR4GhN4Mcl+S8m7OiFJoIPsSdRwZGLSxwqwIACQr6gjRbjPSq yRJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=RZDXbsGMYecpVJUIFscDBr6VCLzaM39kIP1IMvxp604=; b=C19uk4t2QLlkPoGoBTteOlXCEstvkpwXVjgxaHqLqvMBGBZrvCnzt5S1HLYIXTULgF tOjzBhqZQAC1ETKvJ2rCDYZEbEB5l230APtu2fH8a0HhNr/ZbEdyKhevih9aRZwGA0hd u8za/nEDtIy69Lmoh6XJ0ggj9vD4/QVk2DGRtsslyvAd6B0CSQzsaWxRIClf5AmsuNRU Pl8ZyBnVVnkmZ/1M6x1I4Kn+BW9AiQMNhZ5AWd59ELJfiFjFbHHT4KzSxLzh1w1nx3yr 0cmQOplgNLzerV66ne6oSp4u8R/ImjK16VokzPJeii4kv4pNmB7ps7Zqf26W9Pa4wCWx /Dbw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq4si5983866ejb.174.2020.09.07.00.30.25; Mon, 07 Sep 2020 00:30:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbgIGH3c (ORCPT + 99 others); Mon, 7 Sep 2020 03:29:32 -0400 Received: from verein.lst.de ([213.95.11.211]:47992 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbgIGH3Y (ORCPT ); Mon, 7 Sep 2020 03:29:24 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 1B78F68BEB; Mon, 7 Sep 2020 09:29:22 +0200 (CEST) Date: Mon, 7 Sep 2020 09:29:21 +0200 From: Christoph Hellwig To: Leon Romanovsky Cc: Christoph Hellwig , Doug Ledford , Jason Gunthorpe , Maor Gottlieb , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH rdma-next 3/4] lib/scatterlist: Add support in dynamic allocation of SG table from pages Message-ID: <20200907072921.GC19875@lst.de> References: <20200903121853.1145976-1-leon@kernel.org> <20200903121853.1145976-4-leon@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903121853.1145976-4-leon@kernel.org> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + * 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. > +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? > + 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.