From patchwork Tue Jun 13 23:08:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9784949 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 8698F60244 for ; Tue, 13 Jun 2017 23:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73FEA28573 for ; Tue, 13 Jun 2017 23:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68BD428592; Tue, 13 Jun 2017 23:14:56 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1439228573 for ; Tue, 13 Jun 2017 23:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbdFMXOy (ORCPT ); Tue, 13 Jun 2017 19:14:54 -0400 Received: from mga09.intel.com ([134.134.136.24]:7267 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753680AbdFMXOy (ORCPT ); Tue, 13 Jun 2017 19:14:54 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2017 16:14:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,339,1493708400"; d="scan'208";a="1140953284" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2017 16:14:53 -0700 Subject: [PATCH v2 1/2] mm: improve readability of transparent_hugepage_enabled() From: Dan Williams To: akpm@linux-foundation.org Cc: Jan Kara , linux-nvdimm@lists.01.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ross Zwisler , hch@lst.de, "Kirill A. Shutemov" Date: Tue, 13 Jun 2017 16:08:26 -0700 Message-ID: <149739530612.20686.14760671150202647861.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <149739530052.20686.9000645746376519779.stgit@dwillia2-desk3.amr.corp.intel.com> References: <149739530052.20686.9000645746376519779.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 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 Turn the macro into a static inline and rewrite the condition checks for better readability in preparation for adding another condition. Cc: Jan Kara Cc: Andrew Morton Reviewed-by: Ross Zwisler [ross: fix logic to make conversion equivalent] Acked-by: "Kirill A. Shutemov" Signed-off-by: Dan Williams Reviewed-by: Jan Kara Acked-by: Michal Hocko Reviewed-by: Vlastimil Babka --- include/linux/huge_mm.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index a3762d49ba39..c8119e856eb1 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -85,14 +85,23 @@ extern struct kobj_attribute shmem_enabled_attr; extern bool is_vma_temporary_stack(struct vm_area_struct *vma); -#define transparent_hugepage_enabled(__vma) \ - ((transparent_hugepage_flags & \ - (1<vm_flags & VM_HUGEPAGE))) && \ - !((__vma)->vm_flags & VM_NOHUGEPAGE) && \ - !is_vma_temporary_stack(__vma)) +extern unsigned long transparent_hugepage_flags; + +static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) +{ + if ((vma->vm_flags & VM_NOHUGEPAGE) || is_vma_temporary_stack(vma)) + return false; + + if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG)) + return true; + + if (transparent_hugepage_flags & + (1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)) + return !!(vma->vm_flags & VM_HUGEPAGE); + + return false; +} + #define transparent_hugepage_use_zero_page() \ (transparent_hugepage_flags & \ (1<