Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10325156pxu; Tue, 29 Dec 2020 22:38:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt6ILnvBuHdCfq/8iMhthu3fu9iPyM3AIQ7ZWYzvEmVCHaWQQFN9noxlFqFCZV8U/SXFst X-Received: by 2002:a17:906:d9c7:: with SMTP id qk7mr48162665ejb.384.1609310291514; Tue, 29 Dec 2020 22:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609310291; cv=none; d=google.com; s=arc-20160816; b=WDBv62NMkijpBtPsBje5Vs0G5qWZ8gWabbNcPyjbBQQukrOXnUDSN10/uqLq7oR9i8 ANNHv3KGIenLp0iy/CYzT1Rj3zhfnigpUsWGGJ5qK9/sdwy96BBXM04CNxZKT62V1VT5 PqOUIw9P3Z4yaVa0E4uT/wDjLxph8tpTMOu83HZzVfO4Yp8Q73klSLKO0gvt1xTV/4AN LPGMTmrPuaFhwkUDtAt7Jf3hmp2cn2gwPsabqVU9/0Zv/ihSXv/EEIRN6dtVR7b/Gtx6 Mu7LhoW0WKAp3ph/8LleAiNIiWsmh2cvAhnOqMYXsWgb1Jie4LHb222CeY1aeXBSjv3y BDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=V3lC15jls6IaJqaREYiEoSGla45iKl4vF8Trns9tYY8=; b=Mks5K0kgfJbO7FT7Jz1uxbKd7g9/mgQ0bDJqfLVu2n2fpzPpjVYWewLm3mZN45Raht WP8D9JB7P3554dT1IDf2/2w9IEN8XciEGVDOv4T4a5TYdXTfy/iOoGwrknSkgiWaqeRh iv4nZn8NbP+7kM/JRMdOPfKMV0Hh4yrJFUSV5Jz5r/fvrANUOt4y/XLHpMacUWH1oZVg bO4uJI5ChxiNx//a7EoV5cADZsZfp40lo8uiSvWfndf+11D9DNHwgy21ZigChB16Gqws O5nZF5lELCOGxoADba4khtQCv4hgVyjYQtKeMMCPK7tOtNTwF7r75/uuDXQZWUCKtLtN 5HBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OTF+WfpU; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si21879586ejg.205.2020.12.29.22.37.49; Tue, 29 Dec 2020 22:38:11 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=OTF+WfpU; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbgL3Ggn (ORCPT + 99 others); Wed, 30 Dec 2020 01:36:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47937 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgL3Ggm (ORCPT ); Wed, 30 Dec 2020 01:36:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609310116; 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=V3lC15jls6IaJqaREYiEoSGla45iKl4vF8Trns9tYY8=; b=OTF+WfpUVPmtcmFxRirnfjhubtQeMr/Tx8de5gJl3IjChpPmrwTPYUTOqhz2zko8dzmtqT 7iQ+emaBvUWQski/bdqBL3DyC3euUgFq4lB5j7K16Ln9BBCUOBoDxtEqX8e+mG7j5VSvoX Oz38AZkfWx/5kD9egTelv+en+Umdcy4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-u9IGufgONymH5MxSpEGGwQ-1; Wed, 30 Dec 2020 01:35:12 -0500 X-MC-Unique: u9IGufgONymH5MxSpEGGwQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B2D010054FF; Wed, 30 Dec 2020 06:35:10 +0000 (UTC) Received: from [10.72.13.30] (ovpn-13-30.pek2.redhat.com [10.72.13.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B77922C166; Wed, 30 Dec 2020 06:35:00 +0000 (UTC) Subject: Re: [PATCH 11/21] vhost-vdpa: introduce asid based IOTLB To: Eli Cohen Cc: mst@redhat.com, eperezma@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lulu@redhat.com, eli@mellanox.com, lingshan.zhu@intel.com, rob.miller@broadcom.com, stefanha@redhat.com, sgarzare@redhat.com References: <20201216064818.48239-1-jasowang@redhat.com> <20201216064818.48239-12-jasowang@redhat.com> <20201229115340.GD195479@mtl-vdi-166.wap.labs.mlnx> From: Jason Wang Message-ID: <5df825a2-b794-9374-4ebf-83c5cc14584a@redhat.com> Date: Wed, 30 Dec 2020 14:34:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201229115340.GD195479@mtl-vdi-166.wap.labs.mlnx> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/12/29 下午7:53, Eli Cohen wrote: >> + >> +static struct vhost_vdpa_as *vhost_vdpa_alloc_as(struct vhost_vdpa *v, u32 asid) >> +{ >> + struct hlist_head *head = &v->as[asid % VHOST_VDPA_IOTLB_BUCKETS]; >> + struct vhost_vdpa_as *as; >> + >> + if (asid_to_as(v, asid)) >> + return NULL; >> + >> + as = kmalloc(sizeof(*as), GFP_KERNEL); > kzalloc()? See comment below. > >> + if (!as) >> + return NULL; >> + >> + vhost_iotlb_init(&as->iotlb, 0, 0); >> + as->id = asid; >> + hlist_add_head(&as->hash_link, head); >> + ++v->used_as; > Although you eventually ended up removing used_as, this is a bug since > you're incrementing a random value. Maybe it's better to be on the safe > side and use kzalloc() for as above. Yes and used_as needs to be removed. Thanks >