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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D45DC27C5F for ; Mon, 10 Jun 2024 04:24:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42DB56B008C; Mon, 10 Jun 2024 00:24:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B65C6B0092; Mon, 10 Jun 2024 00:24:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 209796B0093; Mon, 10 Jun 2024 00:24:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F421B6B008C for ; Mon, 10 Jun 2024 00:24:09 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F475A21E9 for ; Mon, 10 Jun 2024 04:24:09 +0000 (UTC) X-FDA: 82213686618.16.0D26FB6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf03.hostedemail.com (Postfix) with ESMTP id A58A920004 for ; Mon, 10 Jun 2024 04:24:06 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=o8tqZ6pt; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=fQWD18aj; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=o8tqZ6pt; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=fQWD18aj; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717993447; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=STes9dvsOiZHvfV9vRJe27/8pEpJsEu/gt/yrG0Qqek=; b=jcV7TmJmVViyXwW4ndd50mRSd7KJTnbq/UbhZ/BmAAhFNeUcaqCkdx6/nCl59djrOBeiIa MAiGWYgjxbVCIdJNUjo1xllyk2+Tf4NlbU8NqgftdRIKbc9RwHjSFESwUFGeKKSZdBCWNT sunsheoq/Kbu9A0L29t8LuDN03rLpfk= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=o8tqZ6pt; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=fQWD18aj; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=o8tqZ6pt; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=fQWD18aj; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717993447; a=rsa-sha256; cv=none; b=putDUfDIRmosjbRvou0ak/wn5vdAK4AU0uRRW+lojsKGSZC6y/KckoCiL1phdPvelq2kyw fBp3aa3Q6eIVUZQ7geI+M0bKFLJXMntCRuNFOAyFfQz4tgVofbyCCawp3qbQTakvT1/m4G V6SbyJ6SrnNCHUPlOIyzGuqNMONKd6c= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 88FA1219DC; Mon, 10 Jun 2024 04:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1717993444; 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=STes9dvsOiZHvfV9vRJe27/8pEpJsEu/gt/yrG0Qqek=; b=o8tqZ6ptgNBJgDzFFFlXJ4BuRYktYynoSB9CmRx3kAKTTWOQVXmg2tdchdht62Uh4KiAoT Xjh9Ea6U1Dp2/lG8fVpOXMgyDKEwE6igfCaySZdZRfxaGYQYm6usncgdP35NZiqT5JNfOa RSbw87vp6yMYDpWUD7crMXYt1zHzDeA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1717993444; 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=STes9dvsOiZHvfV9vRJe27/8pEpJsEu/gt/yrG0Qqek=; b=fQWD18ajS3CyXfmlEKPJp0P/CvQjtxtJJeWW8NIZLqMy2mo4mWHdImltCgMGR17riJ+K30 kQDBwHnbIU0PuZBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1717993444; 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=STes9dvsOiZHvfV9vRJe27/8pEpJsEu/gt/yrG0Qqek=; b=o8tqZ6ptgNBJgDzFFFlXJ4BuRYktYynoSB9CmRx3kAKTTWOQVXmg2tdchdht62Uh4KiAoT Xjh9Ea6U1Dp2/lG8fVpOXMgyDKEwE6igfCaySZdZRfxaGYQYm6usncgdP35NZiqT5JNfOa RSbw87vp6yMYDpWUD7crMXYt1zHzDeA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1717993444; 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=STes9dvsOiZHvfV9vRJe27/8pEpJsEu/gt/yrG0Qqek=; b=fQWD18ajS3CyXfmlEKPJp0P/CvQjtxtJJeWW8NIZLqMy2mo4mWHdImltCgMGR17riJ+K30 kQDBwHnbIU0PuZBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5D2BD13A7F; Mon, 10 Jun 2024 04:24:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id jBLQE+N/ZmYYFwAAD6G6ig (envelope-from ); Mon, 10 Jun 2024 04:24:03 +0000 Date: Mon, 10 Jun 2024 06:23:57 +0200 From: Oscar Salvador To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, xen-devel@lists.xenproject.org, kasan-dev@googlegroups.com, Andrew Morton , Mike Rapoport , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Alexander Potapenko , Marco Elver , Dmitry Vyukov Subject: Re: [PATCH v1 2/3] mm/memory_hotplug: initialize memmap of !ZONE_DEVICE with PageOffline() instead of PageReserved() Message-ID: References: <20240607090939.89524-1-david@redhat.com> <20240607090939.89524-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240607090939.89524-3-david@redhat.com> X-Rspamd-Queue-Id: A58A920004 X-Stat-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O SpbNnCnbtbU7ekLW9qsJptg9qhZdjqTxKzcLgggRxqluOg/+1RmuUdEaiCRUGuPVhUr5sk373TP/qb1DlhSOpNKZwq7nf0uK13UDiGrn+sOwAr/A5sqlPrbNfPmmuFtDmqTDDVDdACJzwLjKxUCTfphUFHekNinw6YB9LP0vGUljJcry1sNDnQi17wD4x0Zn31Y/qsVInNpFGB6lsJ9dvaIE1DvqGjoj967pDpS9h1ZVnfivzo3B4+boDK3p3fgxASNwDm1D0yeFph4E4rKJsZ03NpQ5jyEb1rTTiXlMeo39kCBdzbWQLSAEg3LFtVsA4MEM7 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: List-Subscribe: List-Unsubscribe: On Fri, Jun 07, 2024 at 11:09:37AM +0200, David Hildenbrand wrote: > We currently initialize the memmap such that PG_reserved is set and the > refcount of the page is 1. In virtio-mem code, we have to manually clear > that PG_reserved flag to make memory offlining with partially hotplugged > memory blocks possible: has_unmovable_pages() would otherwise bail out on > such pages. > > We want to avoid PG_reserved where possible and move to typed pages > instead. Further, we want to further enlighten memory offlining code about > PG_offline: offline pages in an online memory section. One example is > handling managed page count adjustments in a cleaner way during memory > offlining. > > So let's initialize the pages with PG_offline instead of PG_reserved. > generic_online_page()->__free_pages_core() will now clear that flag before > handing that memory to the buddy. > > Note that the page refcount is still 1 and would forbid offlining of such > memory except when special care is take during GOING_OFFLINE as > currently only implemented by virtio-mem. > > With this change, we can now get non-PageReserved() pages in the XEN > balloon list. From what I can tell, that can already happen via > decrease_reservation(), so that should be fine. > > HV-balloon should not really observe a change: partial online memory > blocks still cannot get surprise-offlined, because the refcount of these > PageOffline() pages is 1. > > Update virtio-mem, HV-balloon and XEN-balloon code to be aware that > hotplugged pages are now PageOffline() instead of PageReserved() before > they are handed over to the buddy. > > We'll leave the ZONE_DEVICE case alone for now. > > Signed-off-by: David Hildenbrand > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 27e3be75edcf7..0254059efcbe1 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -734,7 +734,7 @@ static inline void section_taint_zone_device(unsigned long pfn) > /* > * Associate the pfn range with the given zone, initializing the memmaps > * and resizing the pgdat/zone data to span the added pages. After this > - * call, all affected pages are PG_reserved. > + * call, all affected pages are PageOffline(). > * > * All aligned pageblocks are initialized to the specified migratetype > * (usually MIGRATE_MOVABLE). Besides setting the migratetype, no related > @@ -1100,8 +1100,12 @@ int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > > move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE); > > - for (i = 0; i < nr_pages; i++) > - SetPageVmemmapSelfHosted(pfn_to_page(pfn + i)); > + for (i = 0; i < nr_pages; i++) { > + struct page *page = pfn_to_page(pfn + i); > + > + __ClearPageOffline(page); > + SetPageVmemmapSelfHosted(page); So, refresh my memory here please. AFAIR, those VmemmapSelfHosted pages were marked Reserved before, but now, memmap_init_range() will not mark them reserved anymore. I do not think that is ok? I am worried about walkers getting this wrong. We usually skip PageReserved pages in walkers because are pages we cannot deal with for those purposes, but with this change, we will leak PageVmemmapSelfHosted, and I am not sure whether are ready for that. Moreover, boot memmap pages are marked as PageReserved, which would be now inconsistent with those added during hotplug operations. All in all, I feel uneasy about this change. -- Oscar Salvador SUSE Labs