Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp749152pxb; Tue, 2 Feb 2021 17:30:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2M8qCwjcoGCuneEf6KcvUoK3RUU8M+eEh6tpn7esm6lmiKsp8++pLzGI4M/RqacYLvtzZ X-Received: by 2002:a17:906:a453:: with SMTP id cb19mr735234ejb.459.1612315804120; Tue, 02 Feb 2021 17:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612315804; cv=none; d=google.com; s=arc-20160816; b=T/ORcCOKQBKbwJYKHYsCB0Igs8fXxkr+fWVyspHilTQ6FoOYOCu/PJQDillQiAksXY kFrznZzFBSsQla8BSS2uK9NRohUvnbfzPpQTpTbuL8REwuRWBz/aJGkk26qbT9LnAzkh OEig2GDyWqwIROLIha95YaryScEkwMFI6zB7SImRo+BoWIxiNIBc646imCOCkr+mZRpK ZTy/CWvD8UadGRWG1tkX5/Zvvq1Z96itFL54LhSqyhIuogxjMPMM5bpfPJZCGIfRHTGL zkQ1mlq4VtVzlQeEDdMTCbEcoyo4pr263cXNEMdJaagIyIUq1AcJ0j6rzKtF1l+i5Zz7 CNRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qXG1UgdtkX6yxLeqttdkRd8jmYp/dO73+VJ0IHIyr9s=; b=Gtbfzw0jTdOefjbvzoDp++jrwXhXLiTH2CT56l4k+mz7/u5udxPNLUI9VpaCySakD2 Zi3rzL1DBpg6mQXZYraPR0/2S+AnnZ1HSZb3iYanHx1w+CxqTkJJFBcyxXieQmL1bEd2 7NqAQYbeqjYNY7Gh3DmaPGmDQ+X6+j6bMR9rdxodpHEA2ZXpBMDGmxpN2ybluGjThZ1D CS98LS3DVLcXnYsCz6uWMF1v3BtVhpk12PHeLkfrUuslGnlVm0E22fDt7GbJbGMztq0l oljIH6xr9Vq0ESlwif2cKcrh2dmECs8fU6FlrylvbusyPH7dILXp1KWxUYqJLn0PV6qc /hbw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si338742ejp.425.2021.02.02.17.29.40; Tue, 02 Feb 2021 17:30:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbhBCB1y (ORCPT + 99 others); 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); >