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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 ECD50C433E0 for ; Wed, 3 Feb 2021 02:26:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8903564F59 for ; Wed, 3 Feb 2021 02:26:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8903564F59 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EB0D96B0070; Tue, 2 Feb 2021 21:26:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E61916B0071; Tue, 2 Feb 2021 21:26:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D79B76B0072; Tue, 2 Feb 2021 21:26:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id C0F526B0070 for ; Tue, 2 Feb 2021 21:26:35 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 86F1E3635 for ; Wed, 3 Feb 2021 02:26:35 +0000 (UTC) X-FDA: 77775367950.03.clam51_2a0fe27275cf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 6954328A4E8 for ; Wed, 3 Feb 2021 02:26:35 +0000 (UTC) X-HE-Tag: clam51_2a0fe27275cf X-Filterd-Recvd-Size: 4973 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 3 Feb 2021 02:26:34 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id 7so22497091wrz.0 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=B2icOEHhF1wU819NH5uGVSfqZ3sVFivlOf0SkYZGk8aYe6s2n6Qj4mHpuRZQZ9Z3ZL I3yKeot+Cov7WVEecW1cRkCnNP9xUyHPdTXI9AFDsbal136y5ywP/s+FuLN3QLnZmq/5 QTwrMCl22GPZHL0EJsyAb3pY1qKcCMWo0TJB78bur0fubpA19yjBOBQWEe7SchnxojIG BGlqOyFQgt2XQLZeQkhBa/6NHTjjdmAGCyD1O91+5PRn9+t/ehf+IBGZqkUtwBSGmfHy /hoNIvGOxptApZ15TB1PjZhgq9b27Cvba/s4Z8gPCuA7V2Esih40rbXUpfKULOd+cPjn +dtg== X-Gm-Message-State: AOAM532w3EhG5SyykkJwrvNx/64v9ulvHListD6ZJ4UwSkSLZ9moAiPc jVO9AoX3HmVWde08bZHny9DcWoe/B8QNggqv5efHTw== X-Google-Smtp-Source: ABdhPJy6fGFUBvfPcPkeOCTJpRJofvPTFjYyVYvrOMlWx5vJKlJpzyy3HdXZL3OGYGKpL/SuZw5CvuxZEEfSKXife4g= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.