Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp757264pxu; Wed, 6 Jan 2021 03:41:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoChp90aOe7VZkw7krA4xKgUyFYAu9Iey88+CKzJ6qKKJxjfY1lLSOh4mjF59h4+JEsVCr X-Received: by 2002:a05:6402:40e:: with SMTP id q14mr3685097edv.85.1609933273765; Wed, 06 Jan 2021 03:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609933273; cv=none; d=google.com; s=arc-20160816; b=LhbmYihpUizHy817OZDOaNr9g9e9mU227GYQEYHgk7D6IzaXUK5u+RkiLtEM/Tx9h1 pUvo3+JKZwc1g3wvA6fDswq1FCQo/KyrpC98NErrQB3R10psbTUn5r6+RkZWIjHxrB+2 ZIiWwNODT59S7U6e5Lgdl7oToND0XIn9x8qHzVRc6YwWaTLmUyIcaK7c5aN3Zzg1sqQa qtE9UzrMjnWO0A8Q0CagQ2X04aX3l+tlW4kKf1BqRyGXXy2/nNYO2MXwosTbQiODb7Qk 0GGsp6uUsmxvtA+nt/+2zS0kK9XEWQNU+nPRjEz+ktToom2tfUQWHaxwpgwbBKIEmVjZ bjVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=v7Nwai2b36E4PhjVqMjGa8YBAPAahmnOcM2dSGchQYc=; b=g8hG1m8zD69P9eFal/VsBRn4W8W1CX5Yua5tS4XqvlyNoURTrQnp3BAzxgyYofPRY0 vksmG0EIinx8vQH6iswhuxYTeVpmJLB/wQmUAYpzkPXDPOReUtQElfuQ4qJiAx+sfemt Rm1C8/IHEhn07SP4dVLlveMs/puRv7iOmF1wpdq0vOXGPSxGPKx8p3JopOSuTSmk/Yvi 3xKyrMT/ZFtXgftsMXNpDp/r7HSU6w1xgKPGFcOwGSYzd2LFGnkkviSXUh+mM9UcCZ9C XcHA3qvUvAQyb+lSrAdwpj3ddw+RnxYv+Jeak0fueygsEdFMfp5BE025N2Cr0yY/3d3k jpew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=f9M8+8NJ; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si792717ejr.334.2021.01.06.03.40.49; Wed, 06 Jan 2021 03:41:13 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=f9M8+8NJ; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbhAFLiv (ORCPT + 99 others); Wed, 6 Jan 2021 06:38:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:35802 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725896AbhAFLiv (ORCPT ); Wed, 6 Jan 2021 06:38:51 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1609933084; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=v7Nwai2b36E4PhjVqMjGa8YBAPAahmnOcM2dSGchQYc=; b=f9M8+8NJbvL9i4aGj8NPFHBx549GQTh/WlzgJUZxSHClZvzf8cQDu4Ofc4+gaM2s7EBQMV DpyApGDOAtoNf0WC7+z1ljZt3O5w8lHBt2PDNV1slYLbzFuFZ4JC7/AGeAq1u5847Mm2iy qaK2+UhBgMn31EM7qxH9bGz1SZ5G0QQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BCDB2AA35; Wed, 6 Jan 2021 11:38:04 +0000 (UTC) Date: Wed, 6 Jan 2021 12:38:04 +0100 From: Michal Hocko To: David Hildenbrand Cc: Dan Williams , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Teach pfn_to_online_page() about ZONE_DEVICE section collisions Message-ID: <20210106113804.GL13207@dhcp22.suse.cz> References: <160990599013.2430134.11556277600719835946.stgit@dwillia2-desk3.amr.corp.intel.com> <785b9095-eca4-8100-33ea-6ae84e02a92e@redhat.com> <20210106104255.GK13207@dhcp22.suse.cz> <7d7c5dc4-7784-5dcc-fc00-4fe99f0a4a90@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d7c5dc4-7784-5dcc-fc00-4fe99f0a4a90@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 06-01-21 12:22:57, David Hildenbrand wrote: > On 06.01.21 11:42, Michal Hocko wrote: > > On Wed 06-01-21 10:56:19, David Hildenbrand wrote: > > [...] > >> Note that this is not sufficient in the general case. I already > >> mentioned that we effectively override an already initialized memmap. > >> > >> --- > >> > >> [ SECTION ] > >> Before: > >> [ ZONE_NORMAL ][ Hole ] > >> > >> The hole has some node/zone (currently 0/0, discussions ongoing on how > >> to optimize that to e.g., ZONE_NORMAL in this example) and is > >> PG_reserved - looks like an ordinary memory hole. > >> > >> After memremap: > >> [ ZONE_NORMAL ][ ZONE_DEVICE ] > >> > >> The already initialized memmap was converted to ZONE_DEVICE. Your > >> slowpath will work. > >> > >> After memunmap (no poisioning): > >> [ ZONE_NORMAL ][ ZONE_DEVICE ] > >> > >> The slow path is no longer working. pfn_to_online_page() might return > >> something that is ZONE_DEVICE. > >> > >> After memunmap (poisioning): > >> [ ZONE_NORMAL ][ POISONED ] > >> > >> The slow path is no longer working. pfn_to_online_page() might return > >> something that will BUG_ON via page_to_nid() etc. > >> > >> --- > >> > >> Reason is that pfn_to_online_page() does no care about sub-sections. And > >> for now, it didn't had to. If there was an online section, it either was > >> > >> a) Completely present. The whole memmap is initialized to sane values. > >> b) Partially present. The whole memmap is initialized to sane values. > >> > >> memremap/memunmap messes with case b) > > > > I do not see we ever clear the newly added flag and my understanding is > > that the subsection removed would lead to get_dev_pagemap returning a > > NULL. Which would obviously need to be checked for pfn_to_online_page. > > Or do I miss anything and the above is not the case and we could still > > get false positives? > > See my example above ("After memunmap"). > > We're still in the slow pathg. pfn_to_online_page() will return a struct > page as get_dev_pagemap() is now NULL. Yeah, my bad. I have clearly misread the patch. We would need som other means than relying on get_dev_pagemap if it doesn't survive the memunmap. :/ -- Michal Hocko SUSE Labs