Received: by 10.223.176.5 with SMTP id f5csp2197685wra; Thu, 8 Feb 2018 09:58:17 -0800 (PST) X-Google-Smtp-Source: AH8x227CXL5ZX9sxGPVdh684ShhK/Yl7+rV1NxveadDukTE2PZ3otQs/ukPOAwvKNAkVXh19j+Wa X-Received: by 10.99.182.75 with SMTP id v11mr23138pgt.158.1518112697613; Thu, 08 Feb 2018 09:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518112697; cv=none; d=google.com; s=arc-20160816; b=EcIBgs1XY0KfU/Z81ZyHu5SCYXvZ5bGrRAsJ8yOciVRW/9Y7ArlA0tpvoQeD8nqlWf 6GnMuAeqF2frwbKbOzjgPRGFEvyZNJH+gNz+gTUBUhiG4NxmuOFomzzoofV64ArwwluS l7RN96vYCr+sFgl7Ii5YX7Xo5xTse17yT53UeJve2fHb4I0QX+YDbMzB0hCyWTuXt2J4 N0OvxzgIq/8N1D5TxMNwujtVXqqx6P/YQ2P12+TIz8yB3zO3D2DlnCe4tRbdYpyHo3pG FcAETtUKOvBulPLcAgQl9qSyqdouTbR13AyQQSKgAGGGDt/ssOHTPX/jErZym+kiPkvC fhtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=O59UOyrdo5A0Hz9AJzA5cTj886/o/GCC1icYsDRbLTU=; b=EAoQi/pZMRfWBUnnceI4G+zQD9DYIFP7BrSi5omPMzR8FhzfDroyIu+E8MEhop8C0E Ba5WoQHqRun2qkRBD6tSLVrYAJdGm3YdYMoHEhNOFqaIGIhKaBRk8toQdZJJzpguJxMY KluR27wpvwN6NUBxzUfmQ/0JjRYrIXqlVeHT9oKA+CCg3OdajA8xGiSOEehK6zmV2JZC Wd5n2+ZkkInXGWQ7U9Y2IAhMfhToXlfrLh7RRUf8gw4r449gCfP0/okswNPBYlDsGYym YvT9Ezf5jlOkta0K6iFEx7qyBGcUQ3i4/VIV+b4B1d6AAI1j4R3AdeB+OTkoZv+VZSgJ J0GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12-v6si279955plt.13.2018.02.08.09.58.02; Thu, 08 Feb 2018 09:58:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752223AbeBHR4r (ORCPT + 99 others); Thu, 8 Feb 2018 12:56:47 -0500 Received: from mail-ot0-f181.google.com ([74.125.82.181]:38607 "EHLO mail-ot0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbeBHR4q (ORCPT ); Thu, 8 Feb 2018 12:56:46 -0500 Received: by mail-ot0-f181.google.com with SMTP id h14so5135625otj.5 for ; Thu, 08 Feb 2018 09:56:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=O59UOyrdo5A0Hz9AJzA5cTj886/o/GCC1icYsDRbLTU=; b=pUQ+IWivJNYoHK6w2Zd1I7zw2gCkC29drWUP/TTdHbPglCsLUM2yUxIqFUPmXrtfVS DtijnBO82elZAwXzdwrWDyi0iU+QacTznQKxfqv6J0CgX07rR94Rz2MrJRvIfCJpdIXz jL7XubnJbmYF+bvLW/2MmF0ve8L9Fea8MDXl6D/hg6dIXfKt+j7AGABeYT3SfkAkGWV3 z5i286se+wXLTp3zgCG4vrw1UdpdNtaGdzETEuUHBuhiyKazq6xF26p7by98VCIkIasM 0aTufgWEQop+LaUAC6u2L+g/oBrNuBqkti7s/AHpMcUO5sbyDhbSo83qZT8vhts/wG79 y9lA== X-Gm-Message-State: APf1xPBJjIJfZHvTecPcAvPQNTQWzrCSzu1k6w75WzY/L2D3yXW9mDHf CUELl0QRGhCIu8lHu8VTOitltYbxjmY= X-Received: by 10.157.42.16 with SMTP id t16mr7310ota.75.1518112605532; Thu, 08 Feb 2018 09:56:45 -0800 (PST) Received: from ?IPv6:2601:602:9802:a8dc::f21a? ([2601:602:9802:a8dc::f21a]) by smtp.gmail.com with ESMTPSA id a44sm255560ote.72.2018.02.08.09.56.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 09:56:44 -0800 (PST) Subject: Re: Regression after commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly") To: Matthew Wilcox , Kai Heng Feng Cc: Michal Hocko , linux-mm@kvack.org, Linux Kernel Mailing List References: <627DA40A-D0F6-41C1-BB5A-55830FBC9800@canonical.com> <20180208130649.GA15846@bombadil.infradead.org> From: Laura Abbott Message-ID: Date: Thu, 8 Feb 2018 09:56:42 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180208130649.GA15846@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/08/2018 05:06 AM, Matthew Wilcox wrote: > On Thu, Feb 08, 2018 at 02:29:57PM +0800, Kai Heng Feng wrote: >> A user with i386 instead of AMD64 machine reports [1] that commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitlyā€¯) causes a regression. >> BUG_ON(PageHighMem(pg)) in drivers/media/common/saa7146/saa7146_core.c always gets triggered after that commit. > > Well, the BUG_ON is wrong. You can absolutely have pages which are both > HighMem and under the 4GB boundary. Only the first 896MB (iirc) are LowMem, > and the next 3GB of pages are available to vmalloc_32(). > >> Also there are other BUG_ON(PageHighMem()) in drivers/media, I think they will get hit by same regression in 32bit machine too. > > I fixed one of them. I think the other three are also bogus, but it's > hard to say; the comments say "DMA to HighMem might not work", and they > probably mean "above the 4GB boundary", but I really don't know. > > (since two drivers now have this code, maybe it should be part of the core > MM API? Or maybe there's already something better they should be using?) > The comment at the top said the function was copied from videobuf-dma-sg.c so might be worth making it common. > diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c > index 9f7c5b0a6b45..329fd43228ff 100644 > --- a/drivers/media/common/saa7146/saa7146_core.c > +++ b/drivers/media/common/saa7146/saa7146_core.c > @@ -160,7 +160,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) > pg = vmalloc_to_page(virt); > if (NULL == pg) > goto err; > - BUG_ON(PageHighMem(pg)); > + BUG_ON(page_to_pfn(pg) >= (1 << (32 - PAGE_SHIFT))); > sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); > } > return sglist; > diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c > index f412429cf5ba..b5ec74b9c867 100644 > --- a/drivers/media/v4l2-core/videobuf-dma-sg.c > +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c > @@ -77,7 +77,7 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt, > pg = vmalloc_to_page(virt); > if (NULL == pg) > goto err; > - BUG_ON(PageHighMem(pg)); > + BUG_ON(page_to_pfn(pg) >= (1 << (32 - PAGE_SHIFT))); > sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); > } > return sglist; > the vzalloc in this function needs to be switched to vmalloc32 if it actually wants to guarantee 32-bit memory. Thanks, Laura