From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5CC7C433EF for ; Fri, 28 Jan 2022 03:57:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 3466840240; Fri, 28 Jan 2022 03:57:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m0Buqv5Uq9SF; Fri, 28 Jan 2022 03:57:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id B93DD4020C; Fri, 28 Jan 2022 03:57:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 90EA9C001A; Fri, 28 Jan 2022 03:57:56 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6C4CBC000B for ; Fri, 28 Jan 2022 03:57:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4B109401FD for ; Fri, 28 Jan 2022 03:57:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YiahsaYI3_ic for ; Fri, 28 Jan 2022 03:57:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 389D4415FD for ; Fri, 28 Jan 2022 03:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643342270; 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: in-reply-to:in-reply-to:references:references; bh=jWvHlR7f12xl5QlYdeCb5wE6G0pG1QFlh+7tBOuNAe4=; b=hCKCprMi1LbVo06hC0WJ3D1D3I9L0hnLpRL1fzc/LjctT43STCnbHSU9UK/2luGB1yTP64 X+vT/NwYOgNcyYN1HTTsm9aMVmoFmkhtYeIvousL7+GwyEOsJ3DbEbowK1Fxy1M7MZXsJn MwaVz44qH3oA4G88TGITISkz/3bXyVM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-I91Rer8zNXWVfEUysTfBDw-1; Thu, 27 Jan 2022 22:57:44 -0500 X-MC-Unique: I91Rer8zNXWVfEUysTfBDw-1 Received: by mail-wr1-f69.google.com with SMTP id q4-20020adfbb84000000b001dd3cfddb2dso1750077wrg.11 for ; Thu, 27 Jan 2022 19:57:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jWvHlR7f12xl5QlYdeCb5wE6G0pG1QFlh+7tBOuNAe4=; b=3/zhtFcEWIXShhoahx0Y2OVGxjFm+cjxAk6anzHCHvDDZcmX8nfC593NjLHgZGAHbX ogLqFlor1klKbvfxA6wDtdFJSX0z8cVmeqybtk5swLF7mUbh49TwxzsFZJJr8LaaHkud tclQzXyFESt4WGFYJ99f8EfZxgpR8sxxbKDiunZVoUd7vL3Qi+NtjF+9h3Ju+6ScIz2x N6zGoudQ20yoyPjAjBvqQlajy8dSRbZJNKJh+txBgEx+g6+UWWFXH/lTMS7t9a9MScc/ x8YKGHhlCTuemGTTMoX5y5yZCeaXp8bHpjLPzc0YkJG0tbsd75sbkUalypDmm6WAR9BP LeYQ== X-Gm-Message-State: AOAM530PlJb64SGiSDJh0pDbDQYrzJVikY5ceK8Th2OTq3IEUSf3izU7 qCPt7DAjIiuoLKtm7CwvQw0N3uw5AraXju2D6koWr8IbtCkR3srrVe8LmpuV3QqJjxD6wlcpFo0 XGPd10ot6ztWRYA/v5xt+s8i4r7HU+LyLPjTrUj6f6Q== X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr5410544wri.432.1643342262988; Thu, 27 Jan 2022 19:57:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf5IuzSvJxcgfQuZPBSRPgkHI3ACKszhhRY9oImVHXp/pw0dSLnOrDNR2IlDXGR3OHU8Bbrg== X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr5410528wri.432.1643342262784; Thu, 27 Jan 2022 19:57:42 -0800 (PST) Received: from xz-m1.local ([64.64.123.9]) by smtp.gmail.com with ESMTPSA id u14sm946742wmq.24.2022.01.27.19.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 19:57:42 -0800 (PST) Date: Fri, 28 Jan 2022 11:57:32 +0800 From: Peter Xu To: Eugenio Perez Martin Subject: Re: [PATCH 21/31] util: Add iova_tree_alloc Message-ID: References: <20220121202733.404989-1-eperezma@redhat.com> <20220121202733.404989-22-eperezma@redhat.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: Laurent Vivier , Parav Pandit , Cindy Lu , "Michael S. Tsirkin" , Richard Henderson , qemu-level , Gautam Dawar , Markus Armbruster , Eduardo Habkost , Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Paolo Bonzini , Zhu Lingshan , virtualization , Eric Blake X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Thu, Jan 27, 2022 at 10:24:27AM +0100, Eugenio Perez Martin wrote: > On Thu, Jan 27, 2022 at 9:06 AM Peter Xu wrote: > > > > On Tue, Jan 25, 2022 at 10:40:01AM +0100, Eugenio Perez Martin wrote: > > > So I think that the first step to remove complexity from the old one > > > is to remove iova_begin and iova_end. > > > > > > As Jason points out, removing iova_end is easier. It has the drawback > > > of having to traverse all the list beyond iova_end, but a well formed > > > iova tree should contain none. If the guest can manipulate it, it's > > > only hurting itself adding nodes to it. > > > > > > It's possible to extract the check for hole_right (or this in Jason's > > > proposal) as a special case too. > > > > > > But removing the iova_begin parameter is more complicated. We cannot > > > know if it's a valid hole without knowing iova_begin, and we cannot > > > resume traversing. Could we assume iova_begin will always be 0? I > > > think not, the vdpa device can return anything through syscall. > > > > Frankly I don't know what's the syscall you're talking about, > > I meant VHOST_VDPA_GET_IOVA_RANGE, which allows qemu to know the valid > range of iova addresses. We get a pair of uint64_t from it, that > indicates the minimum and maximum iova address the device (or iommu) > supports. > > We must allocate iova ranges within that address range, which > complicates this algorithm a little bit. Since the SVQ iova addresses > are not GPA, qemu needs extra code to be able to allocate and free > them, creating a new custom iova as. > > Please let me know if you want more details or if you prefer me to > give more context in the patch message. That's good enough, thanks. > > > I mean this one: > > > > https://lore.kernel.org/qemu-devel/20211029183525.1776416-24-eperezma@redhat.com/ > > > > Though this time I have some comments on the details. > > > > Personally I like that one (probably with some amendment upon the old version) > > more than the current list-based approach. But I'd like to know your thoughts > > too (including Jason). I'll further comment in that thread soon. > > > > Sure, I'm fine with whatever solution we choose, but I'm just running > out of ideas to simplify it. Reading your suggestions on old RFC now. > > Overall I feel list-based one is both more convenient and easy to > delete when qemu raises the minimal glib version, but it adds a lot > more code. > > It could add less code with this less elegant changes: > * If we just put the list entry in the DMAMap itself, although it > exposes unneeded implementation details. > * We force the iova tree either to be an allocation-based or an > insertion-based, but not both. In other words, you can only either use > iova_tree_alloc or iova_tree_insert on the same tree. Yeah, I just noticed it yesterday that there's no easy choice on it. Let's go with either way; it shouldn't block the rest of the code. It'll be good if Jason or Michael share their preferences too. > > I have a few tests to check the algorithms, but they are not in the > qemu test format. I will post them so we all can understand better > what is expected from this. Sure. Thanks. -- Peter Xu _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 051E9C433EF for ; Fri, 28 Jan 2022 04:36:42 +0000 (UTC) Received: from localhost ([::1]:48078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDJ04-000661-KQ for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 23:36:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDIOV-0008WQ-3y for qemu-devel@nongnu.org; Thu, 27 Jan 2022 22:57:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDIOQ-00047C-Qg for qemu-devel@nongnu.org; Thu, 27 Jan 2022 22:57:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643342265; 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: in-reply-to:in-reply-to:references:references; bh=jWvHlR7f12xl5QlYdeCb5wE6G0pG1QFlh+7tBOuNAe4=; b=U+0OT13JbEDquBVk2jeBkvHemBDceFRjbwhSsTcDuPhXTYMbusxHQtvJw687grWfJ1Hl9f ta0VnVVTPXKmj424K3NLZ4P8dF0XHMDDsbidaToaIQdW29tqxDXiAdUD+NMoFz8IP/Dz1P KRPVQekG6xWKa2ix33VdN6QgzFhExlM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-gRhpA2mXOTyDOQyJyMZI0w-1; Thu, 27 Jan 2022 22:57:44 -0500 X-MC-Unique: gRhpA2mXOTyDOQyJyMZI0w-1 Received: by mail-wr1-f69.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so1754450wrc.5 for ; Thu, 27 Jan 2022 19:57:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jWvHlR7f12xl5QlYdeCb5wE6G0pG1QFlh+7tBOuNAe4=; b=8B5BNMCk8FovyZPmPl+t/uoBCq6epItV2SDhvK4BlfmNB6tnvtsSqLd8KVNnHgXPrY 9QW9D2AlAQCBJJcBGvUX9Qr12veaRPMMSXD68IYx9f+9j6FrAEJSmcKGKhEW9oq08TFq THdMeC7t12Nl5mwoVhiM6fHfXwGdHCEmHOO1u4t+5hMzsRhuzoUQOWiI0Aqh3ebvvKFx N0cB4H2t1ZjtXYnj6vEi09OquDavOlyahnxkL26bOzoIQ8/NmmhU/TkXGMlsHhisLtgy OTzSf7TE+oqqNti8on6GwN8ZLjxUqPVMps7bwvIMz8D/YO70AjXfrZhq6gAmP2im/vm8 mpsA== X-Gm-Message-State: AOAM5320hKOqumX/by/PphOIsmJfiPsoApMVB7r1CWymsXleG36fheOb QHDNjvI35sI0f+y4snRgZ8AuMGxvgfgjcfR9S9pZ/u4rQ2fzMHdLVPfK0ncSqh3izC3UeLXAwNF 5oAqBs9YlzYnXwiY= X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr5410547wri.432.1643342262988; Thu, 27 Jan 2022 19:57:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf5IuzSvJxcgfQuZPBSRPgkHI3ACKszhhRY9oImVHXp/pw0dSLnOrDNR2IlDXGR3OHU8Bbrg== X-Received: by 2002:a05:6000:1869:: with SMTP id d9mr5410528wri.432.1643342262784; Thu, 27 Jan 2022 19:57:42 -0800 (PST) Received: from xz-m1.local ([64.64.123.9]) by smtp.gmail.com with ESMTPSA id u14sm946742wmq.24.2022.01.27.19.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 19:57:42 -0800 (PST) Date: Fri, 28 Jan 2022 11:57:32 +0800 From: Peter Xu To: Eugenio Perez Martin Subject: Re: [PATCH 21/31] util: Add iova_tree_alloc Message-ID: References: <20220121202733.404989-1-eperezma@redhat.com> <20220121202733.404989-22-eperezma@redhat.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.159, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Parav Pandit , Cindy Lu , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , Richard Henderson , qemu-level , Gautam Dawar , Markus Armbruster , Eduardo Habkost , Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Paolo Bonzini , Zhu Lingshan , virtualization , Eric Blake , Stefano Garzarella Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Jan 27, 2022 at 10:24:27AM +0100, Eugenio Perez Martin wrote: > On Thu, Jan 27, 2022 at 9:06 AM Peter Xu wrote: > > > > On Tue, Jan 25, 2022 at 10:40:01AM +0100, Eugenio Perez Martin wrote: > > > So I think that the first step to remove complexity from the old one > > > is to remove iova_begin and iova_end. > > > > > > As Jason points out, removing iova_end is easier. It has the drawback > > > of having to traverse all the list beyond iova_end, but a well formed > > > iova tree should contain none. If the guest can manipulate it, it's > > > only hurting itself adding nodes to it. > > > > > > It's possible to extract the check for hole_right (or this in Jason's > > > proposal) as a special case too. > > > > > > But removing the iova_begin parameter is more complicated. We cannot > > > know if it's a valid hole without knowing iova_begin, and we cannot > > > resume traversing. Could we assume iova_begin will always be 0? I > > > think not, the vdpa device can return anything through syscall. > > > > Frankly I don't know what's the syscall you're talking about, > > I meant VHOST_VDPA_GET_IOVA_RANGE, which allows qemu to know the valid > range of iova addresses. We get a pair of uint64_t from it, that > indicates the minimum and maximum iova address the device (or iommu) > supports. > > We must allocate iova ranges within that address range, which > complicates this algorithm a little bit. Since the SVQ iova addresses > are not GPA, qemu needs extra code to be able to allocate and free > them, creating a new custom iova as. > > Please let me know if you want more details or if you prefer me to > give more context in the patch message. That's good enough, thanks. > > > I mean this one: > > > > https://lore.kernel.org/qemu-devel/20211029183525.1776416-24-eperezma@redhat.com/ > > > > Though this time I have some comments on the details. > > > > Personally I like that one (probably with some amendment upon the old version) > > more than the current list-based approach. But I'd like to know your thoughts > > too (including Jason). I'll further comment in that thread soon. > > > > Sure, I'm fine with whatever solution we choose, but I'm just running > out of ideas to simplify it. Reading your suggestions on old RFC now. > > Overall I feel list-based one is both more convenient and easy to > delete when qemu raises the minimal glib version, but it adds a lot > more code. > > It could add less code with this less elegant changes: > * If we just put the list entry in the DMAMap itself, although it > exposes unneeded implementation details. > * We force the iova tree either to be an allocation-based or an > insertion-based, but not both. In other words, you can only either use > iova_tree_alloc or iova_tree_insert on the same tree. Yeah, I just noticed it yesterday that there's no easy choice on it. Let's go with either way; it shouldn't block the rest of the code. It'll be good if Jason or Michael share their preferences too. > > I have a few tests to check the algorithms, but they are not in the > qemu test format. I will post them so we all can understand better > what is expected from this. Sure. Thanks. -- Peter Xu