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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 54BF4C433DB for ; Tue, 2 Feb 2021 08:52:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E85464F65 for ; Tue, 2 Feb 2021 08:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232844AbhBBIwX (ORCPT ); Tue, 2 Feb 2021 03:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbhBBIwL (ORCPT ); Tue, 2 Feb 2021 03:52:11 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD28C061573; Tue, 2 Feb 2021 00:51:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FViyHdjUfYiPSPWgGhgWx2i7ISbpBjSz7lj18u2QJ8c=; b=o8BF2/rSSVljt5i8n6qbO/QXkX uTDow7BL1VRjIjeNTYduv6qpazB3bUBKMLHOBj7URIf0/QWr57A1PDKoiNiwbmRc+yUb4PPwFtI6e qSD2LIFGI1gFs5gBUwxcMHsWFqKbnme6PjxGzqEtWqno5TS1vkPy1DBH6iHJUoH7YVYWENUAMvP+V Rs/OJdurrfpD+TrMiS6OL3o1yhBgj8Zc1nEaFh1EtmvXZuoYTnBSt55gELYpUPEhTJDd6qmeBcliT QgWqwpuk8K3Gyf6r2ipRWREvVg72kZO/EOhtumjXBvnb1RPc/CeKYG3hnJjaExk0Kh0+F92N7D5zf HIFR8YuA==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l6rP0-00Ewuo-Sx; Tue, 02 Feb 2021 08:51:15 +0000 Date: Tue, 2 Feb 2021 08:51:14 +0000 From: Christoph Hellwig To: Suren Baghdasaryan Cc: Christoph Hellwig , Minchan Kim , Sumit Semwal , "(Exiting) Benjamin Gaignard" , Liam Mark , labbott@redhat.com, Brian Starkey , John Stultz , Christian K??nig , Chris Goldsworthy , ??rjan Eide , Robin Murphy , James Jones , Hridya Valsaraju , Sandeep Patil , linux-media , DRI mailing list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , LKML , kernel-team Subject: Re: [PATCH 1/1] dma-buf: heaps: Map system heap pages as managed by linux vm Message-ID: <20210202085114.GA3562876@infradead.org> References: <20210128083817.314315-1-surenb@google.com> <20210128091348.GA1962975@infradead.org> <20210202070336.GA3535861@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 02, 2021 at 12:44:44AM -0800, Suren Baghdasaryan wrote: > On Mon, Feb 1, 2021 at 11:03 PM Christoph Hellwig wrote: > > > > IMHO the > > > > BUG_ON(vma->vm_flags & VM_PFNMAP); > > > > in vm_insert_page should just become a WARN_ON_ONCE with an error > > return, and then we just need to gradually fix up the callers that > > trigger it instead of coming up with workarounds like this. > > For the existing vm_insert_page users this should be fine since > BUG_ON() guarantees that none of them sets VM_PFNMAP. Even for them WARN_ON_ONCE plus an actual error return is a way better assert that is much developer friendly. > However, for the > system_heap_mmap I have one concern. When vm_insert_page returns an > error due to VM_PFNMAP flag, the whole mmap operation should fail > (system_heap_mmap returning an error leading to dma_buf_mmap failure). > Could there be cases when a heap user (DRM driver for example) would > be expected to work with a heap which requires VM_PFNMAP and at the > same time with another heap which requires !VM_PFNMAP? IOW, this > introduces a dependency between the heap and its > user. The user would have to know expectations of the heap it uses and > can't work with another heap that has the opposite expectation. This > usecase is purely theoretical and maybe I should not worry about it > for now? If such a case ever arises we can look into it.