From patchwork Tue Jul 17 00:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10527841 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 35269600F4 for ; Tue, 17 Jul 2018 00:55:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B372285A5 for ; Tue, 17 Jul 2018 00:55:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E7BC286B4; Tue, 17 Jul 2018 00:55:58 +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 BB482285A5 for ; Tue, 17 Jul 2018 00:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE8466B026B; Mon, 16 Jul 2018 20:55:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E704E6B026D; Mon, 16 Jul 2018 20:55:54 -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 D17526B026E; Mon, 16 Jul 2018 20:55:54 -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 825EC6B026B for ; Mon, 16 Jul 2018 20:55:54 -0400 (EDT) Received: by mail-pl0-f70.google.com with SMTP id s3-v6so25683527plp.21 for ; Mon, 16 Jul 2018 17:55:54 -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=FyiaanC7wESlf9DRJSFA7M7jKwuV0ZzjtFQJoL7oJCo=; b=l5ZyMOtfW0+YRjyg4NZsWPz5Lylaoqe08yV5BtqetptqzOdvqSJSZ0HWkDFuxUr3K5 45I2g6QLBxvv3okn1HYSdNbIGNV2hEL7nYw6oMxyltKYfo7PxVf870Xhmcp2Iwx+nHpd Axv4+OTHm8Ba0rdZ9daRluObUR5bP8Ua4i+PX5SDKE/Xzj0YDVURNxfIMgajkaHLntmP j4G6iyxFliSuBPL5moP4o9WoRvq/S9pj8GHkqkbpJ2pwUb9RoLmejKYGsKeQiUq2FWJa J3r58QvobMES7bEvEYNtyc+mEEx0S+ADfu7QvQ5BAnyLKbka8zPIiu/+GsY4e8XFlnr/ je+A== 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: AOUpUlFPGkXwcp1PQUS9xpn++3v/HMi2mIMf9O+bRALAijoKqlvRxeCE jvXRIBuOChLxEPBkzYqAJ/87odTVDhkH7dzyBvk8x9VzHIBnzR3wRTF8HyYlDsoA3ecKxGxnmRL SPhypqwIdJMQY8YhOIBWjyhr/nae3pXLrjjZPy6furTdZ7dvVlkw5pifH2ZKgOBAosQ== X-Received: by 2002:a63:f616:: with SMTP id m22-v6mr3325025pgh.293.1531788954230; Mon, 16 Jul 2018 17:55:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdesymWu6Ic/TeU4OgdkmaNfVzPEi1M46ayms1nHithi0i4cCr6gtsiVYhHnvSFmVSmb50O X-Received: by 2002:a63:f616:: with SMTP id m22-v6mr3324995pgh.293.1531788953596; Mon, 16 Jul 2018 17:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531788953; cv=none; d=google.com; s=arc-20160816; b=YKopg9U5HZ3hcQjg/M7+8TX9aN3ty3gLLP3Y6XFLhkrA01w3bhOwuxRoxEksEyaC1k oOZLVNkhqtSzNtgewd/YsT/515xa0CPEnqea9FJp03+RchkRZjD+TLnGGwYmuwOn+Qfj khaiE3heFJwMxX4dgjDyUx4rJutQOrizgfv7M9K2CkmUBqPTROmWZtCMDsF2fA73Pfio qT7XQs7lYqbmc5J410pVrXwHht6DsjyuBrw3ihQLMZlCyR3h468n7K+Ge9pvChazjdyP Ns6+4vkgJ39wERTLRXSn7WvmBben3aiJ94YPGL1LFk+mxqvyp4wBClq9PvK2VZGj5DIQ 894g== 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=FyiaanC7wESlf9DRJSFA7M7jKwuV0ZzjtFQJoL7oJCo=; b=JSD3ny5rPPPWiP5lp/Pymu3ZP0sOsJJzd2iFVdPnnh2iOWpXUmDFefGJvhoZKmz+x9 6/ZVWoo47wG1z+tA3VLtWyV4bhYr6HRVpiT4axxF3l7MjMN70kTE4hHWZGJMMWR6HZbo LGIOYimzGNzXpFGX9pWQWfvdnGn4wzI4KE93eNSuSgftyIafkokgzb9WYQ2daEWshTkG w/hnRc+5e1EKOB99UQTuL6lP3KbVVrw1gqsCRc55ZgnNdkFTZ+gSG3U4w8Xzmv6tPhlJ EOjqRck9hH9/cZWKY/gbpk1amXd42jxISSrXw+s3EwRpcroCLjZLf8/TB5TVYyVArRXb 6rgA== 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.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 17:55:53 -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:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,363,1526367600"; d="scan'208";a="245788288" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.184]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2018 17:55:51 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Dan Williams , Daniel Jordan Subject: [PATCH v2 3/7] swap: Use swap_count() in swap_page_trans_huge_swapped() Date: Tue, 17 Jul 2018 08:55:52 +0800 Message-Id: <20180717005556.29758-4-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 In swap_page_trans_huge_swapped(), to identify whether there's any page table mapping for a 4k sized swap entry, "si->swap_map[i] != SWAP_HAS_CACHE" is used. This works correctly now, because all users of the function will only call it after checking SWAP_HAS_CACHE. But as pointed out by Daniel, it is better to use "swap_count(map[i])" here, because it works for "map[i] == 0" case too. And this makes the implementation more consistent between normal and huge swap entry. Signed-off-by: "Huang, Ying" Suggested-by: Daniel Jordan Cc: Dave Hansen 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index dd9263411f11..92c24402706c 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1494,12 +1494,12 @@ static bool swap_page_trans_huge_swapped(struct swap_info_struct *si, ci = lock_cluster_or_swap_info(si, offset); if (!ci || !cluster_is_huge(ci)) { - if (map[roffset] != SWAP_HAS_CACHE) + if (swap_count(map[roffset])) ret = true; goto unlock_out; } for (i = 0; i < SWAPFILE_CLUSTER; i++) { - if (map[offset + i] != SWAP_HAS_CACHE) { + if (swap_count(map[offset + i])) { ret = true; break; }