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=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 DB523C433E0 for ; Wed, 3 Feb 2021 01:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE0D164F67 for ; Wed, 3 Feb 2021 01:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbhBCB1y (ORCPT ); Tue, 2 Feb 2021 20:27:54 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12069 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhBCB1x (ORCPT ); Tue, 2 Feb 2021 20:27:53 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DVkWv5tQ5zMTrn; Wed, 3 Feb 2021 09:25:31 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Feb 2021 09:27:05 +0800 Subject: Re: [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error To: Suren Baghdasaryan , CC: , , , , , , , , , , , , , , , , , , , References: <20210203003134.2422308-1-surenb@google.com> From: Miaohe Lin Message-ID: Date: Wed, 3 Feb 2021 09:27:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210203003134.2422308-1-surenb@google.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.241] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi: On 2021/2/3 8:31, 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. > > Suggested-by: Christoph Hellwig > Signed-off-by: Suren Baghdasaryan Looks reasonable. Thanks. Reviewed-by: Miaohe Lin > --- > mm/memory.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/memory.c b/mm/memory.c > index feff48e1465a..e503c9801cd9 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1827,7 +1827,8 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, > return -EINVAL; > if (!(vma->vm_flags & VM_MIXEDMAP)) { > BUG_ON(mmap_read_trylock(vma->vm_mm)); > - BUG_ON(vma->vm_flags & VM_PFNMAP); > + if (WARN_ON_ONCE(vma->vm_flags & VM_PFNMAP)) > + return -EINVAL; > vma->vm_flags |= VM_MIXEDMAP; > } > return insert_page(vma, addr, page, vma->vm_page_prot); > 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=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 DDEAFC433E0 for ; Wed, 3 Feb 2021 08:13:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6EBB764F67 for ; Wed, 3 Feb 2021 08:13:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EBB764F67 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4CCC46EA06; Wed, 3 Feb 2021 08:13:13 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9AE336E9D7 for ; Wed, 3 Feb 2021 01:27:16 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DVkWv5tQ5zMTrn; Wed, 3 Feb 2021 09:25:31 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Feb 2021 09:27:05 +0800 Subject: Re: [PATCH 1/2] mm: replace BUG_ON in vm_insert_page with a return of an error To: Suren Baghdasaryan , References: <20210203003134.2422308-1-surenb@google.com> From: Miaohe Lin Message-ID: Date: Wed, 3 Feb 2021 09:27:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210203003134.2422308-1-surenb@google.com> Content-Language: en-US X-Originating-IP: [10.174.179.241] X-CFilter-Loop: Reflected X-Mailman-Approved-At: Wed, 03 Feb 2021 08:13:07 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linaro-mm-sig@lists.linaro.org, orjan.eide@arm.com, sspatil@google.com, linux-mm@kvack.org, kernel-team@android.com, jajones@nvidia.com, linux-kernel@vger.kernel.org, lmark@codeaurora.org, christian.koenig@amd.com, hch@infradead.org, minchan@kernel.org, dri-devel@lists.freedesktop.org, cgoldswo@codeaurora.org, hridya@google.com, akpm@linux-foundation.org, labbott@redhat.com, robin.murphy@arm.com, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi: On 2021/2/3 8:31, 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. > > Suggested-by: Christoph Hellwig > Signed-off-by: Suren Baghdasaryan Looks reasonable. Thanks. Reviewed-by: Miaohe Lin > --- > mm/memory.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/memory.c b/mm/memory.c > index feff48e1465a..e503c9801cd9 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1827,7 +1827,8 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, > return -EINVAL; > if (!(vma->vm_flags & VM_MIXEDMAP)) { > BUG_ON(mmap_read_trylock(vma->vm_mm)); > - BUG_ON(vma->vm_flags & VM_PFNMAP); > + if (WARN_ON_ONCE(vma->vm_flags & VM_PFNMAP)) > + return -EINVAL; > vma->vm_flags |= VM_MIXEDMAP; > } > return insert_page(vma, addr, page, vma->vm_page_prot); > _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel