From patchwork Thu Jul 19 08:48:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10533893 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 03DD060554 for ; Thu, 19 Jul 2018 08:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E82C8295D9 for ; Thu, 19 Jul 2018 08:49:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCA15295DD; Thu, 19 Jul 2018 08:49:03 +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 F3FF7295D9 for ; Thu, 19 Jul 2018 08:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DD826B0275; Thu, 19 Jul 2018 04:48:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B59D6B0277; Thu, 19 Jul 2018 04:48: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 1E3156B0278; Thu, 19 Jul 2018 04:48:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id CA0BB6B0275 for ; Thu, 19 Jul 2018 04:48:58 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id x2-v6so4188973plv.0 for ; Thu, 19 Jul 2018 01:48:58 -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=vlT+Qu5UVDi6R0OC4Wb1KR8Qa8RJAIAQPj4JB8wJOCI=; b=BjmSJkuhRealav90kBW77rEFJNI+xHAufWz/tk7AVJCb+8hA6jbzdHU7UwH6qjskJb +Dgjf7Szu60ItHi8HAFjbvEw9u7lzLQ009XAUdXOeG3EjAZZnHWkZ4BNA4Cjo2fAzLWh ztIrZzDECsJAz1IrTzyEAcZxg6YVbhpZXXQ4jwtRYTPSpgiyHzqUNxQePZWfYETlIQNj yyinWki5fbH/oQl/F83zd4Cu5oGs0jbFpsLDNhWHYx8XoBRDFKdRYZI48N8vc/ng+wTm jFpi8KPCvzkn3j+2lfOQJZ8Oh+iELlq8H4w/YMSTuUYu+zkv9Pp/BaW9t8PYbjSME5H8 bTJg== 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: AOUpUlGdzh9R4/aiZn/UWquSszs+AvWQX/EzmWtx3stB4EsSsXQiAewC NPmP/TQ4ATAo1Ai/khMStxZ5LOgHitqCHgNBB4SrzGLKJiabffAhiMMXSGQnIfodolV3PDlynKq R0eiBXhVfa48JiXtn7T5GaIsQ8WNskdufNg+ZeQtpUe+RMdY9MVIFFRbh+wY6KSeW9Q== X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr9309809plh.291.1531990138524; Thu, 19 Jul 2018 01:48:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcL6Zhys0yvGVWzIQZLyecYu0oj8kqppfSglpieXjwnZzhvSL/fEWVBlTRbQPkT+wFaWNP0 X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr9309766plh.291.1531990137855; Thu, 19 Jul 2018 01:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531990137; cv=none; d=google.com; s=arc-20160816; b=A/pL1vUWBJoawkTZL8OWB5lpb9wl38wxJ14xfpTv2iw5u2GcNRL5gmSA7Yn9g/wUHR h1XBmNLzUzQ14paI/Rk27HUi6/LJYehV0oxaSmc8O6uOOMGnlaMVfxIyBt+5cboJHR5F 1f8ifjPrd4K//7BapPgU9VTj0i5q9Wlg+6hIGrFJhVjflmYccqCuMsBo+0R3DYXAkho9 XBKQ7Sj+yODilJmhJPq1rfhojSVGSjJIZDt8v6+1B9Dvh90su/UPp34bj3s1U2BWx5e9 aB4+jzZADY5/7WbaahyUv30xEtDtawFpIMHs/K+nXajPIk3LnDSvQcvQTA3mC+TKqeBS GMUQ== 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=vlT+Qu5UVDi6R0OC4Wb1KR8Qa8RJAIAQPj4JB8wJOCI=; b=wjbPMPNzfawCwi21IEf6oFI4pzhKLnbw2DvkNL9FyiTUu7TFlXVMuYZC6JCDsZkKq2 syBWVYgce9qcG2OQuLwBN4psWAr/1RZZmV2D/7tFvZD3ZXE4QW0jPx5JOVd/3IVeSKqe 8+32VV1S+2NaGJWvMmFIgAbJF90pJkfm01rxb8R6pxvwJrMr21VgwMTcA+Voa4a9n8pv ORFRPCqBnaz8VUgUgz0+oLIFkslWyBcOk5c4iktY/qJB/Cs7X3h/CexfH1XsY+V2wzmw Vr1b7vhzr6Yvp/foj2HtjBEOb4b0swMkNLlziKBSuOGuqychsK4tXW1HGSYgD4yqEzFO FBJQ== 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.48.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:48:57 -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:48:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,374,1526367600"; d="scan'208";a="76038280" Received: from yhuang6-ux31a.sh.intel.com ([10.239.195.246]) by orsmga002.jf.intel.com with ESMTP; 19 Jul 2018 01:48:55 -0700 From: Huang Ying To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Dave Hansen , Michal Hocko , Johannes Weiner , Shaohua Li , Hugh Dickins , Minchan Kim , Rik van Riel , Dan Williams , Daniel Jordan Subject: [PATCH v3 3/8] swap: Use swap_count() in swap_page_trans_huge_swapped() Date: Thu, 19 Jul 2018 16:48:37 +0800 Message-Id: <20180719084842.11385-4-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 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 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 87c4c3446aed..cb0bc54e99c0 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1498,12 +1498,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; }