From patchwork Fri Jul 20 07:18:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10536045 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 1221E602CA for ; Fri, 20 Jul 2018 07:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F30E528610 for ; Fri, 20 Jul 2018 07:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7C6429873; Fri, 20 Jul 2018 07:20:26 +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 7AC1E29869 for ; Fri, 20 Jul 2018 07:20:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C20016B0005; Fri, 20 Jul 2018 03:19:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 960C96B0007; Fri, 20 Jul 2018 03:19:59 -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 64B6C6B000E; Fri, 20 Jul 2018 03:19:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 188196B0007 for ; Fri, 20 Jul 2018 03:19:59 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id b9-v6so5342674pgq.17 for ; Fri, 20 Jul 2018 00:19:59 -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=lFdiqFEkhbJ66zoIJDnJD/53BBkRX7trwCRAJnx1qpE=; b=FgMYv+JbuPpADwPmGt9opq0ZgoNVIw6Ds54SDmWyWNgEMvMId2oet6WAJhqVIYor2m nicGwrouCAOLe+hpxe7rC9kDDMMij0VbHlElbX3g0gVc83xIJ3YQyrIWEFkShlJlZZgA TSpqK0WFigv1WTCqEqprBUhDyxfqQRSVE/NYy3BFkOGFaKFXgXzw5jnb+AhOmYICVGkc DD+ratP7lThLGobyXRvmqxWn+HLQU3cPS6aYB2kUbwtRnURqlGCmI2q1p73PRyUVdVzr V6Yn6jJxW7jL9odRVuEx6/sIbsvQEcSdqMJVr8nBYmWLcQoJQwdLR2I2TI29mztEhMfx PbAw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.65 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: AOUpUlHLIboKLJAp7GwAD11WSQb6FUwhNklGKE42fFA24uAEjPR58Ijz K/BfduA/iOoXqThKdUkUysuSvfxlXmECVhVjfhrZvnYw+WhTcYclqt1HBZntrHTDuf5u4DsqVhR T6JyNevOagqy7P4GRrksIAmEvNxFDJw+90G+/L1dEXzYWZEWWw0ByyfkAsR6Pj83bEw== X-Received: by 2002:a17:902:c4:: with SMTP id a62-v6mr970924pla.344.1532071198793; Fri, 20 Jul 2018 00:19:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe76+YpFFfgEfIA4fnnB9mlourD+56U0SH/rM/THE01I6o3XtLPEvok00nR4ukmPuN+QYDh X-Received: by 2002:a17:902:c4:: with SMTP id a62-v6mr970847pla.344.1532071197152; Fri, 20 Jul 2018 00:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532071197; cv=none; d=google.com; s=arc-20160816; b=x801cEn+ysitBfDh0lMxEZGWoS3UFwpKDcxNfzE5Djza3uU+HVqipO1ynB4KwDnrYV 3Nm7WtkN+hceK2AOyv7V4RpIkcSfUPh50nw4/kl2hzT85Q9N02B22d/A5P0Br//P0PMi QfSga1dFDc41gw954OvM7awFA+0Spfc6592XxJLGCHKWJFyWtOowtU5/vOKA8EOEpLRl I+spDc8phvQWVBdLoKx6y7vL+ynzbSbCATAE7u9KKoeKq3zDw1Jo6C7ecJ//Vw5rHL50 AHPvmzy9ieV4A/iQu2eCZmVB06INmuX1dkdeHbjMbM+K79Siu9Fx6V7DbGgDarrTXJ3B D7/g== 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=lFdiqFEkhbJ66zoIJDnJD/53BBkRX7trwCRAJnx1qpE=; b=jv1/gh0reRMPBlrEe62HQ3KEgz/yzG79zmDQl3lobSs54ocuE03R9nNncO2D5ZN5qF eKzIpggKEUybm79M/ht0Xak/D+zzIjkcVAt2bDoNCscbcCt1BcwPMgIlDrW/AGuohdLS BgzFnNl3ZLy97lkJndTHdLKhVZkWYb+zNos+OzT3iB6IoO39/c79h53Q4v+Jx1lwx2M+ xmaZBInnUqwiKwUIk7w9vIAbUZFx+LECQg/vO48Z02x4Wu2MbZmSq0US+PpPX4LDhJK9 5IQ6E1N/aBcpHjIVfQzNO4UnocjNhw4E2AeD9x6UMChQpFwZGYRO7pxnHGDBoY79WxJl QkKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga03.intel.com (mga03.intel.com. [134.134.136.65]) by mx.google.com with ESMTPS id q90-v6si1235046pfa.272.2018.07.20.00.19.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 00:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 134.134.136.65 as permitted sender) client-ip=134.134.136.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 134.134.136.65 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 fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jul 2018 00:19:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,377,1526367600"; d="scan'208";a="68652042" Received: from yhuang6-ux31a.sh.intel.com ([10.239.198.6]) by fmsmga002.fm.intel.com with ESMTP; 20 Jul 2018 00:18: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 , Daniel Jordan , Dave Hansen Subject: [PATCH v4 3/8] swap: Use swap_count() in swap_page_trans_huge_swapped() Date: Fri, 20 Jul 2018 15:18:40 +0800 Message-Id: <20180720071845.17920-4-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180720071845.17920-1-ying.huang@intel.com> References: <20180720071845.17920-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-and-reviewed-by: Daniel Jordan Acked-by: 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 7283104bfafa..833613e59ef7 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1497,12 +1497,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; }