From patchwork Mon Sep 28 17:54:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 11804487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF38B618 for ; Mon, 28 Sep 2020 17:56:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 646D322204 for ; Mon, 28 Sep 2020 17:56:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sent.com header.i=@sent.com header.b="C59hXIN3"; dkim=temperror (0-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="j0FrHWS4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 646D322204 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=sent.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CFAFC90000D; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CD2DA90001B; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) 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 BEB5590000D; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 9783390001A for ; Mon, 28 Sep 2020 13:55:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 640B1181AE86D for ; Mon, 28 Sep 2020 17:55:30 +0000 (UTC) X-FDA: 77313222420.02.fire76_08138cb27183 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 31E9B101CFC34 for ; Mon, 28 Sep 2020 17:55:30 +0000 (UTC) X-Spam-Summary: 1,0,0,85d126e51ec61a0b,d41d8cd98f00b204,zi.yan@sent.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3354:3865:3867:3868:3870:3871:3872:3874:4118:4250:4321:5007:6117:6119:6120:6261:6630:6653:6742:7576:7903:10004:11026:11473:11658:11914:12043:12296:12438:12555:12679:12895:12986:13894:13972:14181:14721:21080:21324:21451:21627:30054:30064:30070,0,RBL:64.147.123.17:@sent.com:.lbl8.mailshell.net-64.100.201.100 62.18.0.100;04yg3piha6hoxi84a8f7bcn1xyyc8ycc7g3mfgqu7d7b35h6dzu9ti31jecarw4.j4tx74byiw9cc7baynnn1xragbcktkoqi4ni8zrnwc8q8d95od89uut13rrb9xy.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: fire76_08138cb27183 X-Filterd-Recvd-Size: 7022 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Sep 2020 17:55:29 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id CD665E95; Mon, 28 Sep 2020 13:55:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 28 Sep 2020 13:55:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=from :to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; s=fm1; bh=rCrx+wAdGZ4Zl ehY5QUiHxqrgmnxiUlf7t6hp6icemY=; b=C59hXIN3yDOINTV4MVhsGhLRUzwbb UPYycdysWR66pa3JrnWmafuw+ydviMmjuub/cZjzkxcTSrwEf1egf7K15FUE21p9 VX5G/HvxQfQf1mUglYVirkX8aqYpUeIjAkh9WTA/NR7zQXZ796GWOeBNOwUHfWBM 4aeHzyUYchfYdwTavalwYz9rk4Drjb2J++j9zqE8QlqtOZ22ldVNH2Z44tnVtDg7 I9BLU8RaYOjrP2/8X1A3EonlKFzgNuiTHDdqIJjyuK5kMFpsC8uleqFfTdtp2A1R LYBLJc3pAJL1D5Y9zlkGE/3sCPaj+3sqEu5kkJ0Htf07i8Dq+jS7yUtJA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:reply-to:subject :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=rCrx+wAdGZ4ZlehY5QUiHxqrgmnxiUlf7t6hp6icemY=; b=j0FrHWS4 1N0CXibOSAMghD1zLIu+sQukT6SNTW/kSB6KK/HftENN6LSVEp/CD4PoV0gUvMF6 jwjV3nFr2HFXDeDXzIMhgat1bW1MrHJO4uEyTl1BER304W5U62M6tvUvxzQWiXmN HLVoP0EPK9z1AYu1BPVdvzrAVXe36zHuq2YRXzuvuqHe7OlhcjF+RsSGsJSyFzdb 9NzU2wcTfNu4+BXfOxjOg/VJouNM4wyXbnZRu8a2+Dw24k4x9qvhcKdrDcucy1zs QCHA31YxWEW9DB5ArwgoAy5uhggRmeaYWku+9J30YS+Hi7DR81RrNrcXLVlOwf0c qF/eh0+d4rS/Cw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdeigdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeduhfffve ektdduhfdutdfgtdekkedvhfetuedufedtgffgvdevleehheevjefgtdenucfkphepuddv rdegiedruddtiedrudeigeenucevlhhushhtvghrufhiiigvpeduvdenucfrrghrrghmpe hmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Received: from nvrsysarch6.NVidia.COM (unknown [12.46.106.164]) by mail.messagingengine.com (Postfix) with ESMTPA id E98073064674; Mon, 28 Sep 2020 13:55:26 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org Cc: "Kirill A . Shutemov" , Roman Gushchin , Rik van Riel , Matthew Wilcox , Shakeel Butt , Yang Shi , Jason Gunthorpe , Mike Kravetz , Michal Hocko , David Hildenbrand , William Kucharski , Andrea Arcangeli , John Hubbard , David Nellans , linux-kernel@vger.kernel.org, Zi Yan Subject: [RFC PATCH v2 25/30] mm: vma: add VM_HUGEPAGE_PUD to vm_flags at bit 37. Date: Mon, 28 Sep 2020 13:54:23 -0400 Message-Id: <20200928175428.4110504-26-zi.yan@sent.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928175428.4110504-1-zi.yan@sent.com> References: <20200928175428.4110504-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 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: From: Zi Yan madvise can set this bit via MADV_HUGEPAGE | MADV_HUGEPAGE_1GB and unset it via MADV_NOHUGEPAGE | MADV_HUGEPAGE_1GB. Later, kernel will check this bit to decide whether to allocate PUD THPs or not on a VMA when the global PUD THP is set to madvise. Signed-off-by: Zi Yan --- include/linux/mm.h | 6 ++++++ mm/khugepaged.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 51b75ffa6a6c..78bee63c64da 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -305,11 +305,13 @@ extern unsigned int kobjsize(const void *objp); #define VM_HIGH_ARCH_BIT_2 34 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_3 35 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */ +#define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0) #define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1) #define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2) #define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3) #define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) +#define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS @@ -325,6 +327,10 @@ extern unsigned int kobjsize(const void *objp); #endif #endif /* CONFIG_ARCH_HAS_PKEYS */ +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +#define VM_HUGEPAGE_PUD VM_HIGH_ARCH_5 +#endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ + #if defined(CONFIG_X86) # define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */ #elif defined(CONFIG_PPC) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index b34c78085017..f085c218ea84 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -345,6 +345,9 @@ struct attribute_group khugepaged_attr_group = { int hugepage_madvise(struct vm_area_struct *vma, unsigned long *vm_flags, int advice) { + /* only support 1GB PUD THP on x86 now */ + bool use_pud_page = advice & MADV_HUGEPAGE_1GB; + advice = advice & MADV_BEHAVIOR_MASK; switch (advice) { case MADV_HUGEPAGE: @@ -359,6 +362,9 @@ int hugepage_madvise(struct vm_area_struct *vma, #endif *vm_flags &= ~VM_NOHUGEPAGE; *vm_flags |= VM_HUGEPAGE; + + if (use_pud_page) + *vm_flags |= VM_HUGEPAGE_PUD; /* * If the vma become good for khugepaged to scan, * register it here without waiting a page fault that @@ -371,6 +377,9 @@ int hugepage_madvise(struct vm_area_struct *vma, case MADV_NOHUGEPAGE: *vm_flags &= ~VM_HUGEPAGE; *vm_flags |= VM_NOHUGEPAGE; + + if (use_pud_page) + *vm_flags &= ~VM_HUGEPAGE_PUD; /* * Setting VM_NOHUGEPAGE will prevent khugepaged from scanning * this vma even if we leave the mm registered in khugepaged if