From patchwork Thu Jul 19 08:48:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10533897 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 9FB146062E for ; Thu, 19 Jul 2018 08:49:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EDB5295DE for ; Thu, 19 Jul 2018 08:49:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 799FE295D9; Thu, 19 Jul 2018 08:49:06 +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=unavailable 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 566E4295D9 for ; Thu, 19 Jul 2018 08:49:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A92976B0277; Thu, 19 Jul 2018 04:49:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A42B86B0278; Thu, 19 Jul 2018 04:49:01 -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 90ACB6B027A; Thu, 19 Jul 2018 04:49:01 -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 4E49A6B0277 for ; Thu, 19 Jul 2018 04:49:01 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id x2-v6so4189022plv.0 for ; Thu, 19 Jul 2018 01:49:01 -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=AYAYAZf7sJhSGquy6vqROw7Jiu0lxQ8wO41Id0hdW3w=; b=sJ811H3crkv3En3NSxPBA+BrhObZwocy0TZXs+tdULSkqKm4WTVhYU+eO875NikH2h OeBAXxHE39+YWWjP5ff1EZrLbZ2FlqICDz3iB/cijPQS676Rbi+d38vW0Mkr8NT88w9z 6TsKO3cPUWB/9mCpbsa1XRtn+ktY8eGmQ3vzY762taIpgujmyDQIGoGzQJYvGuBwXqlu cfzPOgVEXYuFthSsGw9AZxMNlrMpHZXE8DGnpLQRjUNQQXiNyw53WyYEUctdlbMS+TAM diQAf/Fr9FWxFC2qKGmpjCxkvk8H1y25RAgCAHVckluDHBFBw+t8T69GpLsXTi+Ehf3C 4eXQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 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: AOUpUlFkh75wi5lAOMscW0qc/GFinb2ze7aOcgfdkzMEMZEjCw/aNh/7 u/CnETIDhsBWbBjRxqEcE89lS5/LvuDd0tP6CpzphrmwlYzPKQqjoylCvouWCrj/fHw6gU1l6mO OKs3qjSmQL4koVr7E+TLvrhQ80OsPi3uP/JyHDeagLja50xgr6FHN4EaPZUxQJyjLqQ== X-Received: by 2002:a65:6258:: with SMTP id q24-v6mr9057376pgv.131.1531990141030; Thu, 19 Jul 2018 01:49:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdnDNfEO41wyyBlWRlxpMeIh2xLT2P5RaD2T98geoI1gose1s3UN+dPQKdej97bLh0N82Y7 X-Received: by 2002:a65:6258:: with SMTP id q24-v6mr9057347pgv.131.1531990140352; Thu, 19 Jul 2018 01:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531990140; cv=none; d=google.com; s=arc-20160816; b=F1Y53st0qvN7jOewgx0weuH57IGVE5xIK4AtynfaT51YGul1Uo3wBzURZMruxdvxtT rG4dp2RWww9TplF+dTWUsEaMKgB86LeqCcsOVCya1GvkbAUykece29Gmaxar7K1icUku 9pQY0xEQAWXlj2pU/N0rNI6E2Nj62Vdh+uFCu//4p/GvcWh2YPa72TfMrErpm6ReKrSD RfkbOeU7JUMKjAfj6dA73aRFlnaQ8CIax9pOMG1hl6X7H9miIjVro+sUG+oL3+RpQyT6 i2kZ3RGo9xNziL557K8XfnNViIrpJKEXCwx0imXDXW25Nn8SbL5Mk5/XD2sCqhGWzGHG g4Dw== 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=AYAYAZf7sJhSGquy6vqROw7Jiu0lxQ8wO41Id0hdW3w=; b=pVvZouFzBERY0UC5CfV+6DgjumXkATcbWYWJG5x0OngsboYjqpSCXOxCGG1tx2bPjR qQDTKs+7+8m2K3miBX0oAPBupNKG4ZbBi2a9OllVSkqClgKcy4Q2D6iTnx+WAfkIlJWM 8VLgSvGWnUIOP2pDY+MyrLM8b42Pu2FBUkYfPyH1FUoHYuHG0EjGtrqXS/Ynh8Z1TUai DdNtuHE4/oyCc7VMq/CeJ3n/Vyk+Lg17eq6sAWN/MiFA0979i8JBDGRKi4V+8pzvb4wz RHTUWGS3dMfm6P84JzuAblObmms0L66kzOCIt234ZdZNUFVZblmAnKfhvAGK6tyvlPfX XqwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id x18-v6si4948122pll.193.2018.07.19.01.49.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.100 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 orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2018 01:49:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,374,1526367600"; d="scan'208";a="76038288" Received: from yhuang6-ux31a.sh.intel.com ([10.239.195.246]) by orsmga002.jf.intel.com with ESMTP; 19 Jul 2018 01:48:57 -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 , Dan Williams , Dave Hansen , Daniel Jordan Subject: [PATCH v3 4/8] swap: Unify normal/huge code path in swap_page_trans_huge_swapped() Date: Thu, 19 Jul 2018 16:48:38 +0800 Message-Id: <20180719084842.11385-5-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180719084842.11385-1-ying.huang@intel.com> References: <20180719084842.11385-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 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 Reviewed-by: Daniel Jordan Cc: Michal Hocko Cc: Johannes Weiner Cc: Shaohua Li Cc: Hugh Dickins Cc: Minchan Kim Cc: Rik van Riel 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 cb0bc54e99c0..96018207b582 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) @@ -1493,9 +1496,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 (swap_count(map[roffset]))