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 X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 245F2C433ED for ; Wed, 28 Apr 2021 12:08:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7904161419 for ; Wed, 28 Apr 2021 12:08:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7904161419 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbize-0007Hi-6W for qemu-devel@archiver.kernel.org; Wed, 28 Apr 2021 08:08:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbix0-0005UB-F6 for qemu-devel@nongnu.org; Wed, 28 Apr 2021 08:05:54 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]:39819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbiwt-00017G-Nc for qemu-devel@nongnu.org; Wed, 28 Apr 2021 08:05:50 -0400 Received: by mail-io1-xd34.google.com with SMTP id k25so19590847iob.6 for ; Wed, 28 Apr 2021 05:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MteE/g/KmQ9BlQnYvGg30lhYeZdvbq7IAml0pL394Qs=; b=CrynjyOVZL6/shRVFdLnrQGrZTnnRxkeu6U7/7CMFwrHUpjHPnIjS37cZfn81ZETkg WxAC7nFoW7Q1/GgHnoMf96M7K3LArUbdpMufhtPSkxt+g+y3gp1hImC8V+ED/v1o8cqM 78Hvj/VCwbEps8WYk18TEgvr7fSnK8IK+fwzr3QsRhAhmhkQCIwcA9ozeb7T9GsQ9M2i tOJn0afXqGd17F4A2FaCX8gLiaLy1CxXXcGAD27RxxyS+Ne2gpXGEKcwkSKPfDBy1C4k mHGl/j66yPl7T8up46UQwEcHuudeysikg7dmsfGvCkgNqUc7uqBhmpxJknupEQX4u+WP VRjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MteE/g/KmQ9BlQnYvGg30lhYeZdvbq7IAml0pL394Qs=; b=a38muvd1FoWioVw4HgFxlJLrnFPNa9XsMdmaYWfgBTZKUInkVx/L8SVzctQK4SZIeh 36MBU0IN+t0opI86sZYtxPgvApujUbBqontJUUPlA78TlTqorQAex7LIEl8d0Q9sW2E3 IlOWbSiRfqiw7OZjkvvp/K962FeXqPRTcGENRbpJCxD1NEONCUCfCVZhgTTt3yP57SAk ztnbTFRV/rUoA9eNdl5KxmzOTeIqicQ7wsSM6f/CbUeSys9bOg8sSRMd46xBZk902L9X LrQPWQCVrAvFrIdkG2xJ7EUIpuNzSflzoIE6XAKdc7W4rJHlE8iT6aQFvK4yehP4Mlvf hmZg== X-Gm-Message-State: AOAM53074oeasui2YB1F2OzkaQt9LVKKnrukikXZo49h/Eheu52o4u2I 21Z6cGBhOfg6Yv+cXLrVuvm7TcuPzLtu+/b6i5c= X-Google-Smtp-Source: ABdhPJxTkJLt+MGqyaYsRzxqQXLyGjYyCYjVO08zvaZwDx2+vpiA2EQqK4gKDorDcT2pI/Z1crFwWmPucJSgzl8GEJU= X-Received: by 2002:a05:6638:2515:: with SMTP id v21mr26862139jat.110.1619611542943; Wed, 28 Apr 2021 05:05:42 -0700 (PDT) MIME-Version: 1.0 References: <20210426152203.379dab00@redhat.com> <20210427121850.68d2a8dd@redhat.com> In-Reply-To: From: Dev Audsin Date: Wed, 28 Apr 2021 13:04:57 +0100 Message-ID: Subject: Re: [PATCH] make vfio and DAX cache work together To: "Dr. David Alan Gilbert" Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::d34; envelope-from=dev.devaqemu@gmail.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Williamson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Thanks Dave for your explanation. Any suggestions on how to make VFIO not attempt to map into the unaccessible and unallocated RAM. Best Dev On Tue, Apr 27, 2021 at 8:00 PM Dr. David Alan Gilbert wrote: > > * Alex Williamson (alex.williamson@redhat.com) wrote: > > On Tue, 27 Apr 2021 17:29:37 +0100 > > Dev Audsin wrote: > > > > > Hi Alex > > > > > > Based on your comments and thinking a bit, wonder if it makes sense to > > > allow DMA map for the DAX cache but make unexpected mappings to be not > > > fatal. Please let me know your thoughts. > > > > I think you're still working on the assumption that simply making the > > VM boot is an improvement, it's not. If there's a risk that a possible > > DMA target for the device cannot be mapped, it's better that the VM > > fail to boot than to expose that risk. Performance cannot compromise > > correctness. > > > > We do allow DMA mappings to other device memory regions to fail > > non-fatally with the logic that peer-to-peer DMA is often not trusted > > to work by drivers and therefore support would be probed before > > assuming that it works. I don't think that same logic applies here. > > > > Is there something about the definition of this particular region that > > precludes it from being a DMA target for an assigned devices? > > It's never really the ram that's used. > This area is really a chunk of VMA that's mmap'd over by (chunks of) > normal files in the underlying exported filesystem. The actual RAM > block itself is just a placeholder for the VMA, and is normally mapped > PROT_NONE until an actual file is mapped on top of it. > That cache bar is a mapping containing multiple separate file chunk > mappings. > > So I guess the problems for VFIO are: > a) At the start it's unmapped, unaccessible, unallocated ram. > b) Later it's arbitrary chunks of ondisk files. > > [on a bad day, and it's bad even without vfio, someone truncates the > file mapping] > > Dave > > > Otherwise if it's initially unpopulated, maybe something like the > > RamDiscardManager could be used to insert DMA mappings as the region > > becomes populated. > > > > Simply disabling mapping to boot with both features together, without > > analyzing how that missing mapping affects their interaction is not > > acceptable. Thanks, > > > > Alex > > > > > On Mon, Apr 26, 2021 at 10:22 PM Alex Williamson > > > wrote: > > > > > > > > On Mon, 26 Apr 2021 21:50:38 +0100 > > > > Dev Audsin wrote: > > > > > > > > > Hi Alex and David > > > > > > > > > > @Alex: > > > > > > > > > > Justification on why this region cannot be a DMA target for the device, > > > > > > > > > > virtio-fs with DAX is currently not compatible with NIC Pass through. > > > > > When a SR-IOV VF attaches to a qemu process, vfio will try to pin the > > > > > entire DAX Window but it is empty when the guest boots and will fail. > > > > > A method to make VFIO and DAX to work together is to make vfio skip > > > > > DAX cache. > > > > > > > > > > Currently DAX cache need to be set to 0, for the SR-IOV VF to be > > > > > attached to Kata containers. Enabling both SR-IOV VF and DAX work > > > > > together will potentially improve performance for workloads which are > > > > > I/O and network intensive. > > > > > > > > Sorry, there's no actual justification described here. You're enabling > > > > a VM with both features, virtio-fs DAX and VFIO, but there's no > > > > evidence that they "work together" or that your use case is simply > > > > avoiding a scenario where the device might attempt to DMA into the area > > > > with this designation. With this change, if the device were to attempt > > > > to DMA into this region, it would be blocked by the IOMMU, which might > > > > result in a data loss within the VM. Justification of this change > > > > needs to prove that this region can never be a DMA target for the > > > > device, not simply that both features can be enabled and we hope that > > > > they don't interact. Thanks, > > > > > > > > Alex > > > > > > > > > > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >