Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp779602pxb; Tue, 2 Feb 2021 18:29:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdbKlE60ngbtZqtSGG2x2JANIe8J3vc5odUXOcplD1qPqjt7ixPkcbr52k8k3FrNXhs55a X-Received: by 2002:a05:6402:3070:: with SMTP id bs16mr931088edb.22.1612319359379; Tue, 02 Feb 2021 18:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612319359; cv=none; d=google.com; s=arc-20160816; b=0xJXqbjqTqHAkaT2LjRmdQVbK2mCWMdERSDEJlxEXHhvowcP9lO2b6/6sOin3BWXw4 DJtoT6Ey6cAtiREhjOA2ZdvduniyrdhniMo90u7AvWMKn4gxf5OZgt/QWXd6ohB6561c bDNwbVIS+BGoa9qoIkLNKPDXu4aXOIgg6HEJ2HJe+dI47ls5/xD0jNbRFhO5/Vx/n09x wapRo1Miv/qYszJN7roC/XJmpPJC2Wa5Dk7f+ZJqQKbsYnZRzNXlzKYzRuukg0DaMgoC qn+xHSo2oT9JxRGjVaD77H89CcvPFANdySpMeSN+lyHjeMHzVGgt3NfATfQZzAWztlhX r+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Uc4Qty+5tEkUX3Oy4yRHsOTw3F10hKVAPg2EbH1/158=; b=CnOoDZj1Q4BMTDlkyYQbAk4HqvQkblM3wfLr0nwWRo/Jr+npaaNm5VFp/LLSH28baj zSZgdDsGNCzDz0JUbKlDIiC0ZCOolQPJcn1mw7AENOW0QL8Zy7IxweWegC8Yp++shM0t Qz77F8rk6aSKBA6d3V4Aoz3BkW8bHZqscLKGhQsVlKOTMKUSS3ROnc2W6/TDxVYeW4m/ zQP3fbAgQ2gNv1fbn7l5u8W2o4srJ9sDWnbYSbF7L3VjI52vFjdWStb0vY1bH2p1NNtl s8oecD5N26426AW7DB/Aj2jWKWi4nGEMonQI2Ukt0S3bmS/Ui8QNwm9wGkrrZjQgXRc2 aW3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RsYuDkkj; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn20si480515ejc.418.2021.02.02.18.28.50; Tue, 02 Feb 2021 18:29:19 -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=@google.com header.s=20161025 header.b=RsYuDkkj; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbhBCC1Z (ORCPT + 99 others); Tue, 2 Feb 2021 21:27:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbhBCC1P (ORCPT ); Tue, 2 Feb 2021 21:27:15 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E0ACC06174A for ; Tue, 2 Feb 2021 18:26:35 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id p15so22411940wrq.8 for ; Tue, 02 Feb 2021 18:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Uc4Qty+5tEkUX3Oy4yRHsOTw3F10hKVAPg2EbH1/158=; b=RsYuDkkjXxaWE8kw/n+kzBzlYdKiQ17h3HXujdu00oj/DBl5tpK/+tbtqtVKSbg0aQ K84VvjMxpwhMsx9QCpdfEmalSWpry53eknjWVRW2ZtzszFvkGzuijhora5Zg0IN2hARc Q3e2sT6/kCvOu5hHd+6oMNslcg6fz/ukZdn2FY8IyekWHSUF3ILilPxAF7Du7kRomgjh mswhSMsTitGj64T88bkD4pR3RwXt96GMUQWWBeN9kJSeE4PLkcprxlugFDRXKHecP/ja SOnz509daLDVsJiZQM1E0gtyBcpH6wRBXbGA37hGcEUdrKdqqm74qYFIYAbGCsXlh5Dy Z1AA== 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=Uc4Qty+5tEkUX3Oy4yRHsOTw3F10hKVAPg2EbH1/158=; b=Klop20XpRmKsVspv0mfaL8Idw18xIL/ySmiHjAyuGlFq9xRN4sB/9mvxnK4q3Rn314 i3T5sBZiUB/hGo5nyVhBzLbBSsjRckcje+VveiivO4lqNf47qOr3nYMqWiSdPW4abFR6 SqSTTZKaq4pgfP3SeVgIaSmRQV//l/kWQyHfJMNqPb1DC4KGaSKZLCA+vcchPIKoCF7k vuWjrIrZEIm359i5TT9cVsEXoK486gMJHDIVEWVBoE1P0SIxLKud5viDwtJP/4m5FVDL ASiwInO+9cXfW7hFr2viy1fQqpYlPJIlbAIVrP6gxNocUJfXOMRksiscWACo27Ha1OE9 hl/g== X-Gm-Message-State: AOAM533DD11XUJi9CdnQdIyEDWCTgG6P4JX5Jf5iD444kwVbDHavhDgz 0IEkR1DAZJu+Vv983TbpC5N3yiIndb+Ogt3u3+W+8g== X-Received: by 2002:a5d:453b:: with SMTP id j27mr930767wra.92.1612319193577; Tue, 02 Feb 2021 18:26:33 -0800 (PST) MIME-Version: 1.0 References: <20210203003134.2422308-1-surenb@google.com> <20210203015553.GX308988@casper.infradead.org> In-Reply-To: <20210203015553.GX308988@casper.infradead.org> From: Suren Baghdasaryan Date: Tue, 2 Feb 2021 18:26:22 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error To: Matthew Wilcox Cc: Sumit Semwal , Andrew Morton , Christoph Hellwig , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , =?UTF-8?Q?Christian_K=C3=B6nig?= , Chris Goldsworthy , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , James Jones , Minchan Kim , Hridya Valsaraju , Sandeep Patil , linux-media , DRI mailing list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , linux-mm , LKML , kernel-team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 2, 2021 at 5:55 PM Matthew Wilcox wrote: > > On Tue, Feb 02, 2021 at 04:31:33PM -0800, Suren Baghdasaryan wrote: > > Replace BUG_ON(vma->vm_flags & VM_PFNMAP) in vm_insert_page with > > WARN_ON_ONCE and returning an error. This is to ensure users of the > > vm_insert_page that set VM_PFNMAP are notified of the wrong flag usage > > and get an indication of an error without panicing the kernel. > > This will help identifying drivers that need to clear VM_PFNMAP before > > using dmabuf system heap which is moving to use vm_insert_page. > > NACK. > > The system may not _panic_, but it is clearly now _broken_. The device > doesn't work, and so the system is useless. You haven't really improved > anything here. Just bloated the kernel with yet another _ONCE variable > that in a normal system will never ever ever be triggered. We had a discussion in https://lore.kernel.org/patchwork/patch/1372409 about how some DRM drivers set up their VMAs with VM_PFNMAP before mapping them. We want to use vm_insert_page instead of remap_pfn_range in the dmabuf heaps so that this memory is visible in PSS. However if a driver that sets VM_PFNMAP tries to use a dmabuf heap, it will step into this BUG_ON. We wanted to catch and gradually fix such drivers but without causing a panic in the process. I hope this clarifies the reasons why I'm making this change and I'm open to other ideas if they would address this issue in a better way.