From patchwork Mon Aug 27 07:55:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10576571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70145139B for ; Mon, 27 Aug 2018 07:55:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AC9F2973A for ; Mon, 27 Aug 2018 07:55:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EA8A29847; Mon, 27 Aug 2018 07:55:48 +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 8CE0A2973A for ; Mon, 27 Aug 2018 07:55:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2287F6B3F67; Mon, 27 Aug 2018 03:55:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1B5E26B3F69; Mon, 27 Aug 2018 03:55:46 -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 052E16B3F6B; Mon, 27 Aug 2018 03:55:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id B0A086B3F67 for ; Mon, 27 Aug 2018 03:55:45 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id h65-v6so10904260pfk.18 for ; Mon, 27 Aug 2018 00:55:45 -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=22O/2wy3rsjyyKtZpoopK56F+Com0gmVZoeqsNxvFWo=; b=cNZYKyf4k6fkqsGmCDasASE0MOAfNIEsMS8vX+H0w0ucA77VqJecwhIElPYY3dMQPU BPtqtT700vvbL9JRd++cqyxSJeskJejlmSsuKPCDIRP1gUT54wTNvrGplmFu/dkMB/Sj PYYYtbD9MSfOtnVv6dlIfhukxiFFwNPCtI14wZablokWYnTzJTfUvnTeUuNrH8K2cmBF y4JW39zrRIoCWsXP1j6y/nkzZNVpqsfLzu4bwCsbUiI5RqO2/JzkiS2cxVxGK5P3BSpf dFdfAKn6zw/R4IlnIbEvpTYsvlrzlr3JpL8SGD5/ikHqqmrTrVgioXOQePb91I6WA1S4 Owhg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 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: APzg51B+0e9sOddMsQHTezpEQzjgiNNlbfM0NdUOubtxs+CW3mGiOwYt nZ5O29Jhq0B3j6myRCo4NbJmYM/ceDG58qXHRC27BCNDq3cwP6lypUM8WQjijDrWejP7il+54xE k5nMzOAP0bAG9X0khNxmisCpRNTMrzpYok2l37XwLq2PO1So5Wgx7OpWzwH4wNJJ+CA== X-Received: by 2002:a63:170e:: with SMTP id x14-v6mr10902209pgl.364.1535356545354; Mon, 27 Aug 2018 00:55:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZrBtxK3lduQZf8PoK1P1tBDlVIiV+Kezc5A2h/yfTij7IWyNB6aJkdds/L0qCQVADamigC X-Received: by 2002:a63:170e:: with SMTP id x14-v6mr10902168pgl.364.1535356544484; Mon, 27 Aug 2018 00:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535356544; cv=none; d=google.com; s=arc-20160816; b=wvjVi8SqS+MunqU5fWKy+SN5EftM0praFmsNs+cj7ceeHlQHKlprLsmz9V1Bub1tja NTxnWlNjNy/pMCcbox9Pw2y/dRssZFJxnxueECCtXGCEkD3trQLe8iaCTrJySlP53weW 5nT0uzN1/s90nyWixg3wv/YM3sNEq9I9oQBlxHUq5sGN1srGdFmd+2yZGFvU6qh4kUZw EfWL5T2CIlsZvCSvXAwhz9o5H3xnp+2E9ax0yHYLJDcKUg/3Qi8DzFB+mqtW55v3DVns /8kscFLnlkrOmqQKk+cCoEMZ9viJQcU23nl3ei0WW8OCDvEyKvSOCGrETJF9Aw6xwDVn JRUw== 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=22O/2wy3rsjyyKtZpoopK56F+Com0gmVZoeqsNxvFWo=; b=fJ+wIy31mi2e7m831//05H/J0nQ0bH2MalqpuP31rE/Pkb0kJzoFTj1lUvE46qksyP 0cX3J4cUEx1ZetEnDt8uOr6ItkdA2801kAn+qwLxUSlYfG30WosTvui1kDgpkg7XummD Sb4pZXwdmUHiwCwAXByqBitRJWbFGwqOKo3ay6+icEv8b1vzGMgQsClW3lWE6v2+q6Hc CqW9sNPAPHe76lXAiJ59rwuDyIgqVjl4wiiLjLwden+7bEApiT5TqdBOKkuYP/ouAoTY GpTXeWbD+Jp3JfJ47offJ4p2IcEKeSaEEb2sKUZHeLArck7MlkrpAcTJ/QBLpRmHAiZj r8qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id j5-v6si13565094plk.406.2018.08.27.00.55.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 00:55:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.43 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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Aug 2018 00:55:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,294,1531810800"; d="scan'208";a="80463046" Received: from yhuang-mobile.sh.intel.com ([10.239.198.115]) by fmsmga002.fm.intel.com with ESMTP; 27 Aug 2018 00:55:41 -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 Subject: [PATCH 2/3] swap: call free_swap_slot() in __swap_entry_free() Date: Mon, 27 Aug 2018 15:55:34 +0800 Message-Id: <20180827075535.17406-3-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180827075535.17406-1-ying.huang@intel.com> References: <20180827075535.17406-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 This is a code cleanup patch without functionality change. Originally, when __swap_entry_free() is called, and its return value is 0, free_swap_slot() will always be called to free the swap entry to the per-CPU pool. So move the call to free_swap_slot() to __swap_entry_free() to simplify the code. Signed-off-by: "Huang, Ying" Cc: Dave Hansen Cc: Michal Hocko Cc: Johannes Weiner Cc: Shaohua Li Cc: Hugh Dickins Cc: Minchan Kim --- mm/swapfile.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 409926079607..ef974bbd7715 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1241,6 +1241,8 @@ static unsigned char __swap_entry_free(struct swap_info_struct *p, ci = lock_cluster_or_swap_info(p, offset); usage = __swap_entry_free_locked(p, offset, usage); unlock_cluster_or_swap_info(p, ci); + if (!usage) + free_swap_slot(entry); return usage; } @@ -1271,10 +1273,8 @@ void swap_free(swp_entry_t entry) struct swap_info_struct *p; p = _swap_info_get(entry); - if (p) { - if (!__swap_entry_free(p, entry, 1)) - free_swap_slot(entry); - } + if (p) + __swap_entry_free(p, entry, 1); } /* @@ -1705,8 +1705,6 @@ int free_swap_and_cache(swp_entry_t entry) !swap_page_trans_huge_swapped(p, entry)) __try_to_reclaim_swap(p, swp_offset(entry), TTRS_UNMAPPED | TTRS_FULL); - else if (!count) - free_swap_slot(entry); } return p != NULL; }