From patchwork Thu Jul 12 23:36:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10522415 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 549F56032C for ; Thu, 12 Jul 2018 23:37:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E9327D16 for ; Thu, 12 Jul 2018 23:37:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3752E298A6; Thu, 12 Jul 2018 23:37:10 +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, 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 C103927D16 for ; Thu, 12 Jul 2018 23:37:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0211F6B000D; Thu, 12 Jul 2018 19:37:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE66D6B0266; Thu, 12 Jul 2018 19:37:06 -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 D5FC66B0269; Thu, 12 Jul 2018 19:37:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f70.google.com (mail-pl0-f70.google.com [209.85.160.70]) by kanga.kvack.org (Postfix) with ESMTP id 8A9FC6B000D for ; Thu, 12 Jul 2018 19:37:06 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id g15-v6so7415204plo.11 for ; Thu, 12 Jul 2018 16:37:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=3ZCXXQBqh5yPmFFbldns+EUoyeAQjbW5Y3B28FuP9lE=; b=B09iVawjyOuD/lfMarxqHlbTNE/YiUis8AORpTrija8gY0XucafHiQpDk10o+ljNzN ZHKmeAhhA5gm/A2ncpIvC1OWApuX2DT7+SpmcfgmRtf6qdwmGD9eQwpfF6rSkk7WIZB6 sxyaLXAV4J74zB09LCWDtl5Hnci6hPU8E9uLsV/4a+uaOOPSvhHLpYtFVm6Nwu7ds7Tz 2Vw8IpzG8wJ6lqPyuZGuBXAVm3O9zLTbx3LlOISZRZtmLuHZCgcSrt60xkCHafOZBjfy jZ7laAF9ZM5hjwxcwZ0REsIt7qOieXVTMMpX/A6E3lTc732TY2l0r2rFag4LRNIWO6Hk nQWQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlEJAs8GTLVb+Ec/uzK+9oOxYBb13oIAkmxGm28V8Ava5B4sbRg6 I12Aoq1Yt6MA3raZ6eGFc7+wvAWkqV6sBKjZUkuS9X1r8LT5VR3dCk4a+/yAz98EI/8h6f224/4 fe/nJnYJRmOvdE1oQFmw7uibAIQeEQXvEULPplOhCVSjacQFuXGoqxxc7k8ozTHuY4A== X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr926013pfm.254.1531438626260; Thu, 12 Jul 2018 16:37:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdJSexEvxUC0cl5v3PbQbu5j3LWYK2U/bTpxFguhT8I0iycDmCJOy1Ytpt/JbhlM9lLBZTN X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr925970pfm.254.1531438625456; Thu, 12 Jul 2018 16:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531438625; cv=none; d=google.com; s=arc-20160816; b=RyRSH3zYJQQGBeGwdEMibK2S9I6JiXd3qatTamTc9H8REtpwvSCTV+Ze32qJ+r9NDn IHPTO7ycWBPUSZsi/PovaYen0GWln6IZAqG3Ue6k0zSojmFoyCdlajzC1lb+mTkmnl+U I5jBkoHH1dqYnr51vR8bmzynApsgqNoMlnXzhET5nfuw1WwSBWsSLX82LAKU9jHXufv+ osbDwOCm1siHenTmsKRHnmEVVNGOTdLtRatvy/3EY4FeaYH97vO8MXZHpyVKF3Oc4vQ7 SJx+K+dgEJ3Arhn/hhlUPGjp8+M1cv9XCtEedfeu5qeyJIXSRDmm+dRjM83v4igbZ62r l7Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3ZCXXQBqh5yPmFFbldns+EUoyeAQjbW5Y3B28FuP9lE=; b=UyYJewishs2EIVNmonXvjH2xtJLEs8U4jKP4Miv7rlqNGvsK1qVyPbKC5P8B7d15+Z bfEOEdvyeReHPSuswPX61iMlUoYOkSAWTyj9coi3ai7P9MX+FxdeAFOi5zPshG3SxWFU 1nGjhS7Zu0hzL47IwiFMjtJXd64nKJpvQXpHlcxDySelGrybreGVbVO4r1QfsmXMzqP7 3i8sgKtYFoKIvB/XTOMokYr6M8APSNGFzgibEpoQIb2Ig2UsADyxBr5iv3MJnPfSPfBI KFpm+ilXHNOIK52OGe2z6rnZRV975hWCn9bhBsF+7X10cIzULv2F9YrAizM6Ck2oBnRc qArw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id o184-v6si21060983pga.520.2018.07.12.16.37.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 16:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2018 16:37:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,345,1526367600"; d="scan'208";a="57272250" Received: from yongjuns-mobl2.ccr.corp.intel.com (HELO yhuang6-ux31a.ccr.corp.intel.com) ([10.254.213.67]) by orsmga006.jf.intel.com with ESMTP; 12 Jul 2018 16:36:49 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Daniel Jordan , Dan Williams , Dave Hansen Subject: [PATCH 3/6] swap: Unify normal/huge code path in swap_page_trans_huge_swapped() Date: Fri, 13 Jul 2018 07:36:33 +0800 Message-Id: <20180712233636.20629-4-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180712233636.20629-1-ying.huang@intel.com> References: <20180712233636.20629-1-ying.huang@intel.com> 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 From: Huang Ying As suggested by Dave, we should unify the code path for normal and huge swap support if possible to avoid duplicated code, bugs, etc. and make it easier to review code. In this patch, the normal/huge code path in swap_page_trans_huge_swapped() is unified, the added and removed lines are same. And the binary size is kept almost same when CONFIG_TRANSPARENT_HUGEPAGE=n. text data bss dec hex filename base: 24179 2028 340 26547 67b3 mm/swapfile.o unified: 24215 2028 340 26583 67d7 mm/swapfile.o Signed-off-by: "Huang, Ying" Suggested-by: Dave Hansen Cc: Michal Hocko Cc: Johannes Weiner Cc: Shaohua Li Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel Cc: Daniel Jordan Cc: Dan Williams --- mm/swapfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 75c84aa763a3..160f78072667 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -270,7 +270,10 @@ static inline void cluster_set_null(struct swap_cluster_info *info) static inline bool cluster_is_huge(struct swap_cluster_info *info) { - return info->flags & CLUSTER_FLAG_HUGE; + if (IS_ENABLED(CONFIG_THP_SWAP)) + return info->flags & CLUSTER_FLAG_HUGE; + else + return false; } static inline void cluster_clear_huge(struct swap_cluster_info *info) @@ -1489,9 +1492,6 @@ static bool swap_page_trans_huge_swapped(struct swap_info_struct *si, int i; bool ret = false; - if (!IS_ENABLED(CONFIG_THP_SWAP)) - return swap_swapcount(si, entry) != 0; - ci = lock_cluster_or_swap_info(si, offset); if (!ci || !cluster_is_huge(ci)) { if (map[roffset] != SWAP_HAS_CACHE)