Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1882721pxb; Mon, 23 Aug 2021 06:55:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjIaV/Qr8UmChrkfsBJpxHxXNxmJ6fuyrMqEy9RuLoHQh7bMJKX5EimSKxXmYzwzJKD00s X-Received: by 2002:a92:b301:: with SMTP id p1mr18173295ilh.10.1629726936382; Mon, 23 Aug 2021 06:55:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629726936; cv=pass; d=google.com; s=arc-20160816; b=JWgZXT76PJn/zHVvj9HD+3kXSTh8C3iaz7lMj9f1NQ0DQ5RjLRORRvIpc9v2d2KbpF lu7+y5lV5wRf58fzodJreNJchBb8uS5rySy68qZ4tpN/DLkUyHZJ0nElLp0vjA8fSKUU X8ufk/q7PVoxYNcJ1tsDdZqu9o0Z+LwVLvWdf/6eGZfSOMb2UsxU2hvlQvwNtP/hu40o tP1vnewqsClYBL8OHxgJXQvtXq6u/ER9EebwE7Zp15PGOha/hZ8TDPj1062YIpQHboAl GQnHEIiq40GBPO0fmNaXlY4yHl4Cp/2CMI4R3tnqFB4VAS/2VfD6MdFGMlpumyc4cLOT shUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=W8E2FlfnzgBWz8gKnDNQnCFom2qUpOZvrQM14eUbWJ4=; b=fcIMNfeSXUJEKqIRe2U4gS3+xf0S9yK5BpSMPh681q0gNOyiKCsCgPb0JUSmt3oxtW RyBp0Crjb3tduz1pQ4PmFKiwolaWGsigtEve+VeO7zod4/4xi1sWgwT1IcaF+YflObEv x3ndOsm0EIOpLrBz3pdpW4aSCPIgTppaUQD8OE8p6m+B+4IXxK8UHhvTXUxeYIbKfMFg wnHeJhTY5J/gqJGkfOnYlcCPyl5sbDfvAy1HGBg9Z49W3FCPSJYLiL7eoDB/L7wIyZdh PpV2lc+1VyKBywtuvXd2vS/cFlKKmU/9s80Z1FaGf8cKgIE5gpGFhp3WNYZ35WBrZbBZ 2xtA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=rHMpI86K; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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; dmarc=pass (p=QUARANTINE 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 b135si14892475iof.27.2021.08.23.06.55.24; Mon, 23 Aug 2021 06:55:36 -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=selector2 header.b=rHMpI86K; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbhHWNzY (ORCPT + 99 others); Mon, 23 Aug 2021 09:55:24 -0400 Received: from mail-dm3nam07on2065.outbound.protection.outlook.com ([40.107.95.65]:3520 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229518AbhHWNzX (ORCPT ); Mon, 23 Aug 2021 09:55:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KDMG8AvDfslNRafDwmXV/EfNk9ZOhHvr0vscqAweIChN4ZiZH6uusQRWofo1l77uzVFL6IdLX047fc5kWtYNJFEjrGTYSxzEY+Np/CNdbDbXZX7728VgQ96i8lZCkQq1Yt1sLlXy/pI77th0argsP3XPoCZ66r2FWbKV+9FGvP0HOnPeocIBqwBO8rU0mHezX+vKStrPu5zD6FUrW+5UDl7PebPKmyhNDoFl78zBy4upPtbZbaq6hsj7s11+iDbRLXdgZYnhgg8mysPQoF1F6UNvK9nPjrvJY8fjn5m4pkfPeX38t5NIuD7uEjb2GiXqtJ1PMk0dsGhISKAeeFFVmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8E2FlfnzgBWz8gKnDNQnCFom2qUpOZvrQM14eUbWJ4=; b=MPXfKZbneL2xw0cXNuX439AjkME9J070lorxCGxYK7TsBuaECaWXE/fEtJmJkwGxDbN3eZGtbIEG1Ya4Vxo0d4ID2NDPYTCVr+KfFRS+m3s3sQ7WD9pE/DYpU7fEXEme2HJFQgGwQ8hBhpoYoBAgGEk1p9ZLOnft4mzQN0kE8DsiGYNfNV3vtnA++7b9BRUVKpydgF87Qcejo7asiPdW/njZpuxJSaRijHnbZQ6F3Mofcx2g7jGRnNhHQCWwYHFCaVFdNzwD6mZel7fU5MA8FacITvgt6S5VxXOkM4VAL2OJWSBlleRxN8NZLKk+Gv3uNf8lnYmnVGkcgcReEveo0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W8E2FlfnzgBWz8gKnDNQnCFom2qUpOZvrQM14eUbWJ4=; b=rHMpI86Ko/nQjgQ28aUDAq83tB36090PFXrPrfSqJ39vZYfd7ls8nRE1fL4eCoQ84P7NZTfzrRGSpWg+qVce/PvzupXc86R8uA3GY6WU3GSRhTA2iiGE19Ug3E77xlIWSFKtMNe/oVt6mhTW9tkHc0x1ns9AaA49O4NNtNNmETJMYwPVlBBBamwBCS2zqykX6IPzxTYTvayqriC6R7t1LVr8T/7i6y54A7k3Y80R6007kI3k8+lGWrB3YyMjm98jHMR09zejfMjX67Lj3kD0qRX4+oCSsjZ3GTA2VBLE2tEXjRi9OF1qIFx/d2eeB6dfolwNclliFQUZ/jum7farLA== Authentication-Results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5157.namprd12.prod.outlook.com (2603:10b6:208:308::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.21; Mon, 23 Aug 2021 13:54:39 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::1de1:52a9:cf66:f336]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::1de1:52a9:cf66:f336%8]) with mapi id 15.20.4436.024; Mon, 23 Aug 2021 13:54:39 +0000 Date: Mon, 23 Aug 2021 10:54:37 -0300 From: Jason Gunthorpe To: Maor Gottlieb Cc: Leon Romanovsky , Doug Ledford , Christoph Hellwig , Ariel Elior , Daniel Vetter , David Airlie , Dennis Dalessandro , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Michal Kalderon , Mike Marciniszyn , Mustafa Ismail , Rodrigo Vivi , Roland Scheidegger , Shiraz Saleem , Thomas Zimmermann , VMware Graphics , Weihang Li , Wenpeng Liang , Yishai Hadas , Zack Rusin , Zhu Yanjun Subject: Re: [PATCH rdma-next v3 2/3] lib/scatterlist: Fix wrong update of orig_nents Message-ID: <20210823135437.GN1721383@nvidia.com> References: <460ae18dd1bbd6c1175e75f5d4e51ddb449acf8d.1627551226.git.leonro@nvidia.com> <20210820155425.GA530861@nvidia.com> <85542c97-c7e0-3db3-baa8-2413c00f75a4@nvidia.com> <20210823124541.GM1721383@nvidia.com> <2aab4d71-c6d3-d24c-ed81-7ded355a1592@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2aab4d71-c6d3-d24c-ed81-7ded355a1592@nvidia.com> X-ClientProxiedBy: BL1PR13CA0190.namprd13.prod.outlook.com (2603:10b6:208:2be::15) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (142.162.113.129) by BL1PR13CA0190.namprd13.prod.outlook.com (2603:10b6:208:2be::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.10 via Frontend Transport; Mon, 23 Aug 2021 13:54:38 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mIAPN-003Hac-F8; Mon, 23 Aug 2021 10:54:37 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c9109e96-7b4e-42da-0f42-08d9663d8cb8 X-MS-TrafficTypeDiagnostic: BL1PR12MB5157: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j5X5tlkYnKDgnb/1eX53LstvGfTm9npHmnnF3QhwdUluLy/hmxPIOKHDijTW59ZlYddsI54JPUgbseKJPdkbysXS4zVh/q52drwdWQFqRTk8qtswveBE8BdedZow381lfFtUAVsHVqnESaaGqrFqsNUR2TY/ZO58pwU5OSAwgXpYSfN7xhp63Q5D6htoOa0vWl5baCbYez6AQ6ifme0HqqtdRbcGSF8vlP9XVRahJOdKg9EX6SmlBFzNJidaMvGGGrRDvyp2+xYSYUBrETBPnhwY50IHFALfwZkpmUNtzTGatXhpfNh86lKbJe0iJ6/+h+1HuPY5804M7PN0MfmvSlyz4dUzt6hkh1GpX9pc8jkqKkSw1RxOs6JLB/ur5jxeeHYRzysOuPmIoCg3M3GUZ60JfvAOGxEOQ2QN6rAWoLGNx4Tdvnsp+1FxSebLxpED5zssKH1d3ng8fJM1GPQfZYEqeka3SgAmIVm/fdR/hmxlxLXA0jjBqpCE4oIJsZ5XbGald7xUwFZe/0FOgYLJ9DNcAObqOfxh1zoYf1Mi+I6+tuain5am1daARYn1DA5KZJWJKVDuslRRU3SKFOtM/ueE0kYtOUEKxy7SC3JUhrNbbIEnnoTUySroM9nyunLiftOo4/BeejyAdADAt+w/nA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(376002)(136003)(346002)(396003)(5660300002)(86362001)(426003)(53546011)(478600001)(186003)(2906002)(8676002)(37006003)(316002)(54906003)(66556008)(6636002)(66946007)(1076003)(66476007)(4326008)(33656002)(2616005)(8936002)(9786002)(7416002)(38100700002)(9746002)(26005)(6862004)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QnlFSGxQVFMrUlpFZWZvSERYUWh2NWhMdC9DbktleExEQ05UV2I4TUdMdFlG?= =?utf-8?B?cW5FZzNVemZabVpTK011Vlo4N2JCWWtBakdBbXArc05qK2dKY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5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 13:54:39.4365 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VTqA+B+Zf7ybNB4jt6o30DQ6bCZG67ADuhOfE5up9/yPvjWKdkuec8cXiSP1gwxl X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5157 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 23, 2021 at 04:45:45PM +0300, Maor Gottlieb wrote: > > On 8/23/2021 3:45 PM, Jason Gunthorpe wrote: > > On Mon, Aug 23, 2021 at 02:09:37PM +0300, Maor Gottlieb wrote: > > > On 8/20/2021 6:54 PM, Jason Gunthorpe wrote: > > > > On Thu, Jul 29, 2021 at 12:39:12PM +0300, Leon Romanovsky wrote: > > > > > > > > > +/** > > > > > + * __sg_free_table - Free a previously mapped sg table > > > > > + * @table: The sg table header to use > > > > > + * @max_ents: The maximum number of entries per single scatterlist > > > > > + * @total_ents: The total number of entries in the table > > > > > + * @nents_first_chunk: Number of entries int the (preallocated) first > > > > > + * scatterlist chunk, 0 means no such preallocated > > > > > + * first chunk > > > > > + * @free_fn: Free function > > > > > + * > > > > > + * Description: > > > > > + * Free an sg table previously allocated and setup with > > > > > + * __sg_alloc_table(). The @max_ents value must be identical to > > > > > + * that previously used with __sg_alloc_table(). > > > > > + * > > > > > + **/ > > > > > +void __sg_free_table(struct sg_table *table, unsigned int max_ents, > > > > > + unsigned int nents_first_chunk, sg_free_fn *free_fn) > > > > > +{ > > > > > + sg_free_table_entries(table, max_ents, nents_first_chunk, free_fn, > > > > > + table->orig_nents); > > > > > +} > > > > > EXPORT_SYMBOL(__sg_free_table); > > > > This is getting a bit indirect, there is only one caller of > > > > __sg_free_table() in sg_pool.c, so may as well just export > > > > sg_free_table_entries have have it use that directly. > > > So I can just extend __sg_free_table to get number of entries. What do you > > > think? > > Isn't the point here that different paths to __sg_free_table require > > different entries? What do you mean? > > I mean that  __sg_free_table will get the number of entries. sg_pool will > call it with table->orig_nents and sg_free_append_table will call it with > with total_nents. That is sort of what you've done, just renamed __sg_free_table to sg_free_table_entries in the process, which seem fine enough Jason