From patchwork Tue Jul 17 00:55:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10527845 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 4025B600F4 for ; Tue, 17 Jul 2018 00:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36372285A5 for ; Tue, 17 Jul 2018 00:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AB84286B4; Tue, 17 Jul 2018 00:56:01 +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 BAD8F285A5 for ; Tue, 17 Jul 2018 00:56:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D68A6B026E; Mon, 16 Jul 2018 20:55:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 437B96B026F; Mon, 16 Jul 2018 20:55:57 -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 2E18A6B0270; Mon, 16 Jul 2018 20:55:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id CCCD06B026E for ; Mon, 16 Jul 2018 20:55:56 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id d22-v6so7951111pls.4 for ; Mon, 16 Jul 2018 17:55:56 -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=2d227zTidl0IGVNpUUG65Vj8P23gv/Au5XnP1mQS9uI=; b=pcRo6dWXDcofHlNSGyayLOiWYsz+Nauv3llQX4ll0/wJPO2IqnazOGJOcczmiVxkYw p2+387d+8sRPIZ/U/m17wftyY37zKjxIFLA485ePCFV/iGRpM1d+yQ13kQJxvhfpwQZw AvOp5S6lsCVcJFg/ReDCHy2U/gokmXbbVRYsL19uiJSiP84UqM/N3fV0Xpz7QjBVPikn KlNO7kd2dRWor1TPl0TLpREMUi+q62A975DeDhdIPVl4XvFu3IaxERnZEK3ruqgKkZma yaM2AK2DLHBuWbQxNwW5zd6xRxFXyfvPoVqD0sidJWSUuRU0RcvGgTvRBxZmC3uh/kch 7H0w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 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: AOUpUlFGpjplDMxXDUjpAaf+tpz4BWgyzjdy2dDLTYCYpct79+MqMcA4 Y0A0+MTATYfVu3imLYTOu4ezZvBGwGNAxxN8r9E0jCThmPgzh6ViF19jKSa+NGiEJTjS1NJuyLq 6NoVcQn0xUNDwLE+JeXjkZIp3beq4aFx1lQAANCBxC3+uQC5FUyqUiEZ4gF9XO3EaJw== X-Received: by 2002:a17:902:50ec:: with SMTP id c41-v6mr6832806plj.269.1531788956543; Mon, 16 Jul 2018 17:55:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf0blulcrmCkxHnFDWXp0qRmj1Eapxtkebi2wpZRFYwmf+7L7FoTlF/wwnSH6lt0UUgJsbf X-Received: by 2002:a17:902:50ec:: with SMTP id c41-v6mr6832768plj.269.1531788955681; Mon, 16 Jul 2018 17:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531788955; cv=none; d=google.com; s=arc-20160816; b=SCaeUW4r0QYjkAHr4TQMoDmeYvnoT0L6drS8s93EhMp8LOUU2xIhrl5BLjGNwYgtua wKQ8J8Bpe24f2soT0s0kKDE+u46ER+jrFkOg8+Sp8U6dXCUcIpxM84qIGOdSoMiuZT5T TUo170MQMOHwC3ILF6tNcCONKS+3iDWB8RcYrjG+d70jQ857fr6IKnzE+bIY4HDAKAmL wX/fnZmqtdBli3LYsGVdCe13klloHcboyVwlLa8iQ41bAw/PuR69eCVhu1K02zCCnPrB iaA/9dlkwZndMgoRepGed1Fo/LHZyTgt2naNCpJde5Q/tnImihdr5KGQHQnfzmQ6CGIK a+Xg== 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=2d227zTidl0IGVNpUUG65Vj8P23gv/Au5XnP1mQS9uI=; b=Aa/afyamQjc2TSimXxbCFukMRah3zy1x4kCRMnQ5gVoICL++qDBPkukzSrHr9eXVsZ eeEg5lUZnBhR4Hkf6flT30yZCGk98Cig7o7gi93M0ti+E0XY378bAtyknkhcP0ChFmzB zqf36B1lZor2vwaQPiJJeUfcmAAjLruPyJWKI5ubWr63YKMhkLMzD5sBKulrOHYIsGFP 4GJ5GckHNPySaArzLyZ7JkLCZvUIt/ErNbH9OBfnD7c7kT8v7lIUK1wZLn8pXVCfUwcY bzeA9IqCoSo3/Kt6VTC7EEfAAK7rqUrGzbnzdLpDPVItQedyNL3RmEpoeesdRCFJiJYF LPyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id bc5-v6si30619643plb.413.2018.07.16.17.55.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 17:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.126 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 fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 17:55:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,363,1526367600"; d="scan'208";a="245788293" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.184]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2018 17:55:53 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Daniel Jordan , Dan Williams , Dave Hansen Subject: [PATCH v2 4/7] swap: Unify normal/huge code path in swap_page_trans_huge_swapped() Date: Tue, 17 Jul 2018 08:55:53 +0800 Message-Id: <20180717005556.29758-5-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180717005556.29758-1-ying.huang@intel.com> References: <20180717005556.29758-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 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 92c24402706c..a6d8b8117bc5 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 (swap_count(map[roffset]))