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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 E20EAC35247 for ; Mon, 3 Feb 2020 17:29:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6D2B2086A for ; Mon, 3 Feb 2020 17:29:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JzREuCGK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6D2B2086A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D7E26B068E; Mon, 3 Feb 2020 12:29:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 288F26B068F; Mon, 3 Feb 2020 12:29:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19E846B0696; Mon, 3 Feb 2020 12:29:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 02B916B068E for ; Mon, 3 Feb 2020 12:29:43 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 904DD181AEF10 for ; Mon, 3 Feb 2020 17:29:43 +0000 (UTC) X-FDA: 76449503046.17.fowl46_8ee29edaa3253 X-HE-Tag: fowl46_8ee29edaa3253 X-Filterd-Recvd-Size: 3809 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 17:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=gFDzfUt/zIrwKYXfbfbbfiYoV5dvTOmOKE3QH7upgwE=; b=JzREuCGKb6Jh0bEUWRoficKAvf rdEsn/r/MyvDseFhxLc13AWyXPQfqAsNyWGRA5cpxBup+/+RNtoK6sQm6TD2NczVw6ckX7ecAGeaY 6gO12yzT+iNxkEyAo9zrI8htTxdFbqAvWDQOUYOoS0Nm8FvtoPPVm8zOcJojLnegnB5CgK1sSieoG J0gn5SHn6oyKQ8GhtzlJaHaAe84StwMwMza0OSE4nm6EzDuCuViqxYvRh7bbIrQLhSeBbNVe88dWt laFLQ5vB/ZBCz9P9Km7yXln1udx3NqZYnpxLPGzuV4Gm4/CGObPtB1anCUuPcXuwpC8GRmlJROanA bNYYAcUw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iyfX3-00063t-Fx; Mon, 03 Feb 2020 17:29:09 +0000 Date: Mon, 3 Feb 2020 09:29:09 -0800 From: Christoph Hellwig To: "Kirill A. Shutemov" Cc: Chris Wilson , "Kirill A. Shutemov" , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Dave Hansen , Mel Gorman , Rik van Riel , Vlastimil Babka , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Jerome Marchand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 09/16] page-flags: define PG_reserved behavior on compound pages Message-ID: <20200203172909.GA22353@infradead.org> References: <1426784902-125149-1-git-send-email-kirill.shutemov@linux.intel.com> <1426784902-125149-10-git-send-email-kirill.shutemov@linux.intel.com> <158048425224.2430.4905670949721797624@skylake-alporthouse-com> <20200203151844.mmgcwzz3igo7h6wj@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203151844.mmgcwzz3igo7h6wj@box> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 Mon, Feb 03, 2020 at 06:18:44PM +0300, Kirill A. Shutemov wrote: > > Much later than you would ever expect, but we just had a user update an > > ancient device and trip over this. > > https://gitlab.freedesktop.org/drm/intel/issues/1027 > > > > In drm_pci_alloc() we allocate a high-order page (for it to be physically > > contiguous) and mark each page as Reserved. > > > > dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, > > &dmah->busaddr, > > GFP_KERNEL | __GFP_COMP); > > > > /* XXX - Is virt_to_page() legal for consistent mem? */ > > /* Reserve */ > > for (addr = (unsigned long)dmah->vaddr, sz = size; > > sz > 0; addr += PAGE_SIZE, sz -= PAGE_SIZE) { > > SetPageReserved(virt_to_page((void *)addr)); > > } > > > > It's been doing that since This code is completely and utterly broken. Drivers were never allowed to call virt_to_page() on the memory returned from dma_alloc_coherent (or pci_alloc_consistent before that), as many implementations return virtual addresses that are not in the kernel mapping. So this code needs to go away and not papered over.