Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp98138pxj; Thu, 3 Jun 2021 01:41:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3uMIA22O30CRe+3Ilmwv/P7xBsBlF+2Gj91TeJ0krXz/NQwE09DFnxmZ9NK1UmyJfTuMH X-Received: by 2002:a17:906:8345:: with SMTP id b5mr4838225ejy.14.1622709717973; Thu, 03 Jun 2021 01:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622709717; cv=none; d=google.com; s=arc-20160816; b=TowjTBMIQQ6de3pp+Oh53sZqWEJpr+XAGOtCZntN8eUNV9f4v7STSWcbd19L06+243 LJxsmNpwfhxXcBMGT+QjjR4QJS5RuD0zETw1lEaCF9WGjrjtDcivUnlZzMIlYQ8mt2yM Q9bV9x9/x8IXCvg6cazNAsRPV1oa/zikdk+bIYd9cy0rDdGMVI+Dm+MyWHFA1RccpKbV sE0Epmnv5S0e3nbcmVZZwwl8TmNa107ajuk0nYOVV0NlCLmRedoai04/6Nx8gMkN5uOw 3RACqqb68amb3iVmI9OTtSVh57x4Y5wkZUoUn+oXfvFvOllTrn0YW02varMXoITuTbZc ZUJA== 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 :dkim-signature:dkim-signature:dkim-signature; bh=zt2fjzTinBjC64Cl7tJnOBqSXBywln5vqKhFtXBD5pc=; b=BXOdSWYsFCNiv4ANCTZoU+ELonjHAcTU6deEz4ceIJzyOQ7vrbuSjjtcllqT/58+ow NpkI9U1nVctsjnrEB+cwy/QCREv4zH4zDmF3Xapbbbi5uQjzdjy0SXrntHHGwAmYQtAR dzQmVebHtYpzFS4DJEyZCSowIhdYjcP1i0qp7Xp3TzithY0es6CCgdfwim1zk6DQ2eOI K5xWR6tkUCE+Q2ENQFyA1RyBoQehAvbAsSUEWG+bRTss/WqJia+NtxsRgLZ11DgDSgHB 51Jbc4QpViyCmcHFx+mpwBF6oKwFX4omyl4IUsXEa0aeY/XnDWqsVZ/XZRa71sh2k2N4 R6IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="Sn1/9hQH"; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="Sn1/9hQH"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vWMRHpuf; 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 m18si1784899edd.534.2021.06.03.01.41.35; Thu, 03 Jun 2021 01:41:57 -0700 (PDT) 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.de header.s=susede2_rsa header.b="Sn1/9hQH"; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="Sn1/9hQH"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vWMRHpuf; 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 S229665AbhFCIkM (ORCPT + 99 others); Thu, 3 Jun 2021 04:40:12 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:38908 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFCIkL (ORCPT ); Thu, 3 Jun 2021 04:40:11 -0400 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DC0091FD4D; Thu, 3 Jun 2021 08:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622709506; 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=zt2fjzTinBjC64Cl7tJnOBqSXBywln5vqKhFtXBD5pc=; b=Sn1/9hQHmHfPpCwhNXwfIj5VyyYze0wc5ZHI8qH9rhEe0vlhSqPaLcNNhfcSDtu6myAow+ Qc2o6x1ShjuGukUAzGoPrSUerMeqEy0tN5znm3UCPwNnkGgWZS3vQTedwfRf4jBEpzyxW8 CE2TkYX9SxoJtnUcNHuTYhOB7uLaxgo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622709506; 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=zt2fjzTinBjC64Cl7tJnOBqSXBywln5vqKhFtXBD5pc=; b=vWMRHpufxPiPK2KZIdZBeBikX5sTr8Wu9dGaLDno5+njY429b3f9TzrkuxUjcapw1/D1TS rbgWfnnu5gxcf3BQ== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 3587C118DD; Thu, 3 Jun 2021 08:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622709506; 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=zt2fjzTinBjC64Cl7tJnOBqSXBywln5vqKhFtXBD5pc=; b=Sn1/9hQHmHfPpCwhNXwfIj5VyyYze0wc5ZHI8qH9rhEe0vlhSqPaLcNNhfcSDtu6myAow+ Qc2o6x1ShjuGukUAzGoPrSUerMeqEy0tN5znm3UCPwNnkGgWZS3vQTedwfRf4jBEpzyxW8 CE2TkYX9SxoJtnUcNHuTYhOB7uLaxgo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622709506; 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=zt2fjzTinBjC64Cl7tJnOBqSXBywln5vqKhFtXBD5pc=; b=vWMRHpufxPiPK2KZIdZBeBikX5sTr8Wu9dGaLDno5+njY429b3f9TzrkuxUjcapw1/D1TS rbgWfnnu5gxcf3BQ== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id BgSbCQKVuGAQMwAALh3uQQ (envelope-from ); Thu, 03 Jun 2021 08:38:26 +0000 Date: Thu, 3 Jun 2021 10:38:24 +0200 From: Oscar Salvador To: David Hildenbrand Cc: Andrew Morton , Dave Hansen , Michal Hocko , Anshuman Khandual , Vlastimil Babka , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] mm,page_alloc: Use {get,put}_online_mems() to get stable zone's values Message-ID: References: <20210602091457.17772-1-osalvador@suse.de> <20210602091457.17772-2-osalvador@suse.de> <39473305-6e91-262d-bcc2-76b745a5b14a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 02, 2021 at 09:45:58PM +0200, Oscar Salvador wrote: > It was too nice and easy to be true I guess. > Yeah, I missed the point that blocking might be an issue here, and hotplug > operations can take really long, so not an option. > I must have switched my brain off back there, because now it is just too > obvious. > > Then I guwmess that seqlock must stay and the only thing than can go is the > pgdat resize lock from the hotplug code. So, I have been looking into this again. Of course, the approach taken here is outrageously wrong, but there are some other things that are a bit confusing. As pointed out, bad_range() (the function that ends up calling page_outside_zone_boundaries) is called from different functions via VM_BUG_ON_*. page_outside_zone_boundaries() takes care of taking the seqlock to avoid reading stale values that might happen if we race with memhotplug operations. page_outside_zone_boundaries() calls zone_spans_pfn() to check that. Now on the funny thing. We do have several places happily calling zone_spans_pfn() without holding zone's seqlock, e.g: set_pageblock_migratetype set_pfnblock_flags_mask zone_spans_pfn move_freepages_block zone_spans_pfn alloc_contig_pages zone_spans_last_pfn zone_spans_pfn Those places hold zone->lock, while move_pfn_range_to_zone() and remove_pfn_range_from_zone() hold zone->seqlock, so AFAICS, those places could read a stale value and proceed thinking the range is within the zone while it is not. So I guess my question is, should we force those places to take the seqlock reader as we do in page_outside_zone_boundaries(), (or maybe just move the seqlock handling to zone_spans_pfn())? Because I does not make much sense to take it in a VM_DEBUG context and not in "real life". Thoughts? -- Oscar Salvador SUSE L3