Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp81315pxv; Wed, 30 Jun 2021 00:06:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGgSkuERjtzjrJE+tLvovGQp9EpwFXPaZJeC5vVxY0Bt1nxEKkXsmZgrwhs9xBlSVMY455 X-Received: by 2002:aa7:d9d3:: with SMTP id v19mr45350563eds.145.1625036777941; Wed, 30 Jun 2021 00:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625036777; cv=none; d=google.com; s=arc-20160816; b=YR5IcIMJLZD8dyc2MccsC8k2rbwpQ/Ub8d06wyr2LV5la+b7etNZJUQNHCfMh0Fm4L ZP8/5g/HLbMGRDhm2s6geYMZApdZV3nnYKYgfoFCwO8OwjwlFl/5jN3euP+dMelfmO1c JKRMX56/wucZ23uxnwpkzP1+U0/vtWC+NB+gY/LhzkEl/BiFx59buOhiaYZGUiItM1+W a9WU+WOjh6WZcFLsfrVrcXhWxkeXcZXWRuyrCsBn7xynCIlEfjQ+I6+eEnIMhYmRi860 QtmBpJt9R84oUhU/HEieuZZHVzDAzBMvFohZYB1J1QWtAK0I9nJcza/+hyRuvRTyHiix r0CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5Ys6h45gbV4Z0AcQgjgtzSDbWM4dl/+2UztaG+n8o9A=; b=epe43txQCutE+yj09344QKpMk0+cN2+zd+CYwucuwqcQSJwLpr2vUnpV+vRpziAg2C JhnCVHJjXQlmJYemb5/SiENIOcG8bSN1L4jH/3pCz9WnoEpmEgtAu/2HV7dqdBLZEycD qaQ3xJJOR44Bl/8rXyDnXhJYWQOzlc1adS+n66tu7DNzA3/6UgyBLlf9feKEtojQjmH6 Pg5T2AAmbc9+TVoWOwr3pNg/ZJogTMH3y3+EgV7fBfbwJxjWcE9gBoP19li1BarhTUVd UCWE2S1mZzsTpGfnTJkeuRLR3NL4hzirepnN7G8bg64thPZ2+ob85a1OU2qddV9hshB5 g99Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FT8PQ9Xs; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si19668470edv.414.2021.06.30.00.05.53; Wed, 30 Jun 2021 00:06:17 -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=@kernel.org header.s=k20201202 header.b=FT8PQ9Xs; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232706AbhF3HEq (ORCPT + 99 others); Wed, 30 Jun 2021 03:04:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:50502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbhF3HEn (ORCPT ); Wed, 30 Jun 2021 03:04:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6D3C611AF; Wed, 30 Jun 2021 07:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625036535; bh=fHMMVrtlxKeaKsAvLWSY7uHaUoi7yT4jN4cdWFy07Ws=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FT8PQ9XsaNMtbxvhMA+KQF2M5q77vzCstbkWP1GXp251+YRgazbFXCrMHcfQ3VLbc vTkMf1hd+cX88d9/o5QBCRTAkOW5QbEJMT2kf+IKvUfe2q+zf1noQGKhHCIZbr5NVO rJ3lyP6PU+GB9bBhLtT7Ga/QDTwQRkNXd6MFPhNHYZGlrD5oi8XGkSeHy2mjrSUuxO k2ICLfkc87ujh7YP28lK33PmwSis3XUJIyJ86DhOimN3AykgQYX3es2CwapqfrTgZp S4wr68Uxhlf72wLfK+2uzl4bn15SwRRWQ/aLJmHSM4ourpFATSxOGAWH1SQjiFye4Z tDeiWt1HqOT+g== Date: Wed, 30 Jun 2021 10:02:11 +0300 From: Leon Romanovsky To: Christoph Hellwig Cc: Doug Ledford , Jason Gunthorpe , Maor Gottlieb , Dennis Dalessandro , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Mike Marciniszyn , Yishai Hadas , Zhu Yanjun Subject: Re: [PATCH rdma-next v1 1/2] lib/scatterlist: Fix wrong update of orig_nents Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 30, 2021 at 07:33:17AM +0100, Christoph Hellwig wrote: > On Wed, Jun 30, 2021 at 09:29:51AM +0300, Leon Romanovsky wrote: > > On Wed, Jun 30, 2021 at 06:59:11AM +0100, Christoph Hellwig wrote: > > > On Tue, Jun 29, 2021 at 11:40:01AM +0300, Leon Romanovsky wrote: > > > > 2. Add a new field total_nents to reflect the total number of entries > > > > in the table. This is required for the release flow (sg_free_table). > > > > This filed should be used internally only by scatterlist. > > > > > > No, please don't bloat the common structure. > > > > Somehow we need to store that total_nents value and our internal > > proposal was to wrap sg_table with another private structure that is > > visible in lib/scatterlist.c only. > > > > Something like that: > > struct sg_table_private { > > struct sg_table table; > > unsigned int total_nents; > > }; > > > > But it looks awkward. > > Well, the important point is that we only need it for the new > way of collapsing, appending allocations. We should not burden > it on all other users. Another possible solution is to change __sg_alloc_table()/__sg_alloc_table_from_pages to return total_nents and expect from the users to store it internally and pass it later to the __sg_free_table(). Something like that. Thanks