Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3061536pxj; Mon, 7 Jun 2021 00:53:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnmQ+tWg+Ox3jWHgbijOhIzhIAG8ipXvNyFSMVyz/rouYBybcTwNAfOAsKlM4C/67BJWOS X-Received: by 2002:a17:906:49ce:: with SMTP id w14mr16874730ejv.273.1623052431807; Mon, 07 Jun 2021 00:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623052431; cv=none; d=google.com; s=arc-20160816; b=Orrn4UMdsFg+RcoFyLFz8JzJ4WHnifXOdimrZXd134vGPyAHWIRomuohFHI5VFLzXe riaSisupnNyRcrJ2FzdwVLRyz9vyl5v2KchHSIi2vWNlXpIYOGbvtwfTdX6Dxxfwuma4 mnOFYmquk+rmscdxqhlp6Oi3m21mv/4lJGg4OU575qaVpiJQ05cZIu/DKYz/LfG8gyoD 7njd9NssLeHs34JVtIxvxMRU4sxHe6H5Ioml+Va2BhXuZU8tE9+Gqlzxp3vHnKQhOQ3k 1VaMwMv4TXEcrlaJGlIpckRntwiCOlUt63ieSkITWr5qYuYaeRbfzgil7v5F99u+k6h/ LClQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=Bx3CBAxFcKycwSZrW3uOEUlKsBQs/nevI6APuZ3SgW0=; b=cYLxHcB+inZen3WQDL4sCAEm/yglKYpnfJWGsNOJQHTrQBQHc1OiPlER0MMLwfYNJA Df+WUNz9pWr29qA16sWqlSbZn20W2Ne3S1HlVLf4gnhj+3h/giCUZrKR7f98bD2XZKur kVImqLucRmvaQy7C6QClPtJU4yy9buyQ1R7rjfmUsdVRx0EvEr3zrzAepR2ZEsxbLYI2 MRFoR2NPsT6VStDEzo2fxZ9EclnPSX4R7Qe/WBQIs4sgOhsEsBMElzqQ2ULcAT1uNkRX T7utMmaRwbT9UE9SKHJ2f9R4fyQmcbD7GhjANV5cd4bXDPng5KuqPLjVLx0hzpmOdDVm pmqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="KfpD/cLC"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="KfpD/cLC"; dkim=neutral (no key) header.i=@suse.de header.b="BIO/RR9W"; 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 f23si6790153edv.591.2021.06.07.00.53.29; Mon, 07 Jun 2021 00:53:51 -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="KfpD/cLC"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="KfpD/cLC"; dkim=neutral (no key) header.i=@suse.de header.b="BIO/RR9W"; 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 S229966AbhFGHyL (ORCPT + 99 others); Mon, 7 Jun 2021 03:54:11 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:43962 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbhFGHyK (ORCPT ); Mon, 7 Jun 2021 03:54:10 -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-out1.suse.de (Postfix) with ESMTPS id A641C21A86; Mon, 7 Jun 2021 07:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623052338; 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=Bx3CBAxFcKycwSZrW3uOEUlKsBQs/nevI6APuZ3SgW0=; b=KfpD/cLCVlUPO85fGKPWgXuPd2PaFZPaWuhAT3BaHOHIVvj/f3gKaZk1cb/3j4sAvWBbee L1LnGQ/uFiBfb+XuD58nMae2AOQ6fYFuJv1BjWL2Z7QDJQToFTtCsEcNcvnFYMOlgqtFrb 0piGocUWYlD4Chz8dWcp4CqdYuaMtGk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623052338; 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=Bx3CBAxFcKycwSZrW3uOEUlKsBQs/nevI6APuZ3SgW0=; b=BIO/RR9WAdgv2OluegLCFUY02E1tppLr5R0PQNdE6p1PZNL7VN0odR6cG727Wy5plc6AXi iWH00zNPYRG+riBw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 1B58D118DD; Mon, 7 Jun 2021 07:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623052338; 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=Bx3CBAxFcKycwSZrW3uOEUlKsBQs/nevI6APuZ3SgW0=; b=KfpD/cLCVlUPO85fGKPWgXuPd2PaFZPaWuhAT3BaHOHIVvj/f3gKaZk1cb/3j4sAvWBbee L1LnGQ/uFiBfb+XuD58nMae2AOQ6fYFuJv1BjWL2Z7QDJQToFTtCsEcNcvnFYMOlgqtFrb 0piGocUWYlD4Chz8dWcp4CqdYuaMtGk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623052338; 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=Bx3CBAxFcKycwSZrW3uOEUlKsBQs/nevI6APuZ3SgW0=; b=BIO/RR9WAdgv2OluegLCFUY02E1tppLr5R0PQNdE6p1PZNL7VN0odR6cG727Wy5plc6AXi iWH00zNPYRG+riBw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id LJyBAzLQvWDVXQAALh3uQQ (envelope-from ); Mon, 07 Jun 2021 07:52:18 +0000 Date: Mon, 7 Jun 2021 09:52:16 +0200 From: Oscar Salvador To: Michal Hocko Cc: David Hildenbrand , Andrew Morton , Dave Hansen , 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: <20210607075147.GA10554@linux> References: <20210602091457.17772-1-osalvador@suse.de> <20210602091457.17772-2-osalvador@suse.de> <39473305-6e91-262d-bcc2-76b745a5b14a@redhat.com> <20210604074140.GA25063@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210604074140.GA25063@linux> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 04, 2021 at 09:41:45AM +0200, Oscar Salvador wrote: > On Thu, Jun 03, 2021 at 02:45:13PM +0200, Michal Hocko wrote: > > I believe we need to define the purpose of the locking first. The > > If you ask me, this locking would be meant to make sure zone's zone_start_pfn > or spanned_pages do not change under us, in case we __need__ the value to be > stable. > > > existing locking doesn't serve much purpose, does it? The state might > > Well, half-way. Currently, the locking is taken in write mode whenever > the zone is expanded or shrinked, and in read mode when called from > bad_range()->page_outside_zone_boundaries() (only on VM_DEBUG). > > But as you pointed out, such state might change right after the locking is > released and all the work would be for nothing. > So indeed, the __whole__ operation should be envolved by the lock in the caller > The way that stands right now is not optimal. > > > change right after the lock is released and the caller cannot really > > rely on the result. So aside of the current implementation, I would > > argue that any locking has to be be done on the caller layer. > > > > But the primary question is whether anybody actually cares about > > potential races in the first place. > > I have been checking move_freepages_block() and alloc_contig_pages(), which > are two of the functions that call zone_spans_pfn(). > > move_freepages_block() uses it in a way to align the given pfn to pageblock > top and bottom, and then check that aligned pfns are still within the same zone. > From a memory-hotplug perspective that's ok as we know that we are offlining > PAGES_PER_SECTION (which implies whole pageblocks). > > alloc_contig_pages() (used by the hugetlb gigantic allocator) runs through a > node's zonelist and checks whether zone->zone_start_pfn + nr_pages stays within > the same zone. > IMHO, the race with zone_spans_last_pfn() vs mem-hotplug would not be that bad, > as it will be caught afters by e.g: __alloc_contig_pages when pages cannot be > isolated because they are offline etc. > > So, I would say we do not really need the lock, but I might be missing something. > But if we chose to care about this, then the locking should be done right, not > half-way as it is right now. Any thoughts on this? :-) -- Oscar Salvador SUSE L3