From patchwork Fri Dec 14 11:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10730891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B791014E2 for ; Fri, 14 Dec 2018 11:11:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A89C22D423 for ; Fri, 14 Dec 2018 11:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CCF92D41D; Fri, 14 Dec 2018 11:11:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35EF2D425 for ; Fri, 14 Dec 2018 11:11:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC1AD8E01D3; Fri, 14 Dec 2018 06:11:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C498D8E01D1; Fri, 14 Dec 2018 06:11:29 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B11E48E01D3; Fri, 14 Dec 2018 06:11:29 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 81D1A8E01D1 for ; Fri, 14 Dec 2018 06:11:29 -0500 (EST) Received: by mail-qt1-f198.google.com with SMTP id n50so4636901qtb.9 for ; Fri, 14 Dec 2018 03:11:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=nWpD9N9Op5IxxAm08dl6DsWoy24QNA2ma1Pd8FjhpwY=; b=YBJD2mWCRzWrFc51OVP3XoaoXMTbdN7NQQgaICfOIYTGUCDKnDWeQGjgQM3/1MZy+8 53IY79RhO6fK+Vp8UzMLeS1fWzB7xcbvYIzWMEI1fYuEI1XFBgxpN//s0F7LVJSeKIpg DlQfeYj9RXBQTweMD7nYrxS4mk96lhzzs1tH7FpL3KjPziVaXzHWakmvUwmEPAtTLxI4 xtf6f7AvunBvrl5NH9sxkU1iDzFRJbEw0bQzJMYVi4wcPIXRKJxXNCNXxV0o8bpSiNau CJ6qNZNSszda/rTJ/Y9o6op65hdNTzgAS/DMs7QjUoH0IUZq1TdUpTEglg9N7hAEC3md q3ag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AA+aEWY/XAmMCaQuaC3EXsNSMSPItWzk4mradD+8VpmWU2RIKdWfppMd fyQ9NaLkF0jZk6XNmKi3Grdt58JpzPId9jWcK4tyOBW444iPV/9KkSVOVSYcSI5ub+hhgQyjQFi O/y6rXm694tvFzwxOv9VpP/rRIVR/p5xAzCUHeBbd35xAUjjDf5igicNKIgjhdp5efw== X-Received: by 2002:a37:358d:: with SMTP id c135mr2006154qka.232.1544785889251; Fri, 14 Dec 2018 03:11:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/VbmW2mr/blmaQ6fEcPZDdLw6CKtBcnmEGLcY8RxGfUvpaaE6/uui/Mo9r26kS8+vk6scXs X-Received: by 2002:a37:358d:: with SMTP id c135mr2006111qka.232.1544785888452; Fri, 14 Dec 2018 03:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544785888; cv=none; d=google.com; s=arc-20160816; b=tZw31LPVzqspLbDM8XsnXowbQFHRazqSNo6CE6ul7/B667uzyIgCs6zYXjgu4SeTqv 71SMYlPkOKJR7CSA1preEqtEwfuoLK+XoXLwO975pfjeF9t+090gFGaRiMES1q0MRiEn A64xuANY7km+IGTdKj9DnJ4peQv9qSL4OWu2J+a3DCa75lh7joSue5y/NeB/5/Eday9z wVNThTUS1lzuslOHPEFsTpFqkdf98cJIN8TDWc0OJxuTUrx3dR4V1GxZUKX4Jd4ucPWE QUlyDjj0jK/0mfUmXar1HHLA70/sCXkPmuSd8JVF4U2bUgAM+F7HO12cTFuEfau94Pr1 cVOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=nWpD9N9Op5IxxAm08dl6DsWoy24QNA2ma1Pd8FjhpwY=; b=WsaI3BYd9ruBkl1eGrkufD1wKBlnuCThfK/8YIHFjNQlintGykXNtIa76OpIDzGA+B 7G6B6udWx48l6HUC85uq50j2yVD2RDMrFP2yYZhuIAvA1Wqi51RokSDDuOMTMcVDVFt8 FiWnX64tMZLTfll9dqyQ/kiKEZk/R1L1vP5D1zSON6zSmwBhc6fD5VJNhaqHieWAShiK O2LrlFPzyqELDiPX9pvgAltiu/IxE/UZ5ov5Yje2V97HPdetI6orKcEVohbzznEzlQtN IIE1eO75IKrYgE7zFo4t8rRorNQn44+qvQy6L3QsPRHHNW6X/Z0QOaQZd99oIGzoO7SD 7gcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 9si2851024qkv.15.2018.12.14.03.11.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 03:11:28 -0800 (PST) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E53487643; Fri, 14 Dec 2018 11:11:27 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-139.ams2.redhat.com [10.36.117.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49F465DA2A; Fri, 14 Dec 2018 11:11:21 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-mediatek@lists.infradead.org, David Hildenbrand , Andrew Morton , Stephen Rothwell , Pavel Tatashin , Michal Hocko , Alexander Duyck , Matthew Wilcox , Anthony Yznaga , Miles Chen , yi.z.zhang@linux.intel.com, Dan Williams Subject: [PATCH v1 9/9] mm: better document PG_reserved Date: Fri, 14 Dec 2018 12:10:14 +0100 Message-Id: <20181214111014.15672-10-david@redhat.com> In-Reply-To: <20181214111014.15672-1-david@redhat.com> References: <20181214111014.15672-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 14 Dec 2018 11:11:27 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP The usage of PG_reserved and how PG_reserved pages are to be treated is buried deep down in different parts of the kernel. Let's shine some light onto these details by documenting current users and expected behavior. Especially, clarify on the "Some of them might not even exist" case. These are physical memory gaps that will never be dumped as they are not marked as IORESOURCE_SYSRAM. PG_reserved does in general not hinder anybody from dumping or swapping. In some cases, these pages will not be stored in the hibernation image. Cc: Andrew Morton Cc: Stephen Rothwell Cc: Pavel Tatashin Cc: Michal Hocko Cc: Alexander Duyck Cc: Matthew Wilcox Cc: Anthony Yznaga Cc: Miles Chen Cc: yi.z.zhang@linux.intel.com Cc: Dan Williams Signed-off-by: David Hildenbrand --- include/linux/page-flags.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 808b4183e30d..9de2e941cbd5 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -17,8 +17,37 @@ /* * Various page->flags bits: * - * PG_reserved is set for special pages, which can never be swapped out. Some - * of them might not even exist... + * PG_reserved is set for special pages. The "struct page" of such a page + * should in general not be touched (e.g. set dirty) except by their owner. + * Pages marked as PG_reserved include: + * - Pages part of the kernel image (including vDSO) and similar (e.g. BIOS, + * initrd, HW tables) + * - Pages reserved or allocated early during boot (before the page allocator + * was initialized). This includes (depending on the architecture) the + * initial vmmap, initial page tables, crashkernel, elfcorehdr, and much + * much more. Once (if ever) freed, PG_reserved is cleared and they will + * be given to the page allocator. + * - Pages falling into physical memory gaps - not IORESOURCE_SYSRAM. Trying + * to read/write these pages might end badly. Don't touch! + * - The zero page(s) + * - Pages not added to the page allocator when onlining a section because + * they were excluded via the online_page_callback() or because they are + * PG_hwpoison. + * - Pages allocated in the context of kexec/kdump (loaded kernel image, + * control pages, vmcoreinfo) + * - MMIO/DMA pages. Some architectures don't allow to ioremap pages that are + * not marked PG_reserved (as they might be in use by somebody else who does + * not respect the caching strategy). + * - Pages part of an offline section (struct pages of offline sections should + * not be trusted as they will be initialized when first onlined). + * - MCA pages on ia64 + * - Pages holding CPU notes for POWER Firmware Assisted Dump + * - Device memory (e.g. PMEM, DAX, HMM) + * Some PG_reserved pages will be excluded from the hibernation image. + * PG_reserved does in general not hinder anybody from dumping or swapping + * and is no longer required for remap_pfn_range(). ioremap might require it. + * Consequently, PG_reserved for a page mapped into user space can indicate + * the zero page, the vDSO, MMIO pages or device memory. * * The PG_private bitflag is set on pagecache pages if they contain filesystem * specific data (which is normally at page->private). It can be used by