From patchwork Tue May 24 08:49:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Davydov X-Patchwork-Id: 9133429 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 900BB607D3 for ; Tue, 24 May 2016 11:24:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 839CA2823B for ; Tue, 24 May 2016 11:24:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76D2228285; Tue, 24 May 2016 11:24:16 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDD3A2823B for ; Tue, 24 May 2016 11:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755495AbcEXLYO (ORCPT ); Tue, 24 May 2016 07:24:14 -0400 Received: from mail-db3on0120.outbound.protection.outlook.com ([157.55.234.120]:43677 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752794AbcEXLYM (ORCPT ); Tue, 24 May 2016 07:24:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4l7RqmhsvVzPZDoGr6SLJpzwV8x3zysh1LeJoLFjcyM=; b=BRzBP3KJ/+aTlNe6r3uBXAr6gNFCZyHJ4S8CeRWueqwM+VEsRjBiB1jPYeOhPE8b8PDvIuNtwrQmBiXBRxwYNV7kJXkUtnlyB8/C2SwNDe1o8W+El83uDS7U7dumgwbIdFquYskR7qXaeMJRBlqqHneNlLl/aSRiqukqsnDBckw= Authentication-Results: linux-foundation.org; dkim=none (message not signed) header.d=none; linux-foundation.org; dmarc=none action=none header.from=virtuozzo.com; Received: from virtuozzo.com (195.214.232.10) by VI1PR08MB0592.eurprd08.prod.outlook.com (10.163.169.22) with Microsoft SMTP Server (TLS) id 15.1.497.12; Tue, 24 May 2016 08:49:38 +0000 From: Vladimir Davydov To: Andrew Morton CC: Johannes Weiner , Michal Hocko , , , , , Subject: [PATCH RESEND 2/8] mm: clean up non-standard page->_mapcount users Date: Tue, 24 May 2016 11:49:24 +0300 Message-ID: <502f49000e0b63e6c62e338fac6b420bf34fb526.1464079537.git.vdavydov@virtuozzo.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: VI1PR0901CA0081.eurprd09.prod.outlook.com (10.167.203.177) To VI1PR08MB0592.eurprd08.prod.outlook.com (10.163.169.22) X-MS-Office365-Filtering-Correlation-Id: a636f493-e5ba-4c6b-d377-08d383b0574d X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0592; 2:YdaYD9qdg+a7/yCKfY+8+UPxsDIIdBTZ5RhnM17GtPzCp5uIVHSAgy3QxRSVlW52ba8RKfeEYSkROkr6er8mn7LApv5hBqA3JshZbZiMuRLWmxLYyowtP6NyEuNJXtt1qJlwzflgcOVYKDfVwYHcSCtC2HadREW4b+0CXy1zizBEtNWZoUwwVCn6CKid37c6; 3:ikKm7AoBb7L7HlEx6nrrwg7pDEeQF9+GQblPbFvR4oeqIc2wTvKuXyFo9Y8IcWSleT4NBxODAY0KPXqTm0rs3y8eZE8LH+wauMlFfIUWOqGgvZAvfdXO4noJOzuVcJ7q X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR08MB0592; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0592; 25:R2I/B8WkTX00zZ5gVHwhyvzdycOT3YB4aUB3SFFn0GXWU/VTYubiNZm0uavRE86s1ABjCrVVDHNlW2tdJzJ8q7AZbl4jqQFO207h75+lsdfGnSyCkGfPhE/vQDoCbtraBAvN8Dehttu3hsBg3mlgPWn3iC+O5/xHwgpII1QPpyr5sWCM98XtcQRJifjt60jpcv5XSHHftbRBt3RxNUG8Cw/B7z4W/qyPBCljj3jo2sO0XQuQxnYgGpMdzXJE9rkIyi5LB/jqnGxVrGnEGPRzbkxiN5520RKuPWTq6lBOwx515nnQJZ8jEsl3KB16GZmObjcuV2bSROdH76qUR268PWQcz/8KLQ+OvqWx+63yiuQItEKx1ylDuFLHeqTzLV+OnsmG3UicHAHqVGiI3mOekQWiSgm7zy+kdn0tHkwSRUlUeyOkJLATa5YQA6ya/3lGYzg1Ozh2D/nKF3VIPw1Sh5/CkjjnEssIsCkn6JLDDxpDtQA+Uci+8oCQeendrbjtxIrPvr5iNo6Q85pf8WBqij8tb+aPiHBvJrnAYFmpkw6SRBsHgTyIQI3O0dZRu7uGuVrrz2+/zkEKhUkYQYFvKIBK8Se4BhqolA+ZVu+aK0EaCF0Zly3da/O0IEZphrydLSy6sKvJEf2arHkUOaDyi/L+zP/uVUL28wcE8bgirZWh2pEeRqoWB1rLS58cCfHNQhA1bnOocIaVzRRh9rxaYg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040130)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041072)(6043046); SRVR:VI1PR08MB0592; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0592; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0592; 4:C4n5/nVBMhLKXYdJDHx0op2W/VonK/wLeLYFUShjGZncAG6fl0Jj6UGzBGI9Fgspk0i2Zh+fk9uRkiFMsfapFxGLBhwEdL1i4lyA5MknyjCkY2pGs+2g3EFf015tPnlktQdmH/FFB20ydB90ri7MvKWGwVY5WdUQkyAu6IgP4PvHx9lmB7JDwWkcISA9HFrXazfieiX+9cklpcIfwjnkFP1R57fzI0YsEleuIF3ZLjOYhGYG/bjo3S2AIBFd5qW0R19xyh83zpWcfY4cjyKseQbil423JTdkkg9QUpuCZz7qCsZHkK0RkbTdq9rIiYMXYtvZXue7BqQdbJU7X7T69gUbh3gVZzUhhoi5gVe8URfz42LRF+y2pCiOPQKdSpeBc510ZOUZuiKhTPS+fVkBgPg/2/hZeFexvISRtHkCYrI= X-Forefront-PRVS: 09525C61DB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(586003)(36756003)(3846002)(6116002)(2950100001)(77096005)(76176999)(50986999)(86362001)(110136002)(92566002)(19580405001)(118296001)(19580395003)(5008740100001)(189998001)(229853001)(2906002)(4326007)(47776003)(5004730100002)(66066001)(50466002)(8676002)(80792005)(5003940100001)(33646002)(81166006)(42186005)(48376002)(50226002)(26730200005)(19860200003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0592; H:virtuozzo.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0592; 23:kWZIX7lg29mEmypAMGoEwd7Hh+gV1JGkVaWWEf6my?= =?us-ascii?Q?kpfFS+ENRexfo6VBr+rBW6qNDsiyEGhsHRNmAfQam9JpeJ59PdFOAjflhKTX?= =?us-ascii?Q?oM6RPg45cK6x4V4J6mAp81CgjK2w4yg+51gFdQBfCtapBmqp+9xu7EHuiLMW?= =?us-ascii?Q?fqZaemNGuFaRXeoaftTWIPYTqpqwywh0pAOh6KunH9dxAs2hU5NOskKTDUfm?= =?us-ascii?Q?z2ZmpvkgqwM2qsw/K056YOEEWHFE7y3U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JC6lD5YnCqfNwpZjGZSI9xPOvQQeyOqP1B2w/H4IJNmyjg==; 24:2uBkOLSP+Ix/UcZAmSkZwV+Kxjbyf0lnpvEQ6aN2qdkVt60J7cf9chBHtWlmonYiUxdbU9ZekKZ5OesUQgpDG7TDaX86/J1YtKDhO/PNA/k=; 7:Vl8Zovmi99Mu7D4OTeQ5LeV11NC6cioIQgR0ECDPQrZNJtZ/NHyk35z+yubbMAywQue44Jmnjmhi6ci+1eBP5F1Ib/8sYhhdlt1XRS37alJaVZy81+RKgrSJwtF8EhDgufxE+DUibUJphKhGr6u9of3w9Zw2NbxjNW4nqHyg/sSZ/4S2NB9w/3czWwV9ZBia; 20:v53eBIyId+uk44F15Ytb2PI4B3sF0FLCj08BrTVgtzlNryq8QyVTYwfB/pD+k/3Ttlq3riGmMYrP22V7kaFdzYBeZPRE5AUTdXDLUSDAeC5Id3lOatD/GTef8+zuNhn5TcMQgUyfwO07pxHWebwA0YZZ6sZyXF9JUicS7C4Ihew= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2016 08:49:38.3447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0592 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Add a proper comment to page->_mapcount. - Introduce a macro for generating helper functions. - Place all special page->_mapcount values next to each other so that readers can see all possible values and so we don't get duplicates. Signed-off-by: Vladimir Davydov --- include/linux/mm_types.h | 5 ++++ include/linux/page-flags.h | 73 ++++++++++++++++++++-------------------------- scripts/tags.sh | 3 ++ 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 3cc5977a9cab..16bdef7943e3 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -85,6 +85,11 @@ struct page { /* * Count of ptes mapped in mms, to show when * page is mapped & limit reverse map searches. + * + * Extra information about page type may be + * stored here for pages that are never mapped, + * in which case the value MUST BE <= -2. + * See page-flags.h for more details. */ atomic_t _mapcount; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index e5a32445f930..9940ade6a25e 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -593,54 +593,45 @@ TESTPAGEFLAG_FALSE(DoubleMap) #endif /* - * PageBuddy() indicate that the page is free and in the buddy system - * (see mm/page_alloc.c). - * - * PAGE_BUDDY_MAPCOUNT_VALUE must be <= -2 but better not too close to - * -2 so that an underflow of the page_mapcount() won't be mistaken - * for a genuine PAGE_BUDDY_MAPCOUNT_VALUE. -128 can be created very - * efficiently by most CPU architectures. + * For pages that are never mapped to userspace, page->mapcount may be + * used for storing extra information about page type. Any value used + * for this purpose must be <= -2, but it's better start not too close + * to -2 so that an underflow of the page_mapcount() won't be mistaken + * for a special page. */ -#define PAGE_BUDDY_MAPCOUNT_VALUE (-128) - -static inline int PageBuddy(struct page *page) -{ - return atomic_read(&page->_mapcount) == PAGE_BUDDY_MAPCOUNT_VALUE; +#define PAGE_MAPCOUNT_OPS(uname, lname) \ +static __always_inline int Page##uname(struct page *page) \ +{ \ + return atomic_read(&page->_mapcount) == \ + PAGE_##lname##_MAPCOUNT_VALUE; \ +} \ +static __always_inline void __SetPage##uname(struct page *page) \ +{ \ + VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page); \ + atomic_set(&page->_mapcount, PAGE_##lname##_MAPCOUNT_VALUE); \ +} \ +static __always_inline void __ClearPage##uname(struct page *page) \ +{ \ + VM_BUG_ON_PAGE(!Page##uname(page), page); \ + atomic_set(&page->_mapcount, -1); \ } -static inline void __SetPageBuddy(struct page *page) -{ - VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page); - atomic_set(&page->_mapcount, PAGE_BUDDY_MAPCOUNT_VALUE); -} +/* + * PageBuddy() indicate that the page is free and in the buddy system + * (see mm/page_alloc.c). + */ +#define PAGE_BUDDY_MAPCOUNT_VALUE (-128) +PAGE_MAPCOUNT_OPS(Buddy, BUDDY) -static inline void __ClearPageBuddy(struct page *page) -{ - VM_BUG_ON_PAGE(!PageBuddy(page), page); - atomic_set(&page->_mapcount, -1); -} +/* + * PageBalloon() is set on pages that are on the balloon page list + * (see mm/balloon_compaction.c). + */ +#define PAGE_BALLOON_MAPCOUNT_VALUE (-256) +PAGE_MAPCOUNT_OPS(Balloon, BALLOON) extern bool is_free_buddy_page(struct page *page); -#define PAGE_BALLOON_MAPCOUNT_VALUE (-256) - -static inline int PageBalloon(struct page *page) -{ - return atomic_read(&page->_mapcount) == PAGE_BALLOON_MAPCOUNT_VALUE; -} - -static inline void __SetPageBalloon(struct page *page) -{ - VM_BUG_ON_PAGE(atomic_read(&page->_mapcount) != -1, page); - atomic_set(&page->_mapcount, PAGE_BALLOON_MAPCOUNT_VALUE); -} - -static inline void __ClearPageBalloon(struct page *page) -{ - VM_BUG_ON_PAGE(!PageBalloon(page), page); - atomic_set(&page->_mapcount, -1); -} - /* * If network-based swap is enabled, sl*b must keep track of whether pages * were allocated from pfmemalloc reserves. diff --git a/scripts/tags.sh b/scripts/tags.sh index f72f48f638ae..ed7eef24ef89 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -185,6 +185,9 @@ regex_c=( '/\