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 072B6C433EF for ; Thu, 16 Jun 2022 07:30:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63E696B0072; Thu, 16 Jun 2022 03:30:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ED066B0073; Thu, 16 Jun 2022 03:30:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48D7E6B0074; Thu, 16 Jun 2022 03:30:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 39F416B0072 for ; Thu, 16 Jun 2022 03:30:39 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0D225150E for ; Thu, 16 Jun 2022 07:30:39 +0000 (UTC) X-FDA: 79583276598.11.51E9E8C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id A5626C0042 for ; Thu, 16 Jun 2022 07:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655364638; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zuRC3QccXxRzfGRljGSr16hxfuV9e3Vmw7qffLvndzs=; b=RdNnR0O12rsEe4SFrq0Mq8bvhBnepTDm5mdA8f5qyMmWieaG7hv+Dml8lQvzCSpAiMqa+f 3gA5rhLilR2mbQ3dGa4mKr/ZvoGIqTs4sAPNVuhsnyoFbXd9gFzpEQ9R/c/qNole29ek+S QRk8UCFs9t15LfA1vglMX/Lt9Kce99o= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-RgJptfgzPv2s1GHva02dRg-1; Thu, 16 Jun 2022 03:30:37 -0400 X-MC-Unique: RgJptfgzPv2s1GHva02dRg-1 Received: by mail-wm1-f72.google.com with SMTP id z13-20020a7bc7cd000000b0039c4a238eadso277939wmk.9 for ; Thu, 16 Jun 2022 00:30:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=zuRC3QccXxRzfGRljGSr16hxfuV9e3Vmw7qffLvndzs=; b=z9TpcQt6qGN+oOlG6xzwrSCWALcjHa7wcl03N+CGYhdiPxJhh8JAAq2xJGTyFOdEcT Jg5ATqzV0RkC18NJTcJyXglB8IVmM4/cEinHpZyyuRArEKhSkNK88Mu7MaHDAe7lDnP5 iWJ1SUBi8Y9XQMhGO7sVxnUbwOXXqNvOr1ZYSwIkTHX1J8manZkXYbd2E9XVIY6B0dEz +T42j/8H3yQ2Igwexpc0qPkZgVgF8rOFESsWjP4QKnk5iSuUguIn+Dg+kTbTC2uYPE+c yl0XSwNf5OSVNIq7qyC9evBTCHestyi/kx+vsUq0RuS7Z2YgQGXFyYkkWi1m3579md1V 8aPg== X-Gm-Message-State: AOAM531Qbg7y4gHE4tMXgZY0cKvE9wcalUSuDRsmvjsX/D6SMaJFCbeI Nv45sVPQ/6fKFg3nQQmGxP9U6brLYxQhtZWbOS76rCINEIlEUnhBlmIRd5xkmSsZAUvGyq8QIZl VaOWFPEYwEx8= X-Received: by 2002:a05:600c:3b0c:b0:39c:7d91:26d0 with SMTP id m12-20020a05600c3b0c00b0039c7d9126d0mr13930627wms.40.1655364636034; Thu, 16 Jun 2022 00:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIqXcd+owz/Nw3PZPl47b6RVBaa+MlNHu4dEkb1E0vRUO+EQbYgm/GgBLVh8yOGJ5FIcuzEA== X-Received: by 2002:a05:600c:3b0c:b0:39c:7d91:26d0 with SMTP id m12-20020a05600c3b0c00b0039c7d9126d0mr13930591wms.40.1655364635744; Thu, 16 Jun 2022 00:30:35 -0700 (PDT) Received: from ?IPV6:2003:cb:c70b:2d00:73d7:5fab:cc8a:e48c? (p200300cbc70b2d0073d75fabcc8ae48c.dip0.t-ipconnect.de. [2003:cb:c70b:2d00:73d7:5fab:cc8a:e48c]) by smtp.gmail.com with ESMTPSA id s16-20020a5d4250000000b0020e5b4ebaecsm1057997wrr.4.2022.06.16.00.30.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Jun 2022 00:30:35 -0700 (PDT) Message-ID: <24d5ec20-9c9e-93aa-11f4-c4619f51f7d1@redhat.com> Date: Thu, 16 Jun 2022 09:30:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 To: Oscar Salvador Cc: Muchun Song , corbet@lwn.net, akpm@linux-foundation.org, paulmck@kernel.org, mike.kravetz@oracle.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com References: <20220520025538.21144-1-songmuchun@bytedance.com> <20220520025538.21144-3-songmuchun@bytedance.com> <53024884-0182-df5f-9ca2-00652c64ce36@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v2 2/2] mm: memory_hotplug: introduce SECTION_CANNOT_OPTIMIZE_VMEMMAP In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655364638; a=rsa-sha256; cv=none; b=8dRcHHmDvowqIUFFZ7J7yGhFmi5rtNWXOdzd23ez4AWbmsxQLr9BMbKoJonJOMHi1uBEkz wF1s33ZitEK3C8nypYTYmfPdoRH3cGPQ1E2ia3R+ZFKOQHinTj8eisK1wBk5U0soeqagk2 fxYDZsI1zmQACAfoz+5BZV4vB3IIIw4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RdNnR0O1; spf=none (imf28.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655364638; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zuRC3QccXxRzfGRljGSr16hxfuV9e3Vmw7qffLvndzs=; b=Oquoz2Yxq5IRs2gWuIX7Ytv7FY+1lb9/ZA7j7cFOQW+W+ipiYmsHWaMrBg2Mn/hpSdfB2h mlfahG/8wjF4xEYvq8RR2jG/+4MBey+tsVMGfSd9EdTSg55NPymKdBG83FqjHpgdVhv1n4 Ld78QBP3bLLpWEqE4r2bXhk1LHbGekc= X-Stat-Signature: zqm1oizebo8zm8f9trirqmi9qnm618ux X-Rspamd-Queue-Id: A5626C0042 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RdNnR0O1; spf=none (imf28.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1655364638-471873 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 16.06.22 05:57, Oscar Salvador wrote: > On Wed, Jun 15, 2022 at 11:51:49AM +0200, David Hildenbrand wrote: >> An easier/future-proof approach might simply be flagging the vmemmap >> pages as being special. We reuse page flags for that, which don't have >> semantics yet (i.e., PG_reserved indicates a boot-time allocation via >> memblock). > > The first versions of memmap_on_memory [1] introduced a new page type > to represent such pages, not sure if that is what you mean, e.g: > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index f91cb8898ff0..75f302a532f9 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -708,6 +708,7 @@ PAGEFLAG_FALSE(DoubleMap) > #define PG_kmemcg 0x00000200 > #define PG_table 0x00000400 > #define PG_guard 0x00000800 > +#define PG_vmemmap 0x00001000 > > #define PageType(page, flag) \ > ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) > @@ -764,6 +765,24 @@ PAGE_TYPE_OPS(Table, table) > */ > PAGE_TYPE_OPS(Guard, guard) > > +/* > + * Vmemmap pages refers to those pages that are used to create the memmap > + * array, and reside within the same memory range that was hotppluged, so > + * they are self-hosted. (see include/linux/memory_hotplug.h) > + */ > +PAGE_TYPE_OPS(Vmemmap, vmemmap) > +static __always_inline void SetPageVmemmap(struct page *page) > +{ > + __SetPageVmemmap(page); > + __SetPageReserved(page); > +} > + > +static __always_inline void ClearPageVmemmap(struct page *page) > +{ > + __ClearPageVmemmap(page); > + __ClearPageReserved(page); > +} > > [1] https://patchwork.kernel.org/project/linux-mm/patch/20190725160207.19579-3-osalvador@suse.de/ IIRC, that was used to skip these patches on the offlining path before we provided the ranges to offline_pages(). I'd not mess with PG_reserved, and give them a clearer name, to not confuse them with other, ordinary, vmemmap pages that are not self-hosted (maybe in the future we might want to flag all vmemmap pages with a new type?). I'd just try reusing the flag PG_owner_priv_1. And eventually, flag all (v)memmap pages with a type PG_memmap. However, the latter would be optional and might not be strictly required So what think could make sense is /* vmemmap pages that are self-hosted and cannot be optimized/freed. */ PG_vmemmap_self_hosted = PG_owner_priv_1, -- Thanks, David / dhildenb