From patchwork Wed Nov 14 21:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10683101 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 44D3714E2 for ; Wed, 14 Nov 2018 21:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35F972B6B5 for ; Wed, 14 Nov 2018 21:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29FA62BD32; Wed, 14 Nov 2018 21:17:37 +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 DE3142B6B5 for ; Wed, 14 Nov 2018 21:17:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E40DA6B000A; Wed, 14 Nov 2018 16:17:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF1426B000C; Wed, 14 Nov 2018 16:17:33 -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 CB9276B000D; Wed, 14 Nov 2018 16:17:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id 99ED16B000A for ; Wed, 14 Nov 2018 16:17:33 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id k203so40815831qke.2 for ; Wed, 14 Nov 2018 13:17:33 -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=RRzTLikkIj/cL+Vufoc8Xsid2bt18phMT3MICGSMy48=; b=AYsDOoIhiAhnilBu1b9Qe37DTLvu3NF2PBxPUckpEV8ioSrJrgDupvgOotQg0jSnxI 0pnrs+Z6ZPUdS4cVLEv4nD4482lOFlveYWRjRXbMX5VNRdf6vm/qsK2ZDt9XfavMN42h /y1fIIieHLk0oqSoepmmqcIZ9Rp+82Vmim0FTqoFANLeLAtL3DSztROXt5OH1CJ/ymO6 di7l0W8/ouw7GbAjc267tWlPvhDz/gtCIOiWkJtYrlI/vdFjTJzp9yWlPygp3yECNEUg rmJx8prvEud+z2zc9a7vtgGtLlI9cFYEIYK/FYMBuBJqJ2Wz+vR95lweFCrRCNUWKOgI Uo4A== 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: AGRZ1gILUDDbKvRKSuwI9YvwTF2BkX2Ky2VfQey23C1g8oJjptynuLsG lV0l2/47m78hNLNZi/ZUf90mHQ9VLdVfBuzeh8XwEQms2SqbGRueqIrBTQtP8MqSVRzOsqL8ied wDzw0MQZzD597gDzTVND5AyM4Pdm9tVJ1QiirBCiCHhb3fhOZYw41BFRMj/IANzNO0w== X-Received: by 2002:aed:2185:: with SMTP id l5mr3519927qtc.276.1542230253302; Wed, 14 Nov 2018 13:17:33 -0800 (PST) X-Google-Smtp-Source: AJdET5e9jgh0SCm/HVowMX3PpEGnJjRdUdMkOUkBtKVneM5FrT/N9m66Nt5a/RTld1klhyU2WMpH X-Received: by 2002:aed:2185:: with SMTP id l5mr3519888qtc.276.1542230252602; Wed, 14 Nov 2018 13:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542230252; cv=none; d=google.com; s=arc-20160816; b=Ru9ngKJbWe1GMRuaRuvGy41E1Q6VkNFtlnE+Tx4LnpKmNpXEyTGamkwjiKyu43lirk t5hlyMj3t1jGbAX9HZjRO64RGgSx7FiY5qGgmQiBFL5ET0TbDXAyWcCWhCjY1QEemJ6s H4U6rwYIvFbVCuBuYUrlsMJUE5xAVOonrE5Ppc7tx4aj2AwbQFNjF6JAYVBaHpTWRh3P 3VRu35/8DRhYXlbOwyN0UEuUKjF4J1GOtxE9YvlC1NDqGN9A+0kUC1kkcWnJE3BAKny6 Oq7HmIJnwnRm8IknJva1FcDMFJ2OzjiNxQS4cSm5xHku8Oz9HrLZqGCvVQZOkgZVcEyH 1BEw== 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=RRzTLikkIj/cL+Vufoc8Xsid2bt18phMT3MICGSMy48=; b=DQLBaltQ4qlbuP+2ueEXC2seSGJRb60Ac6jv3IVUi9iI34DTmdfawG35XGKyHgs9By Y2h3KlLhHa00AP47zr9yWQOA3Kl3oV5SbQqPkGarh0MDNzLb0c1PtRUCWjHAE4OMx6Hi LhII8CtfSzu5CnQ1io300fLCD/cb5GiOWpgd2j0GqAFpMo9aK2WK1WVYNhV5pL+q3tcC A/ByaubJWDburLb6Rq/EugAQzI+Q3L/6MG7TVDpGZXonRt1SH1VpqpSCmc0PlU17Etut S3Hm+/k5WM6XiWE9mODJ6etb9Xx6a2IprbuUlCawV7Sv8xJSlJ68yfPioPAkfrwva+dv QABQ== 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 s127si6479857qkc.45.2018.11.14.13.17.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 13:17:32 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15971300272A; Wed, 14 Nov 2018 21:17:31 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-99.ams2.redhat.com [10.36.116.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07EDE5C8A4; Wed, 14 Nov 2018 21:17:23 +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, David Hildenbrand , Jonathan Corbet , Alexey Dobriyan , Mike Rapoport , Andrew Morton , Christian Hansen , Vlastimil Babka , "Kirill A. Shutemov" , Stephen Rothwell , Matthew Wilcox , "Michael S. Tsirkin" , Michal Hocko , Pavel Tatashin , Alexander Duyck , Naoya Horiguchi , Miles Chen , David Rientjes Subject: [PATCH RFC 2/6] mm: convert PG_balloon to PG_offline Date: Wed, 14 Nov 2018 22:17:00 +0100 Message-Id: <20181114211704.6381-3-david@redhat.com> In-Reply-To: <20181114211704.6381-1-david@redhat.com> References: <20181114211704.6381-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 14 Nov 2018 21:17:31 +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 PG_balloon was introduced to implement page migration/compaction for pages inflated in virtio-balloon. Nowadays, it is only a marker that a page is part of virtio-balloon and therefore logically offline. We also want to make use of this flag in other balloon drivers - for inflated pages or when onlining a section but keeping some pages offline (e.g. used right now by XEN and Hyper-V via set_online_page_callback()). We are going to expose this flag to dump tools like makedumpfile. But instead of exposing PG_balloon, let's generalize the concept of marking pages as logically offline, so it can be reused for other purposes later on. Rename PG_balloon to PG_offline. This is an indicator that the page is logically offline, the content stale and that it should not be touched (e.g. a hypervisor would have to allocate backing storage in order for the guest to dump an unused page). We can then e.g. exclude such pages from dumps. In following patches, we will make use of this bit also in other balloon drivers. While at it, document PGTABLE. Cc: Jonathan Corbet Cc: Alexey Dobriyan Cc: Mike Rapoport Cc: Andrew Morton Cc: Christian Hansen Cc: Vlastimil Babka Cc: "Kirill A. Shutemov" Cc: Stephen Rothwell Cc: Matthew Wilcox Cc: "Michael S. Tsirkin" Cc: Michal Hocko Cc: Pavel Tatashin Cc: Alexander Duyck Cc: Naoya Horiguchi Cc: Miles Chen Cc: David Rientjes Signed-off-by: David Hildenbrand --- Documentation/admin-guide/mm/pagemap.rst | 6 ++++++ fs/proc/page.c | 4 ++-- include/linux/balloon_compaction.h | 8 ++++---- include/linux/page-flags.h | 11 +++++++---- include/uapi/linux/kernel-page-flags.h | 1 + tools/vm/page-types.c | 1 + 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Documentation/admin-guide/mm/pagemap.rst b/Documentation/admin-guide/mm/pagemap.rst index 3f7bade2c231..9afd6bdc424b 100644 --- a/Documentation/admin-guide/mm/pagemap.rst +++ b/Documentation/admin-guide/mm/pagemap.rst @@ -78,6 +78,8 @@ number of times a page is mapped. 23. BALLOON 24. ZERO_PAGE 25. IDLE + 26. PGTABLE + 27. OFFLINE * ``/proc/kpagecgroup``. This file contains a 64-bit inode number of the memory cgroup each page is charged to, indexed by PFN. Only available when @@ -128,6 +130,10 @@ Short descriptions to the page flags Note that this flag may be stale in case the page was accessed via a PTE. To make sure the flag is up-to-date one has to read ``/sys/kernel/mm/page_idle/bitmap`` first. +26 - PGTABLE + page is in use as a page table +27 - OFFLINE + page is logically offline IO related page flags --------------------- diff --git a/fs/proc/page.c b/fs/proc/page.c index 6c517b11acf8..378401af4d9d 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -152,8 +152,8 @@ u64 stable_page_flags(struct page *page) else if (page_count(page) == 0 && is_free_buddy_page(page)) u |= 1 << KPF_BUDDY; - if (PageBalloon(page)) - u |= 1 << KPF_BALLOON; + if (PageOffline(page)) + u |= 1 << KPF_OFFLINE; if (PageTable(page)) u |= 1 << KPF_PGTABLE; diff --git a/include/linux/balloon_compaction.h b/include/linux/balloon_compaction.h index cbe50da5a59d..f111c780ef1d 100644 --- a/include/linux/balloon_compaction.h +++ b/include/linux/balloon_compaction.h @@ -95,7 +95,7 @@ extern int balloon_page_migrate(struct address_space *mapping, static inline void balloon_page_insert(struct balloon_dev_info *balloon, struct page *page) { - __SetPageBalloon(page); + __SetPageOffline(page); __SetPageMovable(page, balloon->inode->i_mapping); set_page_private(page, (unsigned long)balloon); list_add(&page->lru, &balloon->pages); @@ -111,7 +111,7 @@ static inline void balloon_page_insert(struct balloon_dev_info *balloon, */ static inline void balloon_page_delete(struct page *page) { - __ClearPageBalloon(page); + __ClearPageOffline(page); __ClearPageMovable(page); set_page_private(page, 0); /* @@ -141,13 +141,13 @@ static inline gfp_t balloon_mapping_gfp_mask(void) static inline void balloon_page_insert(struct balloon_dev_info *balloon, struct page *page) { - __SetPageBalloon(page); + __SetPageOffline(page); list_add(&page->lru, &balloon->pages); } static inline void balloon_page_delete(struct page *page) { - __ClearPageBalloon(page); + __ClearPageOffline(page); list_del(&page->lru); } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 50ce1bddaf56..f91da3d0a67e 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -670,7 +670,7 @@ PAGEFLAG_FALSE(DoubleMap) #define PAGE_TYPE_BASE 0xf0000000 /* Reserve 0x0000007f to catch underflows of page_mapcount */ #define PG_buddy 0x00000080 -#define PG_balloon 0x00000100 +#define PG_offline 0x00000100 #define PG_kmemcg 0x00000200 #define PG_table 0x00000400 @@ -700,10 +700,13 @@ static __always_inline void __ClearPage##uname(struct page *page) \ PAGE_TYPE_OPS(Buddy, buddy) /* - * PageBalloon() is true for pages that are on the balloon page list - * (see mm/balloon_compaction.c). + * PageOffline() indicates that the pages is logically offline although the + * containing section is online. (e.g. inflated in a balloon driver or + * not onlined when onlining the section). + * The content of these pages is effectively stale. Such pages should not + * be touched (read/write/dump/save) except by their owner. */ -PAGE_TYPE_OPS(Balloon, balloon) +PAGE_TYPE_OPS(Offline, offline) /* * If kmemcg is enabled, the buddy allocator will set PageKmemcg() on diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index 21b9113c69da..6c662eb0dab8 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -36,5 +36,6 @@ #define KPF_ZERO_PAGE 24 #define KPF_IDLE 25 #define KPF_PGTABLE 26 +#define KPF_OFFLINE 27 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c index 37908a83ddc2..b219c2eafd6a 100644 --- a/tools/vm/page-types.c +++ b/tools/vm/page-types.c @@ -137,6 +137,7 @@ static const char * const page_flag_names[] = { [KPF_PGTABLE] = "g:pgtable", [KPF_ZERO_PAGE] = "z:zero_page", [KPF_IDLE] = "i:idle_page", + [KPF_OFFLINE] = "o:offline", [KPF_RESERVED] = "r:reserved", [KPF_MLOCKED] = "m:mlocked",