From patchwork Tue Jul 17 00:55:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 10527853 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 28849600F4 for ; Tue, 17 Jul 2018 00:56:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D4A3285A5 for ; Tue, 17 Jul 2018 00:56:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11A4E286B4; Tue, 17 Jul 2018 00:56:07 +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 9E4C7285A5 for ; Tue, 17 Jul 2018 00:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EF7D6B0271; Mon, 16 Jul 2018 20:56:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 17BAE6B0273; Mon, 16 Jul 2018 20:56:01 -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 01FDF6B0274; Mon, 16 Jul 2018 20:56:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id A50976B0271 for ; Mon, 16 Jul 2018 20:56:00 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id u18-v6so26096842pfh.21 for ; Mon, 16 Jul 2018 17:56:00 -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=vMxhWlTOLi58Jde3woRQ+hFOoltqvySB9drlK2gFz6U=; b=Rjol2SPPl6aZpS1kIWOsI5BAM/uvk6Xc6TkgMBjUGtRZDZqfiaXbqblnFuHCxPOh7d jqecgBC00WCmf+OzR5KNNbqntUnapWN/DnfGQRhj+PdJ/4hGb3Rlx43lHg94bUL5S17n xAWSlpIIMfcoqWIxVGeocwLisJx+MTWFiiNwfeCI7oP9rDaQDYXkqivEPxLB5i/fIOj0 Qk01JLioETQXs0ugaZGH03aOSBJYaF8tDp5abRVHiqtjvBVAWjcPZZ77oTpInFPwZcfh C5/bAAIhXrSOrQPOaIuxfPb9MCWih/FtC7kcmSSLhxS2TKnuVIdp+ImK4r1+vZxOcH9z 0xDw== 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: AOUpUlEWVZNxSZz+Yoxuv0jjuhbzfxX/RoDQm9wWPa8WbDO1JZk6UM+a Lyjulh7rL9nlLQ5ZrwjvQEmZRxzlmf4Fhzu+T562GYwP5yn4DmK+xVNV5YMUo6QzwI/kk5549lR r9d/rmmeI3yUfp2wDlyI7Iqcu1XPJ5Og/UK2ZOoKY12/JFrNYrOQJ46QTSrLuo9hG5g== X-Received: by 2002:a17:902:904c:: with SMTP id w12-v6mr9363492plz.95.1531788960386; Mon, 16 Jul 2018 17:56:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcMrFxWSB6cPNUT7YNF0qiIr/lp4VdaUFkj7KDhB3yeTRrYrCVipGHAvmEkPqsulIYuk9ti X-Received: by 2002:a17:902:904c:: with SMTP id w12-v6mr9363455plz.95.1531788959714; Mon, 16 Jul 2018 17:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531788959; cv=none; d=google.com; s=arc-20160816; b=Bi20lVnqWUsAKf8VYFlW42sX3j0fwot9ExTzv4Co9qrPDkDlN8m80HbRbla9vj7WQU wNUJk5qvYFq/9DvyYn2irBl6Nw1dAqZCNDY7p2Xfk8c0koCSIO30wZZ9pS5X+IHo15Ir zES0XusHczdibZznJpz9m1/nBV/R9S1VVrDg0+OHNb1M4ibJ0Qf0Ei1E5HwPI1SiVS4P JSEygim4rYvYEKvn2oYcSNRQ2w8H0ktNxWlvIjoTj7MKwwNXenHJphdRvVHagVENLi2v kcLUspP27azcVpc1Jd/tnyxk3QXNkml3qxMadsjTeNWMzhsVQ9UaTjY4mj3roWb2itSd 5Bqw== 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=vMxhWlTOLi58Jde3woRQ+hFOoltqvySB9drlK2gFz6U=; b=0mgq4cjvADAu7JWXaCvcQDwaH13qgIuP2+IZBAuD3A0Q0UMNSlRLLz2Ht2N8du+4V6 PkJo4M6ozh14laEs2A08yEDomiIxJLklIIefo7QE0xrAPprCO+a+6Isu99Sds7zdEQvB zsZdp/QZZhIR5R4FOZDDsijg3pmIcqD8EWnT/6i6vx/MblsDGgmdQWVFfHQKbGeSTbnD PcMt2wyEAPok/QRTSybiGBNZLu0mB/oxHvcQGkGsufhcUpM3qpgo4xqMwMTIXgBz5b8Q JSTwjk8/RgYjuCjW9Jyhqvqu3HOhRgfni/rH6+Lshee0qcxhCxPycwoNT+2btOY+O3Ep VUvw== 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.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 17:55:59 -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:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,363,1526367600"; d="scan'208";a="245788303" Received: from yhuang6-ux31a.sh.intel.com ([10.239.197.184]) by fmsmga005.fm.intel.com with ESMTP; 16 Jul 2018 17:55:57 -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 , Daniel Jordan , Dan Williams Subject: [PATCH v2 6/7] swap: Add __swap_entry_free_locked() Date: Tue, 17 Jul 2018 08:55:55 +0800 Message-Id: <20180717005556.29758-7-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 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 622edc47b67a..fec28f6c05b0 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;