Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp969106rdb; Fri, 1 Dec 2023 03:47:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwkA8TYJQ5ANcRv7IlG50eL/sR+ElLZnrWQayPCdzOko8evSPPFzCDWEon6lVsEhPgSSbr X-Received: by 2002:a05:6871:a506:b0:1fa:a802:5f0d with SMTP id wc6-20020a056871a50600b001faa8025f0dmr7008972oab.35.1701431258118; Fri, 01 Dec 2023 03:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701431258; cv=none; d=google.com; s=arc-20160816; b=Fsr1g1s6H+5/pirb+IZGAcaver9cdfgktI1oXtugFctPVH+9OQjANmQklty+9x0Gfy I2sU3fwnyJmmamZjkywVA+P3VJ5OtCqabRfVnw8S5v5L+3QLVdnVXqy5D/5Sjb7ll/2E a4KQu9VFYSavW72IvoLCe3obnp1i2Ia1Zi1FGrt2qE0ha70IiTtQ/icXZnGrtYjDTytb 01m2lHSXTFpkUO25226glS+SLSq/26t3w8h/8j9q5g2SH/4rVz4w7FqY1sbv2QZ2xAmE jz4Ymt559fYHzvpncrfRqLWh8gRsMt7FvuB1G3lM+3Rw6u2V87dD5CvfaUIStq31mVPw B1hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6uHVtje56LWat5Vmv+PcEyAck+di+XL9VN6HEiOJE+M=; fh=JqrXZ/hxBqEZkqRbynoXzQzhQXe6pWuIw9AElvFpeBU=; b=MmrmjD8xYi3fL18/rOMnFSFTTzM5ghQBL09tdwdiF4U7yrpTB6TtNWzctlBok78mCd fgFupLr173Tn/TyRYg9K8DXpk8i/yjQfBX/jC//TIds7Ui/KgFQ3ib/N/5qRwblFiYDm UwWsHGuTOt+1kj4cmGlQMqmPVNqqjsXs4n84hy5H3d4jrdgM5wf6YBua8D115ISvwbcO uq6NfeOVu1mbZK9IJYhHdxl3g4MjUMFzxHqCYa7bm+ZjO2HLgcReLVjB8mFTYF7Wm296 Qz8OGzNcWh1hop1X2ACiY0jKiRvpO6L1kPVQjBcKwTjDNw/vNQw5zVm0+r9Zq96VuncK Dw1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cpgMDxSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g10-20020a656cca000000b005ae22729b09si3310892pgw.683.2023.12.01.03.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 03:47:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cpgMDxSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 67C8F8521376; Fri, 1 Dec 2023 03:47:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378590AbjLALrT (ORCPT + 99 others); Fri, 1 Dec 2023 06:47:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378541AbjLALrS (ORCPT ); Fri, 1 Dec 2023 06:47:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C85F1B3 for ; Fri, 1 Dec 2023 03:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701431243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6uHVtje56LWat5Vmv+PcEyAck+di+XL9VN6HEiOJE+M=; b=cpgMDxSzDZ0GU5naCPN+Zw1Hm/HvfEp5RiIe/Z9ZYzovUW+9lG6Hd+Sy4Mu/+qdIJpBZiM R63J8fzLMIbFJVHCszWTGSsLlVbXZrEsht35pdXB603J4wMTDfmyAfHubD/InsJUgWwwvJ SBVwU/Eq6SQ9rM76MH2B1YN26S2SzaM= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-QrJ49SLzMZWsOdh1H5s26A-1; Fri, 01 Dec 2023 06:47:22 -0500 X-MC-Unique: QrJ49SLzMZWsOdh1H5s26A-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-5d6b751dabcso2349057b3.1 for ; Fri, 01 Dec 2023 03:47:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701431242; x=1702036042; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6uHVtje56LWat5Vmv+PcEyAck+di+XL9VN6HEiOJE+M=; b=k2cS/VeJezRbzJ7MPQoL5O3OG00GWqal5dhuQiVerd3swEwhsxPDe+r1rT3jx4jltn EgVwYq1S8PsxkDfExtZfGJtOwCu8BpbZtQh1oG6Ih7DUaXtHxXiCdUtCM3meXMwwYG3U zQBwP2I/yfY4m2f5wRyclgdaJXxJUFkANIiLlK8WtxrO7jBsgYHmtYNLeJneKcaB7DR5 HSnqJBmlAc6cYIty6E1+ycJ8L7VyrRIjZ0v7xu1/Cfkag8Zy/sfK7OLqaKgitNGo+NjJ hamKgv3/W0bdXohh726T4f68ILff1yV49K5fZayGVRsYVwAnzcENc+jdaHoQV3RUnV7q wH5g== X-Gm-Message-State: AOJu0YzsGaV+T6W+Ng2NWT+bh12tCcXyMMlUh9FzAGLfRhOBR7QR8HZi DD6D3IFbOJSN8ZOzRCMKqyq7qwhl6gSpF4i6raqoSNipxUqzVZE6DM226RtLIzd+H9P0SC8vhiE dBQyEPM34L4UlYfUtAJKW/OoyIeFmNUnqABHI6tN+ X-Received: by 2002:a81:b60c:0:b0:5d4:226f:69a4 with SMTP id u12-20020a81b60c000000b005d4226f69a4mr1446066ywh.28.1701431241865; Fri, 01 Dec 2023 03:47:21 -0800 (PST) X-Received: by 2002:a81:b60c:0:b0:5d4:226f:69a4 with SMTP id u12-20020a81b60c000000b005d4226f69a4mr1446054ywh.28.1701431241604; Fri, 01 Dec 2023 03:47:21 -0800 (PST) MIME-Version: 1.0 References: <20231201104857.665737-1-dtatulea@nvidia.com> <20231201104857.665737-3-dtatulea@nvidia.com> In-Reply-To: <20231201104857.665737-3-dtatulea@nvidia.com> From: Eugenio Perez Martin Date: Fri, 1 Dec 2023 12:46:45 +0100 Message-ID: Subject: Re: [PATCH vhost 2/7] vdpa/mlx5: Split function into locked and unlocked variants To: Dragos Tatulea Cc: "Michael S . Tsirkin" , Jason Wang , Si-Wei Liu , Saeed Mahameed , Leon Romanovsky , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Gal Pressman , Parav Pandit , Xuan Zhuo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 03:47:33 -0800 (PST) On Fri, Dec 1, 2023 at 11:49=E2=80=AFAM Dragos Tatulea wrote: > > mlx5_vdpa_destroy_mr contains more logic than _mlx5_vdpa_destroy_mr. > There is no reason for this to be the case. All the logic can go into > the unlocked variant. > > Using the unlocked version is needed in a follow-up patch. And it also > makes it more consistent with mlx5_vdpa_create_mr. > > Signed-off-by: Dragos Tatulea Acked-by: Eugenio P=C3=A9rez > --- > drivers/vdpa/mlx5/core/mr.c | 31 ++++++++++++++++--------------- > 1 file changed, 16 insertions(+), 15 deletions(-) > > diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c > index 2197c46e563a..8c80d9e77935 100644 > --- a/drivers/vdpa/mlx5/core/mr.c > +++ b/drivers/vdpa/mlx5/core/mr.c > @@ -498,32 +498,32 @@ static void destroy_user_mr(struct mlx5_vdpa_dev *m= vdev, struct mlx5_vdpa_mr *mr > > static void _mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev, struct ml= x5_vdpa_mr *mr) > { > + if (!mr) > + return; > + > if (mr->user_mr) > destroy_user_mr(mvdev, mr); > else > destroy_dma_mr(mvdev, mr); > > + for (int i =3D 0; i < MLX5_VDPA_NUM_AS; i++) { > + if (mvdev->mr[i] =3D=3D mr) > + mvdev->mr[i] =3D NULL; > + } > + > vhost_iotlb_free(mr->iotlb); > + > + kfree(mr); > } > > void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev, > struct mlx5_vdpa_mr *mr) > { > - if (!mr) > - return; > - > mutex_lock(&mvdev->mr_mtx); > > _mlx5_vdpa_destroy_mr(mvdev, mr); > > - for (int i =3D 0; i < MLX5_VDPA_NUM_AS; i++) { > - if (mvdev->mr[i] =3D=3D mr) > - mvdev->mr[i] =3D NULL; > - } > - > mutex_unlock(&mvdev->mr_mtx); > - > - kfree(mr); > } > > void mlx5_vdpa_update_mr(struct mlx5_vdpa_dev *mvdev, > @@ -535,10 +535,7 @@ void mlx5_vdpa_update_mr(struct mlx5_vdpa_dev *mvdev= , > mutex_lock(&mvdev->mr_mtx); > > mvdev->mr[asid] =3D new_mr; > - if (old_mr) { > - _mlx5_vdpa_destroy_mr(mvdev, old_mr); > - kfree(old_mr); > - } > + _mlx5_vdpa_destroy_mr(mvdev, old_mr); > > mutex_unlock(&mvdev->mr_mtx); > > @@ -546,8 +543,12 @@ void mlx5_vdpa_update_mr(struct mlx5_vdpa_dev *mvdev= , > > void mlx5_vdpa_destroy_mr_resources(struct mlx5_vdpa_dev *mvdev) > { > + mutex_lock(&mvdev->mr_mtx); > + > for (int i =3D 0; i < MLX5_VDPA_NUM_AS; i++) > - mlx5_vdpa_destroy_mr(mvdev, mvdev->mr[i]); > + _mlx5_vdpa_destroy_mr(mvdev, mvdev->mr[i]); > + > + mutex_unlock(&mvdev->mr_mtx); > > prune_iotlb(mvdev->cvq.iotlb); > } > -- > 2.42.0 >