Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3359776ybd; Tue, 25 Jun 2019 00:58:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLzqxyo7Ea1TLGk5ycOF/Ni0XUlXyZ/iwztqyxWun4yOyM+67fZTkedQQAlN18qG88DHjc X-Received: by 2002:a17:902:7581:: with SMTP id j1mr152256890pll.23.1561449500548; Tue, 25 Jun 2019 00:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561449500; cv=none; d=google.com; s=arc-20160816; b=cicZbDRwoc88VxxJJBVFLFiRseNSnoAMHsl8JiwXwfL9E+AiosjYwrU6z7TLF5OjnV 7ODa6Kcn05LHT8yXSPeWpfNKyNFCOv+zAIadbxhINTDv1AMOHvp2E2mu6b+mnJ2Xt3mq j5OmG7X2PzrS1poFhJ7pChlCasfqV1Fox+YebCWj9ygwM243FvjCXE6B4E09yDchKrM/ J3f9y+gS/lC4zClcV3UYkQynY9sTh81yPJKLEh5EYWK7GoejxkAzqV/snDA8X1E6AON6 wMx/O7lYqQKLwRbYk5nZK3XvxnxVE7U6XL1FZUi7xEI7S1M6Fbui1WXH77xRWvZR0enX QUZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=pQySH0L22RUnV1R+Ri6D2HobC1fyefST74dWKRzISAc=; b=Qa4tUJgB5pXt2u3wqGLB2Xguf4DqeLamTSnNdqgqybhp5Y2HeEuv250/Kj9PNQ/R79 VzHXL3Wxi8zDxO8hE/RspfXbiNlT9c21kT6YcaIblM/REf3bylbKwajosaxj1YSEGF1K A96cIyG2bCZU0IPmegv9q25kN6XCRyF2BLe3XWv/EEWu5SW7SnUvSkF6sfFoo/k11ESU TWK5OA1uAROjzfCJHvWTObVNwGbO3eL3j5+swQibrgSZzQ/VvMCByq0B/D+4abl877Cn rg7mQN0je7UIUM/Kstt7yxAvHD4mfzE9Ta5JgkAAz5ghdQZeHNvcT2Ql5HcpG1V3WdCE hqNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si12696859pgt.460.2019.06.25.00.58.05; Tue, 25 Jun 2019 00:58:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730093AbfFYHxN (ORCPT + 99 others); Tue, 25 Jun 2019 03:53:13 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:51793 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728310AbfFYHxK (ORCPT ); Tue, 25 Jun 2019 03:53:10 -0400 Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 25 Jun 2019 09:53:09 +0200 Received: from suse.de (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (NOT encrypted); Tue, 25 Jun 2019 08:52:34 +0100 From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, pasha.tatashin@soleen.com, Jonathan.Cameron@huawei.com, david@redhat.com, anshuman.khandual@arm.com, vbabka@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 3/5] mm,memory_hotplug: Introduce Vmemmap page helpers Date: Tue, 25 Jun 2019 09:52:25 +0200 Message-Id: <20190625075227.15193-4-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20190625075227.15193-1-osalvador@suse.de> References: <20190625075227.15193-1-osalvador@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce a set of functions for Vmemmap pages. Set of functions: - {Set,Clear,Check} Vmemmap flag - Given a vmemmap page, get its vmemmap-head - Get #nr of vmemmap pages taking into account the current position of the page These functions will be used for the code handling Vmemmap pages. Signed-off-by: Oscar Salvador --- include/linux/page-flags.h | 34 ++++++++++++++++++++++++++++++++++ mm/util.c | 2 ++ 2 files changed, 36 insertions(+) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index b848517da64c..a8b9b57162b3 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -466,6 +466,40 @@ static __always_inline int __PageMovable(struct page *page) PAGE_MAPPING_MOVABLE; } +#define VMEMMAP_PAGE (~PAGE_MAPPING_FLAGS) +static __always_inline int PageVmemmap(struct page *page) +{ + return PageReserved(page) && (unsigned long)page->mapping == VMEMMAP_PAGE; +} + +static __always_inline int __PageVmemmap(struct page *page) +{ + return (unsigned long)page->mapping == VMEMMAP_PAGE; +} + +static __always_inline void __ClearPageVmemmap(struct page *page) +{ + __ClearPageReserved(page); + page->mapping = NULL; +} + +static __always_inline void __SetPageVmemmap(struct page *page) +{ + __SetPageReserved(page); + page->mapping = (void *)VMEMMAP_PAGE; +} + +static __always_inline struct page *vmemmap_get_head(struct page *page) +{ + return (struct page *)page->freelist; +} + +static __always_inline unsigned long get_nr_vmemmap_pages(struct page *page) +{ + struct page *head = vmemmap_get_head(page); + return head->private - (page - head); +} + #ifdef CONFIG_KSM /* * A KSM page is one of those write-protected "shared pages" or "merged pages" diff --git a/mm/util.c b/mm/util.c index 021648a8a3a3..5e20563cdef6 100644 --- a/mm/util.c +++ b/mm/util.c @@ -607,6 +607,8 @@ struct address_space *page_mapping(struct page *page) mapping = page->mapping; if ((unsigned long)mapping & PAGE_MAPPING_ANON) return NULL; + if ((unsigned long)mapping == VMEMMAP_PAGE) + return NULL; return (void *)((unsigned long)mapping & ~PAGE_MAPPING_FLAGS); } -- 2.12.3