From patchwork Mon Nov 19 10:16:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10688363 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 074D514D6 for ; Mon, 19 Nov 2018 10:16:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA2E6299E2 for ; Mon, 19 Nov 2018 10:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD9BE29C24; Mon, 19 Nov 2018 10:16:40 +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 0C86529B89 for ; Mon, 19 Nov 2018 10:16:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F41016B1A28; Mon, 19 Nov 2018 05:16:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EEF926B1A29; Mon, 19 Nov 2018 05:16:37 -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 DB91F6B1A2A; Mon, 19 Nov 2018 05:16:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id AE3016B1A28 for ; Mon, 19 Nov 2018 05:16:37 -0500 (EST) Received: by mail-qk1-f200.google.com with SMTP id 92so68387583qkx.19 for ; Mon, 19 Nov 2018 02:16:37 -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; bh=+I0cLLdLoFwtQtgvNTLDnIA9vWRw7JXX8gipk9XLCiY=; b=CHjxPy8IeVpSJJQwoHQ1vznIct6I+A0Jk/Wus9qcyalhi2Bwfzx3qhKV9VP64MSzRk Fxl+Kg7/V2RCwaPbnysD50QGxhLWtI7YfoR0l/Em0xieUiwmts8mwsu+ccA4AN/QHfSO qakVJtGtR9rkzAcxW7MUsJvMQj2qSqCJHuDDJQM+lhshbUXTwpsmpAHjQHvZBrxRwvfq 9Px2qFNwhDWSTEsEiL7nj1NwiYVq7B/Z1Uqmd3FA5rCy1abt7zAGqGIT/QuJUfgBDatR schWQnWbnE1Apb24T/MUIRd6y9yput5Z7GvTs4dbvj0J14lDv86UvBdUpSLnL4qvH+dd 7Oww== 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: AGRZ1gLcFtAtqznlY/CxkEesdlIjHhAZY3ZPmlKDKOHS+AQl3aDC8TaX U+7c2DyAHjQKdNuKbMxtmQRGjMP4WEXyc1sRw4G5Sb9I5mnIBMhRADAWO8rwrrgb9ImIg37PIaK lzae3yRRffCVybA3ufu8+fPggaDYtTbFdM/tCsRDLyv/JpEKeGqv2h7HVc1JgimsTBQ== X-Received: by 2002:a37:c0db:: with SMTP id v88mr18910558qkv.288.1542622597401; Mon, 19 Nov 2018 02:16:37 -0800 (PST) X-Google-Smtp-Source: AJdET5dCjYgBzkX0q4wNnAFnFC+PLl427aAOx9x123o2ACNsDAnkBRZbJEmEwNuoUgIhRN0dFGlH X-Received: by 2002:a37:c0db:: with SMTP id v88mr18910522qkv.288.1542622596551; Mon, 19 Nov 2018 02:16:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542622596; cv=none; d=google.com; s=arc-20160816; b=I2HTQqMBiRkyUUIFFIwOEFXzRouc1GchRWcprS6LIHAMZNrGShkV8XqzlUFqUHTVjE GQFwVZR25IcwpiUKtyJ+FIcSG8HNVvpzbSujC4GYqEu2HmddLMcnuPfx98OFmmiXSECS w9LCjyF4qH1zm5mIwtEel8rryQqPjH24PZzeU7r5HY7wd17Ie/oYepYYkgtyYjmy3ypU 2UTNezAPBclocfpTWusKOvyQvpFkCbdRJqY3VjtfURTpsV3u0TC2wRY0QgdOxVZemsZd 6Ha7wn9goD6smViHKpHyamp0rbpb6rAgqgoUG7kNEr4bl/CpPwI0aT12Qus5dl8OMVz9 eY2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=+I0cLLdLoFwtQtgvNTLDnIA9vWRw7JXX8gipk9XLCiY=; b=psFZLXFajZAsMvOm2WXNtaXKgNxlFES3a24kD8oDvOf0sAfHaoJyJpZgZxQ2nh5Lct yZl6VD0GPih69I9vRpytaRhQK12n6zYSUpM7P5Kw0NeTe5Arh9kd+XXDRhpMp7HVtTzC /bpOrHwlssA6Vb6F+jhIb5h59IAU4QB0YWrU+FrBmvISEwW0aq6Uj1MVNU45ceINxSUy zsvPcyRFa5JBuBjPJaJRwVhfgjm1eoacpSSu75sFmY1KqBwsvnPM85bqWUrhcsMmRTzB e/HBAGbbcw7+h9vc3eliwg3KNDriCzsWOjiOkAOLUsxKJKRBdU7wD+i0JVvgZ1XkcaZG dBkA== 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 z13si4597738qkz.84.2018.11.19.02.16.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 02:16:36 -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-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB34E37E74; Mon, 19 Nov 2018 10:16:34 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05A9F106224E; Mon, 19 Nov 2018 10:16:16 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devel@linuxdriverproject.org, linux-fsdevel@vger.kernel.org, linux-pm@vger.kernel.org, xen-devel@lists.xenproject.org, kexec-ml , pv-drivers@vmware.com, David Hildenbrand , Alexander Duyck , Alexey Dobriyan , Andrew Morton , Arnd Bergmann , Baoquan He , Borislav Petkov , Boris Ostrovsky , Christian Hansen , Dave Young , David Rientjes , Greg Kroah-Hartman , Haiyang Zhang , Jonathan Corbet , Juergen Gross , Julien Freche , Kairui Song , Kazuhito Hagio , "Kirill A. Shutemov" , Konstantin Khlebnikov , "K. Y. Srinivasan" , Len Brown , Lianbo Jiang , Matthew Wilcox , "Michael S. Tsirkin" , Michal Hocko , Michal Hocko , Mike Rapoport , Miles Chen , Nadav Amit , Naoya Horiguchi , Omar Sandoval , Pavel Machek , Pavel Tatashin , "Rafael J. Wysocki" , Stefano Stabellini , Stephen Hemminger , Stephen Rothwell , Vitaly Kuznetsov , Vlastimil Babka , Xavier Deguillard Subject: [PATCH v1 0/8] mm/kdump: allow to exclude pages that are logically offline Date: Mon, 19 Nov 2018 11:16:08 +0100 Message-Id: <20181119101616.8901-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 19 Nov 2018 10:16:35 +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 Right now, pages inflated as part of a balloon driver will be dumped by dump tools like makedumpfile. While XEN is able to check in the crash kernel whether a certain pfn is actuall backed by memory in the hypervisor (see xen_oldmem_pfn_is_ram) and optimize this case, dumps of virtio-balloon, hv-balloon and VMWare balloon inflated memory will essentially result in zero pages getting allocated by the hypervisor and the dump getting filled with this data. The allocation and reading of zero pages can directly be avoided if a dumping tool could know which pages only contain stale information not to be dumped. Also for XEN, calling into the kernel and asking the hypervisor if a pfn is backed can be avoided if the duming tool would skip such pages right from the beginning. Dumping tools have no idea whether a given page is part of a balloon driver and shall not be dumped. Esp. PG_reserved cannot be used for that purpose as all memory allocated during early boot is also PG_reserved, see discussion at [1]. So some other way of indication is required and a new page flag is frowned upon. We have PG_balloon (MAPCOUNT value), which is essentially unused now. I suggest renaming it to something more generic (PG_offline) to mark pages as logically offline. This flag can than e.g. also be used by virtio-mem in the future to mark subsections as offline. Or by other code that wants to put pages logically offline (e.g. later maybe poisoned pages that shall no longer be used). This series converts PG_balloon to PG_offline, allows dumping tools to query the value to detect such pages and marks pages in the hv-balloon and XEN balloon properly as PG_offline. Note that virtio-balloon already set pages to PG_balloon (and now PG_offline). Please note that this is also helpful for a problem we were seeing under Hyper-V: Dumping logically offline memory (pages kept fake offline while onlining a section via online_page_callback) would under some condicions result in a kernel panic when dumping them. As I don't have access to neither XEN nor Hyper-V nor VMWare installations, this was only tested with the virtio-balloon and pages were properly skipped when dumping. I'll also attach the makedumpfile patch to this series. [1] https://lkml.org/lkml/2018/7/20/566 RFC -> v1: - Add "PM / Hibernate: use pfn_to_online_page()" - Add "vmw_balloon: mark inflated pages PG_offline" - "mm: convert PG_balloon to PG_offline" -- After discussions, also rename the UAPI bit name (KPF_BALLOON -> KPF_OFFLINE) David Hildenbrand (8): mm: balloon: update comment about isolation/migration/compaction mm: convert PG_balloon to PG_offline kexec: export PG_offline to VMCOREINFO xen/balloon: mark inflated pages PG_offline hv_balloon: mark inflated pages PG_offline vmw_balloon: mark inflated pages PG_offline PM / Hibernate: use pfn_to_online_page() PM / Hibernate: exclude all PageOffline() pages Documentation/admin-guide/mm/pagemap.rst | 9 ++++--- drivers/hv/hv_balloon.c | 14 ++++++++-- drivers/misc/vmw_balloon.c | 32 ++++++++++++++++++++++ drivers/xen/balloon.c | 3 +++ fs/proc/page.c | 4 +-- include/linux/balloon_compaction.h | 34 +++++++++--------------- include/linux/page-flags.h | 11 +++++--- include/uapi/linux/kernel-page-flags.h | 2 +- kernel/crash_core.c | 2 ++ kernel/power/snapshot.c | 13 +++++---- tools/vm/page-types.c | 2 +- 11 files changed, 87 insertions(+), 39 deletions(-)