From patchwork Tue May 8 02:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huaisheng HS1 Ye X-Patchwork-Id: 10385157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C8646037F for ; Tue, 8 May 2018 02:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEDDE289C4 for ; Tue, 8 May 2018 02:33:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3114289CB; Tue, 8 May 2018 02:33:46 +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,DKIM_SIGNED, DKIM_VALID, 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 A3510289C5 for ; Tue, 8 May 2018 02:33:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC316B000C; Mon, 7 May 2018 22:33:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B9CFE6B000D; Mon, 7 May 2018 22:33:44 -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 A3CD26B0010; Mon, 7 May 2018 22:33:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 7AF056B000C for ; Mon, 7 May 2018 22:33:44 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id d128so22581901qkf.18 for ; Mon, 07 May 2018 19:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:thread-topic :thread-index:date:message-id:references:in-reply-to:accept-language :content-language:spamdiagnosticoutput:spamdiagnosticmetadata :content-transfer-encoding:mime-version; bh=7KdWRpPhLt9Bb1Mzxks2j2yJsSjwh6wcW+ljF2nlEF4=; b=W+PECKbjcYifjAWKw2parRV4VdXfOxQ4xqz/O7OOWYqhSpVX+8KLv75ZPHgIZa4x7D gN+9r/fvAXXgt5NEjfahO36YZvdaFVzc6JkfFb6fy9LU5mT8C71x9HqzKonuqPu7+pye JIdXJFoDExmpS5cmqeNf6P1JxEWzU/4cgMHxyGc0MbmEUiW58WisTz2hZQnr+l5LTGdI ueET1zXfBJSVmmrRkQR28BKz7D+leh4T2J8zMJGM6cuAKOAIKncXEDp2DSKBLmtekOAQ Hpg9mdllkN/0uigazk8MRm48q4u8BAzj/puduJXE3tvjqN9qcCFQTG9h5t1pAx/hce1O pN9g== X-Gm-Message-State: ALQs6tCZVCmY+Y1rA9rhc4blA6QIr7/WbTZVpNMNXFY8OyUZg9BcVY2B H0oxWUXwGKRX7W6Dva5VFeX2arus82uiTNH4Xr1cRDZcPijAGju6zvTQpEviJYKmQ3OE8/+anDc iTATC4rbB7ArOktA2cJFO02ygO9UcMvxq95Yz1reim2wEM5SDcAaBS0C9G7Vy4XYONg== X-Received: by 2002:ac8:5293:: with SMTP id s19-v6mr34219950qtn.311.1525746824250; Mon, 07 May 2018 19:33:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrWJf+PB72dX5e0thCCLSNqeXG378NUVpp6q/DKvb7ou5ruEjMAzkO2hxLOoBW4J2ccjLD7 X-Received: by 2002:ac8:5293:: with SMTP id s19-v6mr34219928qtn.311.1525746823553; Mon, 07 May 2018 19:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525746823; cv=none; d=google.com; s=arc-20160816; b=g43bEqBCNVojAFctRHe3OJakGSrdON6hN1/c/1X3poYnS3BfvE/J6vXMi8RWk58jRi RsbzBB6xXArTCxENc6LTaI8kylcUzTpikgxEwCFd3Pah92M6d1hAvjZdaf2T5n1pJjYu 0KDROwIizbSehHbIvdGz0olq+TKftvR7FFzJVG1fMNyH8iRagRbC2mB0l2LHOcibym0s f06lhz7/NixvrZuf6WuuvpVl0iJQV5AAN1hYZbsKe1Gt7/oa8/NEqMGTW2lqbyt4DFub BjrBuobEODRv2G3pEdycX7uAJgSVvz6/hHialBVBygFDJs9BSGt+odP2xqOuWtevpplR hDTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=7KdWRpPhLt9Bb1Mzxks2j2yJsSjwh6wcW+ljF2nlEF4=; b=o8zQF8t5+ye8PrLNKArPswlk/T5L6p/QAC379v5pmNvPNQU1Dj9hQBcP4uhTrRSP7f 4u8fUsYmH6dxfy0LhUqAevEdaVZa+v4YzigcyaD0IcnlDAm75Y4yslP9iFKJxDlFH2V0 O/xpieRqxrpxUcBMoH3Gze09nmlUdWzpfT+pquHCuJk3gusgKkRkNgXLmsNdWZV/2Nmm Fp7zgPtIaeqbICjht+7vmH9MMitVcs2L5YHHkdYRtxW1lZ5RACI5lubMcC42uFLs6UP8 wfkOmMhMHQ2fO2VzwgiE9JgcEK2PkWG1ZitEE7KdazxGMGOv1iGKpvrepAlivUGR1Kzu fUXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@LenovoBeijing.onmicrosoft.com header.s=selector1-lenovo-com header.b=LTJfKnzR; spf=pass (google.com: domain of yehs1@lenovo.com designates 216.82.243.208 as permitted sender) smtp.mailfrom=yehs1@lenovo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lenovo.com Received: from mail1.bemta8.messagelabs.com (mail1.bemta8.messagelabs.com. [216.82.243.208]) by mx.google.com with ESMTPS id p90-v6si6878217qtd.350.2018.05.07.19.33.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 19:33:43 -0700 (PDT) Received-SPF: pass (google.com: domain of yehs1@lenovo.com designates 216.82.243.208 as permitted sender) client-ip=216.82.243.208; Authentication-Results: mx.google.com; dkim=pass header.i=@LenovoBeijing.onmicrosoft.com header.s=selector1-lenovo-com header.b=LTJfKnzR; spf=pass (google.com: domain of yehs1@lenovo.com designates 216.82.243.208 as permitted sender) smtp.mailfrom=yehs1@lenovo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lenovo.com Received: from [216.82.242.38] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-16.bemta-8.messagelabs.com id 23/E6-04586-78C01FA5; Tue, 08 May 2018 02:33:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1WTb1AUZRjA793d21svVl8WkScUP9w4Vld3I2c f1v4Nac7sTDXRRykH9mK927o/zO3JXOlMMHRMAf6dwew49SpFRBgKKBQVJsgBwWI6JEsNUjAN SDy1QTmybm9Pq2+/5/09z/M+z867DMkFDdmMFPBLPo/oMtFGynn9MmGpTIsVrLpZ/xwfbmmi+ c+6nPzH5UMG/mjrq/xwZ5jmR5v+1vMVuy4a+GOHugh+bHseH+w9TvF1H9zQ83Xl2xEfvxum81 ihd3qGFI43NxJCW4NZaL212yD0741TQnXdfUqIXb1ACS3tI5RwNvKtQWgb3CJ8NfeCEJzNFG6 3Ls9nC/Syx+4NFOmdU1+2USWzfOD2/Dxdhq5aqpCR4fAEgr7Rs0gLehBcnJym1YDCNSS0lEcI zWwj4LfTlaQWXEIwNl1HVaEFDI2fgDPTP5IqL8abIHqvM1lB4ko9nA/WJkUGLobamgFCS5Jh/ /WyBDMJtkHo85XqMYVXwEddvcl0Fr8J586PG1TmcAAic4eTvACvhb3XriQZ4RzYc2Us2ZLEWb BvT0ivMmAMB08OkRpnwu/j91PnJgh9czDFORA9UJ3cGfBOPXRc+4vWRC70HekmNVFNw0BNBaU FXyMYPj2YKjfDoe8vURq/A5P3hlO8Bj6M/pTi5dC47XKq+AgJP7SfQJpYBuFfuih1fQ7boTku 70TW0H+20PgpiJy4RWv8JNR/OkWGkl8mHc58MkFFENWIHlckX6nks9iettp9ssPpd4uyy5K7i re6JUURHZJLtCvWt7zuVpR4ku/rdOgY+m5qQw96lCFMmWwpFSvgFtq9xe86RcVZ6NvskpQetI xhTMC+/kjCpfskhxTYJLsS7/qBBibNtJgdNSY0q5SIbkV2aGoAWZim9t01JEd5vB4pO4tdovb AapJzs+dhiwd/RxTlZGewSKfTcWklks8t+//vJ1EWg0wZrFntkiZ7/A9vmkwMQSSGSP91Rh3C L/6rssvQEi9XPD80s2713I74xoFC4tkVq5dufTFoXrd+34YvHAcm8u7aonndzA7jKaLI9Fhs0 S7rqZPvObj+3vG+kY7wrPLMRNXKO/W22pGXnl+I85v/HOxeUxpMD24pdNyI57fk/+x9pWLjG/ 1vbw0VvWy8ea6hYe2dsqMd62MNrxlsSzsv/IFNlOIUc82kTxH/AdpOw28YBAAA X-Env-Sender: yehs1@lenovo.com X-Msg-Ref: server-8.tower-128.messagelabs.com!1525746822!68836764!1 X-Originating-IP: [104.232.225.2] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.9.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61638 invoked from network); 8 May 2018 02:33:42 -0000 Received: from unknown (HELO maesmtp01.lenovo.com) (104.232.225.2) by server-8.tower-128.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 May 2018 02:33:42 -0000 Received: from USEXEDGE01.lenovo.com (unknown [10.62.65.4]) by maesmtp01.lenovo.com with smtp (TLS: TLSv1/SSLv3,256bits,ECDHE-RSA-AES256-SHA) id 0619_1f58_42b1c9b6_b7b2_4c4c_bfe1_82d259069edc; Tue, 08 May 2018 02:33:35 +0000 Received: from APC01-HK2-obe.outbound.protection.outlook.com (65.55.88.210) by USEXEDGE01.lenovo.com (10.62.65.4) with Microsoft SMTP Server (TLS) id 14.3.123.3; Mon, 7 May 2018 22:33:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=LenovoBeijing.onmicrosoft.com; s=selector1-lenovo-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7KdWRpPhLt9Bb1Mzxks2j2yJsSjwh6wcW+ljF2nlEF4=; b=LTJfKnzRwWXSPb7w7irbFSzY3KHTscT5yEurN9PBdzrYpNdfia9qPGyubRB9NZ0bZFcho1aRQcSH8vE4IOa0v8m1ZhJMXeroI5tGh9yThrNhUyC4V5TjXPkJMTkXjQthnNVO4iWTHuR0fH7ibphhCGOK2CHYvtmahOzPo3+aTsU= Received: from HK2PR03MB1684.apcprd03.prod.outlook.com (10.165.178.14) by HK2PR03MB1490.apcprd03.prod.outlook.com (10.165.57.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.755.10; Tue, 8 May 2018 02:33:32 +0000 Received: from HK2PR03MB1684.apcprd03.prod.outlook.com ([fe80::d87a:89b7:f377:f5d]) by HK2PR03MB1684.apcprd03.prod.outlook.com ([fe80::d87a:89b7:f377:f5d%4]) with mapi id 15.20.0755.012; Tue, 8 May 2018 02:33:31 +0000 From: Huaisheng HS1 Ye To: "akpm@linux-foundation.org" , "linux-mm@kvack.org" CC: "mhocko@suse.com" , "willy@infradead.org" , "vbabka@suse.cz" , "mgorman@techsingularity.net" , "pasha.tatashin@oracle.com" , "alexander.levin@verizon.com" , "hannes@cmpxchg.org" , "penguin-kernel@I-love.SAKURA.ne.jp" , "colyli@suse.de" , NingTing Cheng , "Ocean HY1 He" , "linux-kernel@vger.kernel.org" , "linux-nvdimm@lists.01.org" Subject: [External] [RFC PATCH v1 3/6] mm, zone_type: create ZONE_NVM and fill into GFP_ZONE_TABLE Thread-Topic: [External] [RFC PATCH v1 3/6] mm, zone_type: create ZONE_NVM and fill into GFP_ZONE_TABLE Thread-Index: AQHT5nLzy/4k5ASDlU6ANqYChIyrIKQlHNwQ Date: Tue, 8 May 2018 02:33:30 +0000 Message-ID: References: <1525746628-114136-1-git-send-email-yehs1@lenovo.com> <1525746628-114136-4-git-send-email-yehs1@lenovo.com> In-Reply-To: <1525746628-114136-4-git-send-email-yehs1@lenovo.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [111.197.250.78] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; HK2PR03MB1490; 7:NVihKtGCXJgQLXP9Z2Ojm2OOgUkq0W/8Gb5nudkko3FFO3oAiZt0s4EqR0g4f07Es0ssDYpeFLR3BpZx7Hvz0yKVpg5Mq/HexfDer1IG48XoNyfoaaocOBugaVEQ/mE5+hryC8BMetflSFzD2602q+x09kXI3e1Fjd2Tqdgnq0noPweB4Z/k9DSvlXa9lni1RLy0tSxZYy/XUCRG6y06a79quRqLYAAUkzUl6DVKwtdfZjBqp73uiCnO6WBuvSo7; 20:mixslv69UXj+IK8YsDyfHRCLUOLqKVSVcPG9fHky6soWuVNwbOKERl0a9ezoVRnDcM6VoZ2Dtg5ON4rwMb0JF2yo/4bRbzbh9DU43RzgqG6qu/Z9Whem3W5+lS5EvrNHYhe5KWipxEgreLWNY3aIkQa4B+79btkbsDPnJsH0IEnVzY0KmAmNZM4H0S7vb3Xzl8xT10uQSWZDL7N4FVR7lBVz/SMD6VBT7QjKNGZqHSTX8CQaYLc7yy0p0NZ0Ntk/IburJTpxEzVFKUAc6OQE6f798qDaD2UlDujPX7xsXNW/z7fEncmiIOMvq6ttMvl/gorD899NUKH0CPM9wHCvAA== x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10019020)(396003)(346002)(366004)(39850400004)(39380400002)(376002)(199004)(189003)(186003)(4326008)(68736007)(11346002)(476003)(99286004)(33656002)(6346003)(446003)(25786009)(6436002)(102836004)(53936002)(9686003)(7736002)(81166006)(8936002)(26005)(81156014)(8676002)(316002)(55016002)(486006)(54906003)(110136005)(305945005)(76176011)(59450400001)(7416002)(2900100001)(6506007)(6116002)(3846002)(2906002)(14454004)(66066001)(5660300001)(74316002)(86362001)(3660700001)(105586002)(106356001)(478600001)(97736004)(5250100002)(2501003)(575784001)(7696005)(3280700002)(13296004)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR03MB1490; H:HK2PR03MB1684.apcprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HK2PR03MB1490; x-ms-traffictypediagnostic: HK2PR03MB1490: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(3940261145250); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:HK2PR03MB1490; BCL:0; PCL:0; RULEID:; SRVR:HK2PR03MB1490; x-forefront-prvs: 0666E15D35 received-spf: None (protection.outlook.com: lenovo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: aDa7kJL8Ls2wySFCbNREZqE3TV+2u0WpZaCpnVQ5U8zE0HDkFxoKFfg9ZqyNRq1HrEnMsPjVgfCgbY2MAjTGmjL44in61XBuicB6r6GxUJkFd7KsgLuv7C0GoTxq2oNs4u4/6uQwrvx63elhy2mNGtf3/gjpN3NcB+PXzhi8Mjri+i8OI+cjqHulM2lc+9Kw spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b38e2dde-16af-4b9e-d70f-08d5b48c16aa X-MS-Exchange-CrossTenant-Network-Message-Id: b38e2dde-16af-4b9e-d70f-08d5b48c16aa X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2018 02:33:30.9837 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5c7d0b28-bdf8-410c-aa93-4df372b16203 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR03MB1490 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 Expand ZONE_NVM into enum zone_type, and create GFP_NVM which represents gfp_t flag for NVM zone. Because there is no lower plain integer GFP bitmask can be used for ___GFP_NVM, a workable way is to get space from GFP_ZONE_BAD to fill ZONE_NVM into GFP_ZONE_TABLE. Signed-off-by: Huaisheng Ye Signed-off-by: Ocean He --- include/linux/gfp.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++--- include/linux/mmzone.h | 3 +++ mm/Kconfig | 16 ++++++++++++++ mm/page_alloc.c | 3 +++ 4 files changed, 76 insertions(+), 3 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 1a4582b..9e4d867 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -39,6 +39,9 @@ #define ___GFP_DIRECT_RECLAIM 0x400000u #define ___GFP_WRITE 0x800000u #define ___GFP_KSWAPD_RECLAIM 0x1000000u +#ifdef CONFIG_ZONE_NVM +#define ___GFP_NVM 0x4000000u +#endif #ifdef CONFIG_LOCKDEP #define ___GFP_NOLOCKDEP 0x2000000u #else @@ -57,7 +60,12 @@ #define __GFP_HIGHMEM ((__force gfp_t)___GFP_HIGHMEM) #define __GFP_DMA32 ((__force gfp_t)___GFP_DMA32) #define __GFP_MOVABLE ((__force gfp_t)___GFP_MOVABLE) /* ZONE_MOVABLE allowed */ +#ifdef CONFIG_ZONE_NVM +#define __GFP_NVM ((__force gfp_t)___GFP_NVM) /* ZONE_NVM allowed */ +#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE|__GFP_NVM) +#else #define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE) +#endif /* * Page mobility and placement hints @@ -205,7 +213,8 @@ #define __GFP_NOLOCKDEP ((__force gfp_t)___GFP_NOLOCKDEP) /* Room for N __GFP_FOO bits */ -#define __GFP_BITS_SHIFT (25 + IS_ENABLED(CONFIG_LOCKDEP)) +#define __GFP_BITS_SHIFT (25 + IS_ENABLED(CONFIG_LOCKDEP) + \ + (IS_ENABLED(CONFIG_ZONE_NVM) << 1)) #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) /* @@ -283,6 +292,9 @@ #define GFP_TRANSHUGE_LIGHT ((GFP_HIGHUSER_MOVABLE | __GFP_COMP | \ __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM) #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM) +#ifdef CONFIG_ZONE_NVM +#define GFP_NVM __GFP_NVM +#endif /* Convert GFP flags to their corresponding migrate type */ #define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE) @@ -342,7 +354,7 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) * 0x0 => NORMAL * 0x1 => DMA or NORMAL * 0x2 => HIGHMEM or NORMAL - * 0x3 => BAD (DMA+HIGHMEM) + * 0x3 => NVM (DMA+HIGHMEM), now it is used by NVDIMM zone * 0x4 => DMA32 or DMA or NORMAL * 0x5 => BAD (DMA+DMA32) * 0x6 => BAD (HIGHMEM+DMA32) @@ -370,6 +382,29 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) #error GFP_ZONES_SHIFT too large to create GFP_ZONE_TABLE integer #endif +#ifdef CONFIG_ZONE_NVM +#define ___GFP_NVM_BIT (___GFP_DMA | ___GFP_HIGHMEM) +#define GFP_ZONE_TABLE ( \ + ((__force unsigned long)ZONE_NORMAL << \ + 0 * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)OPT_ZONE_DMA << \ + ___GFP_DMA * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)OPT_ZONE_HIGHMEM << \ + ___GFP_HIGHMEM * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)OPT_ZONE_DMA32 << \ + ___GFP_DMA32 * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)ZONE_NORMAL << \ + ___GFP_MOVABLE * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)OPT_ZONE_DMA << \ + (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)ZONE_MOVABLE << \ + (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)OPT_ZONE_DMA32 << \ + (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT) \ + | ((__force unsigned long)ZONE_NVM << \ + ___GFP_NVM_BIT * GFP_ZONES_SHIFT) \ +) +#else #define GFP_ZONE_TABLE ( \ (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT) \ | (OPT_ZONE_DMA << ___GFP_DMA * GFP_ZONES_SHIFT) \ @@ -380,6 +415,7 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) | (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT)\ | (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT)\ ) +#endif /* * GFP_ZONE_BAD is a bitmap for all combinations of __GFP_DMA, __GFP_DMA32 @@ -387,6 +423,17 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) * entry starting with bit 0. Bit is set if the combination is not * allowed. */ +#ifdef CONFIG_ZONE_NVM +#define GFP_ZONE_BAD ( \ + 1 << (___GFP_DMA | ___GFP_DMA32) \ + | 1 << (___GFP_DMA32 | ___GFP_HIGHMEM) \ + | 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM) \ + | 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA) \ + | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA) \ + | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \ + | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \ +) +#else #define GFP_ZONE_BAD ( \ 1 << (___GFP_DMA | ___GFP_HIGHMEM) \ | 1 << (___GFP_DMA | ___GFP_DMA32) \ @@ -397,12 +444,16 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM) \ | 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM) \ ) +#endif static inline enum zone_type gfp_zone(gfp_t flags) { enum zone_type z; int bit = (__force int) (flags & GFP_ZONEMASK); - +#ifdef CONFIG_ZONE_NVM + if (bit & __GFP_NVM) + bit = (__force int)___GFP_NVM_BIT; +#endif z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) & ((1 << GFP_ZONES_SHIFT) - 1); VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1); diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 7522a69..f38e4a0 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -345,6 +345,9 @@ enum zone_type { */ ZONE_HIGHMEM, #endif +#ifdef CONFIG_ZONE_NVM + ZONE_NVM, +#endif ZONE_MOVABLE, #ifdef CONFIG_ZONE_DEVICE ZONE_DEVICE, diff --git a/mm/Kconfig b/mm/Kconfig index c782e8f..5fe1f63 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -687,6 +687,22 @@ config ZONE_DEVICE If FS_DAX is enabled, then say Y. +config ZONE_NVM + bool "Manage NVDIMM (pmem) by memory management (EXPERIMENTAL)" + depends on NUMA && X86_64 + depends on HAVE_MEMBLOCK_NODE_MAP + depends on HAVE_MEMBLOCK + depends on !IA32_EMULATION + default n + + help + This option allows you to use memory management subsystem to manage + NVDIMM (pmem). With it mm can arrange NVDIMMs into real physical zones + like NORMAL and DMA32. That means buddy system and swap can be used + directly to NVDIMM zone. This feature is beneficial to recover + dirty pages from power fail or system crash by storing write cache + to NVDIMM zone. + config ARCH_HAS_HMM bool default y diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 266c065..d8bd20d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -228,6 +228,9 @@ bool pm_suspended_storage(void) "DMA32", #endif "Normal", +#ifdef CONFIG_ZONE_NVM + "NVM", +#endif #ifdef CONFIG_HIGHMEM "HighMem", #endif