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 A144AC27C4F for ; Sun, 30 Jun 2024 07:32:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19F776B0085; Sun, 30 Jun 2024 03:32:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1510A6B0088; Sun, 30 Jun 2024 03:32:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 016E76B0089; Sun, 30 Jun 2024 03:32:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D7E546B0085 for ; Sun, 30 Jun 2024 03:32:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1EC8B16148C for ; Sun, 30 Jun 2024 07:32:12 +0000 (UTC) X-FDA: 82286736504.25.2ECF29E Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf30.hostedemail.com (Postfix) with ESMTP id 24D2C80002 for ; Sun, 30 Jun 2024 07:32:09 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YHVqExEp; spf=pass (imf30.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719732719; a=rsa-sha256; cv=none; b=mUYaMzvRsvux2OBwkp39EobyabKZUbIJN9qCfJkG5+ZlgAVE8S+6+rvNBc0grpD18Zj5uj lMV5up8CdquK4XsUmYxdkWw+MrgQjEsObZAm6FBmHbGgPfept0tJ21Xf0TNoIIXQfkzxOv PSRgshs3I8lCuH4IXmZTLUrwuGkiDgg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YHVqExEp; spf=pass (imf30.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719732719; h=from:from:sender:reply-to: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=egMd7+whOA4Yc7SFFzhb7TonoSK1ot132y6BZ+OmDgo=; b=6xwGkCNNvn2RTo+cA0fPLWFHSi0Sal4n0VSlPSAwNliw+WwA28YxyCE9bAFoXRpMiJdkqh 3oCKwy4gqHf4f0WC6BSu72OsVunfvpU1+x5OqBDK/kLObbEhXLSM2XPEkqp+BFNRzTi15Y wOATMsHanyLm8GMNInjEyRnRqUJIHQ4= Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-57d1782679fso2463348a12.0 for ; Sun, 30 Jun 2024 00:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719732729; x=1720337529; darn=kvack.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=egMd7+whOA4Yc7SFFzhb7TonoSK1ot132y6BZ+OmDgo=; b=YHVqExEppYjRD38+OrJbcYnf8xqsXouS/YCT5dORX1Ough9cnj82KjSWKB5eQ1otIw 1/FJMxfBC9QNRdDxgdFcVIc1NPWqEqR5OMr8XES1sBEaGEuEM8yh2YeNPyeT3fyC+wW4 le2YxCdwlOvgR5vIm3MzjRwp8HaiKbhYbaILSn4AnvUKP4tn+dBhALniOvAnbufzaZZQ D+0TamlXo9/roXjtA1NKu1dXHb9iJzgSTnHUVdxz+TLt+XXQzZm+gnIKUJaCnChHLpZn k9k5ZEO7DgbJ53uOFdy03bLJaE2Z6+ThBszMHx/1t3aowaiFlCxx3L2SJEGctFO+IYvs cIrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719732729; x=1720337529; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=egMd7+whOA4Yc7SFFzhb7TonoSK1ot132y6BZ+OmDgo=; b=PZKDo90vc8Hdkv7yQiF7kOlFEjIfz4/adhzuSE3FDjAGzfFr46Sjjnw3/fPZjM25LS 7QC0xijqBf2LKHAbCBw2TNQrhYwHlm/gO0hOP8XiZhpVj3YDIKjZa2LezUYevoBEjoFr 2MutzaNdSOqupy5IvkvZnPmrmh26V/0/QMRJQ1BCcylrjOaPwQ9sawOsbs1ZHxvryxdd L4sHGtqNa7RVsxVVxrQkaUgJa+JwmWa0b71kF4icttIehARtUa55AgoFFFgLheCP3V1E AMzF/PEluB4zu/XQKb2wQaPBnLvo2eE+mBsP1lPOteCLlkAtAlWaVS2SZzsjb08a0WcV q+WQ== X-Forwarded-Encrypted: i=1; AJvYcCVl0/8YrGLgmY9cn3loPVDegNEva1B/cCtMpfE62v/bzMXTEE7FBWF4kM2ek3KwgmjH+sdryhhMAD8LLsCOz7Kecig= X-Gm-Message-State: AOJu0Yyok6f0+5iGHmySg8H1id8FMeSu5bOnmv8NDtb8X/jC6zBPm8Tj gQ3h/sH1AMrBUfI1ePw7e8aFKESsiK029K2Utn48AOdplvOwfYUk X-Google-Smtp-Source: AGHT+IGdefP4NY2CEIwtl9icBCyCc33EYBagmybgYC5AC7q2v2GoZYzoTgKkEYSMU9eUBVPOk3kPDA== X-Received: by 2002:a05:6402:1cc1:b0:57d:10db:488e with SMTP id 4fb4d7f45d1cf-587a053e3f4mr1716221a12.30.1719732728541; Sun, 30 Jun 2024 00:32:08 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58614d50593sm3047059a12.60.2024.06.30.00.32.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 00:32:07 -0700 (PDT) Date: Sun, 30 Jun 2024 07:32:07 +0000 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , akpm@linux-foundation.org, rppt@kernel.org, linux-mm@kvack.org, Nathan Zimmer Subject: Re: [PATCH 2/4] mm: not __SetPageReserved on initializing hot-plugged memory Message-ID: <20240630073207.cznioxwlur4uubnd@master> Reply-To: Wei Yang References: <20240629013322.12364-1-richard.weiyang@gmail.com> <20240629013322.12364-2-richard.weiyang@gmail.com> <9e05d9da-36bd-4094-93d7-1c19eb77df1e@redhat.com> <20240629083222.35mebt7kqxiepsgg@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-Stat-Signature: cgjh79o88dgdk9prencdsqxwzposdz7d X-Rspamd-Queue-Id: 24D2C80002 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719732729-299 X-HE-Meta: U2FsdGVkX195kOGaLa1idSItZv8mUNSsHXf2rSlFrva6IO4MG/MbZIQ0uzVZ3Jc0J7Wdzx5yhES+I9wcDWjwGFHomnm1KqCgIfnvcoalCQAtJ+3EJ3U2mqWFLyICcRUa651pyU3jrUQo4qON746IeMOzuTuL0cgq8qKd76WODMKSB5Q7r0fEvERRyfbM9p5hS3AvNENpB6VJKyG3rH2UpR2vPHy+65RAWReSzkZP+A61WOkp9fd8l114K1btZhT1yeOB9K7qRO1UxAgfylY2Dy2LoELRKy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TgdqzCAJqxDiPCuvRfNS2SWnKrf5omfjx3uCsedwxmyDMDsdNFivzFd9ZMM3Vi2DwOrrug1kAvw6MmN9qi2pIovGyow2Vxk4lzH66AoAxTfJicWOdG0mKgro6cy4ojiXUQMIGjs1foG2gipT1GcQqYOv+7qkjQ06Fs9Vi50c/qvIJUMSl1NblMfJQVzfAk1VTOfJgSngi1qRL9ka083SjI9vkcDd/LZJ5zNvwguG7KFurE69vfY4SNhhQ5dhscwJBC4QcN68u3+5O5F17M/kD8nRKlrT/A3ys8yRlmbYVaWD/K297wX 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 Sat, Jun 29, 2024 at 04:38:47PM +0200, David Hildenbrand wrote: >On 29.06.24 10:32, Wei Yang wrote: >> On Sat, Jun 29, 2024 at 08:19:49AM +0200, David Hildenbrand wrote: >> > On 29.06.24 03:33, Wei Yang wrote: >> > > Initialize all pages reserved is an ancient behavior. >> > > >> > > Since commit 92923ca3aace ("mm: meminit: only set page reserved in the >> > > memblock region"), SetPageReserved is removed from >> > > __init_single_page(). Only those reserved pages are marked PG_reserved. >> > > >> > > But we still set PG_reserved on offline and check it on online. >> > > >> > > Following two commits removed both of them: >> > > >> > > * Commit 0ee5f4f31d36 ("mm/page_alloc.c: don't set pages PageReserved() >> > > when offlining") removed the set on offline. >> > > * Commit 5ecae6359e3a ("mm/memory_hotplug: drop PageReserved() check in >> > > online_pages_range()") removed the check on online. >> > > >> > > This means we set PG_reserved for hot-plugged memory at initialization >> > > is not helpful and a little different from bootmem initialization path. >> > > Now we can remove it. >> > >> > It's not that easy for ZONE_DEVICE. >> > >> > Also, see mm/mm-stable >> > >> > commit 3dadec1babf9eee0c67c967df931d6f0cb124a04 >> > Author: David Hildenbrand >> > Date: Fri Jun 7 11:09:36 2024 +0200 >> > >> > mm: pass meminit_context to __free_pages_core() >> > >> > Patch series "mm/memory_hotplug: use PageOffline() instead of >> > PageReserved() for !ZONE_DEVICE". >> > >> > >> > commit b873faaa609ab44c223b2327f55d2b6a2ba4ca9c >> > Author: David Hildenbrand >> > Date: Fri Jun 7 11:09:37 2024 +0200 >> > >> > mm/memory_hotplug: initialize memmap of !ZONE_DEVICE with PageOffline() >> > instead of PageReserved() >> > >> >> Let me try to understand this. >> >> You also tries to get rid of PG_reserved but you want PG_offline instead, >> because this benefit virtio-mem, right? > >We now make proper use of PG_offline. All hotplugged pages start out >PG_offline once we turn the section online. Only the ones that actually get >exposed to the buddy -- actually get onlined -- get PG_offline cleared. A >side effect of that is less hacks for virtio-mem, and more natural handling >for the other ballooning drivers that hotplug memory. > >In the future, I'm planning on moving more fake-offlining code from >virtio-mem the core, making use of more PG_offline in memory. > >For now, it's stops the PG_reserved use while maintaining the same semantics >as before: the page content and "struct page" is not to be touched by anybody >except the "owner". > >> >> But I don't get why PG_offline is wrong for ZONE_DEVICE. I may miss some >> knowledge for it. > >I suggest you take a look at the PG_offline documentation. ZONE_DEVICE are >certainly not logically offline pages. They will never be considered online >as part of online sections. But they will never be handed to the buddy. > >Maybe we want a dedicate page type for them in the future, not sure. We can >right now identify them reliably using the zone idx. > >Using a page type right now is very likely not possible, because we might be >using the page->_mapcount in rmap code when mapping some of them to user >space. > >If we want to get rid of the PG_reserved for them right now, we'll have to >make sure all existing PageReserved checks won't be degraded. For >example, drivers/vfio/vfio_iommu_type1.c might need some work (no sure). > >The KVM one in kvm_pfn_to_refcounted_page() should already be fine, because >they really want to refcount them. > >A lot of other ones like can_gather_numa_stats(), already refuse >is_zone_device_page() manually, and maybe we want to factor both checks out >into a separate function like "is_special_reserved_page()" or sth like that. > Thanks for the information, I need sometime to digest it :-) >-- >Cheers, > >David / dhildenb -- Wei Yang Help you, Help me