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=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 CF259C07E94 for ; Fri, 4 Jun 2021 07:41:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A263613AC for ; Fri, 4 Jun 2021 07:41:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A263613AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6B9FA6B0036; Fri, 4 Jun 2021 03:41:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66A686B006C; Fri, 4 Jun 2021 03:41:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E43F6B006E; Fri, 4 Jun 2021 03:41:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 1F3E46B0036 for ; Fri, 4 Jun 2021 03:41:57 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AE677181AC9CB for ; Fri, 4 Jun 2021 07:41:56 +0000 (UTC) X-FDA: 78215247432.32.D0F0923 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf12.hostedemail.com (Postfix) with ESMTP id EB64D2BF4 for ; Fri, 4 Jun 2021 07:41:30 +0000 (UTC) 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 9850B219E9; Fri, 4 Jun 2021 07:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622792507; 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=OCJHiaHES5BuDs/gVUVDCwQLKeuhbXghDp90XR0ftTs=; b=T+/p15KxhWJpfWTtIvkPdqUYlCbUQfjJ06irGFuIk8wQHYJDxL+G7n2QLzzoSJyUkd0x2s IsW+8qyxY/VMAGjU5JaCH+vFvcAa16VNBuSTgbaPcVBgK1O+wh4ja0O9R1+vCU9hscDEkl 8CCShoNSx4rG7Ze1lBUOETvhO+hzU6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622792507; 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=OCJHiaHES5BuDs/gVUVDCwQLKeuhbXghDp90XR0ftTs=; b=tPhbeY/dIw5Z9aXDsHMpJeJhLtwRDml85xhO1FXgmzOC/LdAJSXxyk39lhOFHfr+snCCf+ VjcQleX4W9ySE8Ag== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 16B72118DD; Fri, 4 Jun 2021 07:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1622792507; 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=OCJHiaHES5BuDs/gVUVDCwQLKeuhbXghDp90XR0ftTs=; b=T+/p15KxhWJpfWTtIvkPdqUYlCbUQfjJ06irGFuIk8wQHYJDxL+G7n2QLzzoSJyUkd0x2s IsW+8qyxY/VMAGjU5JaCH+vFvcAa16VNBuSTgbaPcVBgK1O+wh4ja0O9R1+vCU9hscDEkl 8CCShoNSx4rG7Ze1lBUOETvhO+hzU6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1622792507; 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=OCJHiaHES5BuDs/gVUVDCwQLKeuhbXghDp90XR0ftTs=; b=tPhbeY/dIw5Z9aXDsHMpJeJhLtwRDml85xhO1FXgmzOC/LdAJSXxyk39lhOFHfr+snCCf+ VjcQleX4W9ySE8Ag== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id gZpPAjvZuWDdQAAALh3uQQ (envelope-from ); Fri, 04 Jun 2021 07:41:47 +0000 Date: Fri, 4 Jun 2021 09:41:45 +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: <20210604074140.GA25063@linux> 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: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: EB64D2BF4 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="T+/p15Kx"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="tPhbeY/d"; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="T+/p15Kx"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="tPhbeY/d"; spf=pass (imf12.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=none X-Stat-Signature: rydq9qr6hbimbpfwfbbs43j1ngjnrjeb X-HE-Tag: 1622792490-918263 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 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. -- Oscar Salvador SUSE L3