From patchwork Thu Jul 12 23:36:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10522421 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 DEB2C601C2 for ; Thu, 12 Jul 2018 23:37:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD56727D16 for ; Thu, 12 Jul 2018 23:37:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFDBA298A6; Thu, 12 Jul 2018 23:37:16 +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 ECC0129878 for ; Thu, 12 Jul 2018 23:37:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA2706B026A; Thu, 12 Jul 2018 19:37:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B8EF66B0269; Thu, 12 Jul 2018 19:37:07 -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 6FE1B6B0010; Thu, 12 Jul 2018 19:37:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 1A82F6B0269 for ; Thu, 12 Jul 2018 19:37:07 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id i123-v6so11421641pfc.13 for ; Thu, 12 Jul 2018 16:37:07 -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=69ncGG9J53IpMBnM0LQNg2fXrulyU9qg38UVBO2+mEs=; b=mWfmUVZ0tK0eP4I3e9dVVDfrV9n9ijMtgrA4R6wMTL7Z5VwPfb2aJy6/SUGRuTtHIP qpA0hL1wonA4+U7oTYZB0SugkoNs5dNwevRR0B3ttjWVmBnSYLyXpAcopGR7bDYOs0Sx sXQv7BESGg8fi0nahVkSjb5VsGU12KHfelUCvcZtUnPuAcyucWkLMW0/9hZ81kuKSH5c A7gtA+E3tIR1he6VYwW32fYkAZpmQhm9aWQ0DsWsGTdaswQniPh0e5ZNxlenfY+oFRxJ 73nHfncGNFtIekvHeOSG0P/YM3bWQdNl5lbqkZKzJBSGAaFlw7orMMMuM52gRai6vkwe Pw1Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 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: AOUpUlHjT4YBQBjpu45TRBhTz97LOBgZN/obK+Y1Kczrzidl/I8dLmnV 4kFiLK4E9zM7VOm3iG7xBKHfvKclMpC+YkZQxG1OA3NoRZUVyJaPrfjP77VW8LN1r9UURD8BRwJ jBCAU+8JSycR2GjfIIJTUiwyGW1Xdz9yrJ2Oga3WI+zWcmALlAfJ8T7TWMlpT0ivk6Q== X-Received: by 2002:a62:90d4:: with SMTP id q81-v6mr4505241pfk.37.1531438626805; Thu, 12 Jul 2018 16:37:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcEtN6lkP+RakPZuU5D5ynTEZwY0XhyKBtLsM/o1+MJM9emQ3/aJsskqhmXd/vh0xcCIXmn X-Received: by 2002:a62:90d4:: with SMTP id q81-v6mr4505204pfk.37.1531438626001; Thu, 12 Jul 2018 16:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531438625; cv=none; d=google.com; s=arc-20160816; b=RZxcSFLd+Eb8FeVq5+7afje6c0sb9DEnuwmLaKynvcy8FFzhRXWBDooQjIUSlCPgQN uGQia3a9wKGJJiXYz4UO1yWkWrAxRP51dfs7lQ9XyMStrcpd02iC8GN5CAUH6LtQ2e6M YaqavuHraNxAWc7KgGNZcDbaE2f+iLGAwWYC67S0LO5G9DkzaISah7OSpPRR6ID4YPpS ZC2CGRFSQBlnplS5oFj/8m49XaI75l1mm3H7jUQp1f9WgD2swvAX4UZdv3GPsfKifCpG 9ipxeuSsHjlZw/PyOT7thujEURkalcw3WLbizl2N1Hn0TvCCMDT/lWRGXrZJVNMofyIl hM4Q== 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=69ncGG9J53IpMBnM0LQNg2fXrulyU9qg38UVBO2+mEs=; b=FIg6tifC+lQg7I/ZOqVV2heAkoDF9Kl8zUepSHXTtwe566m5GseYm1hieyXtGlnEql ySYG69pdtxnRJsq8tYqbmN1pXGWKZawdjQgxtIE9GRAI5SuIqtytRunBBJ6vwhbDoo5g osHw/m6yfRsUZUN8RGTdRlPIzGzCpeioYbuUAuJEIzNTBWFRlc4NazRD/AEwhq36TgjK 7U+n51FUgqVdCqpx/ksTP7gEU+iqCBeL0Ix5ddZ+VRvxkX3YQjnGnw8zzerHH0+tp6P3 dGn8uI9bCLXRgk5WLDwsorVwgqjDnrDNhHIEIcGHygE2Tb9EPNIls8p+qShakKwjH4fN 9mLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id o184-v6si21060983pga.520.2018.07.12.16.37.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 16:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ying.huang@intel.com designates 192.55.52.151 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 orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2018 16:37:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,345,1526367600"; d="scan'208";a="57272269" Received: from yongjuns-mobl2.ccr.corp.intel.com (HELO yhuang6-ux31a.ccr.corp.intel.com) ([10.254.213.67]) by orsmga006.jf.intel.com with ESMTP; 12 Jul 2018 16:36: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 , Daniel Jordan , Dan Williams Subject: [PATCH 5/6] swap: Add __swap_entry_free_locked() Date: Fri, 13 Jul 2018 07:36:35 +0800 Message-Id: <20180712233636.20629-6-ying.huang@intel.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180712233636.20629-1-ying.huang@intel.com> References: <20180712233636.20629-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 From: Huang Ying The part of __swap_entry_free() with lock held is separated into a new function __swap_entry_free_locked(). Because we want to reuse that piece of code in some other places. Just mechanical code refactoring, there is no any functional change in this function. Signed-off-by: "Huang, Ying" Cc: 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 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index e0df8d22ac92..bc488bf36c86 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1180,16 +1180,13 @@ struct swap_info_struct *get_swap_device(swp_entry_t entry) return NULL; } -static unsigned char __swap_entry_free(struct swap_info_struct *p, - swp_entry_t entry, unsigned char usage) +static unsigned char __swap_entry_free_locked(struct swap_info_struct *p, + unsigned long offset, + unsigned char usage) { - struct swap_cluster_info *ci; - unsigned long offset = swp_offset(entry); unsigned char count; unsigned char has_cache; - ci = lock_cluster_or_swap_info(p, offset); - count = p->swap_map[offset]; has_cache = count & SWAP_HAS_CACHE; @@ -1217,6 +1214,17 @@ static unsigned char __swap_entry_free(struct swap_info_struct *p, usage = count | has_cache; p->swap_map[offset] = usage ? : SWAP_HAS_CACHE; + return usage; +} + +static unsigned char __swap_entry_free(struct swap_info_struct *p, + swp_entry_t entry, unsigned char usage) +{ + struct swap_cluster_info *ci; + unsigned long offset = swp_offset(entry); + + ci = lock_cluster_or_swap_info(p, offset); + usage = __swap_entry_free_locked(p, offset, usage); unlock_cluster_or_swap_info(p, ci); return usage;