Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1742831imm; Fri, 6 Jul 2018 05:50:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpet7gjcHSkRsbw3IMU+fmeMGRkojO7clFfZX+lx3G3CyJYoRrLcpvxToGiXRf0//b/kFPuA X-Received: by 2002:a17:902:b717:: with SMTP id d23-v6mr10226854pls.105.1530881427414; Fri, 06 Jul 2018 05:50:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530881427; cv=none; d=google.com; s=arc-20160816; b=on+wBOL1t6bdHsUwNmV14sV75G+vXd8HNNO2dY90YknuhT7eEa9F8fjF4mSacp5zUm 19uZWG33KDsbtnBnbOhcR5s27H+Rn/KOZa37KRpQQg7ikIhyPqOOkZoTxnnJD3xuKp/l VyYgc7VytDb+ZU1AohcRjGfe/W3kddZm7X8dWeXiir+4vdW2w3QvfrWYOg7rVgyOqYNl fyENpWfBbpt3t7P7xgF9UMeLWokH8YQfhcCOsrSQwunyaXNwPUab5wdbPBKqMBTpfWyk YDx0MOphX8BjCf3+SUtXGjM7SmdysJwr7CSSkbbGtpif7urghg1vCLRPqYGZERFErGGs XfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=hVF5+mj89e/IydX68wkcAHth9sffk+oTtJ97//l4LpM=; b=fVRAcGiyuA2GUhX99QGJg3zPVTPrxgiRX1rIDtux0zotkaaLXgKgrl3noiz0FYAgTH bh6ntTdCuYtGPdnY5FmGQD9HQcoT49S19G3b9LiYDYaGH4HOO2ZvTEG2lnY23u+3A3la 7DHBrINN6mByN0WA1RzmzJzeDtuyZYfKDWZ6j9oECJOs6q/zHWlkqGe24sOg3+uIYo1X kVQnsbB80LO5ILiUNIT02qOBMnd88C2wx8bjA4KvhaN9jgjbGA9zarC8GeTn96zMGs3a YqfVYnMShRyhocdx1S4yXSphqAyaeoIiWf35pv1jqOysgA2BWDyb/iEZqXMVlTTMk1JA VHxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16-v6si8033253pgb.39.2018.07.06.05.50.12; Fri, 06 Jul 2018 05:50:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933177AbeGFMtT (ORCPT + 99 others); Fri, 6 Jul 2018 08:49:19 -0400 Received: from mga03.intel.com ([134.134.136.65]:57888 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932569AbeGFMtS (ORCPT ); Fri, 6 Jul 2018 08:49:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jul 2018 05:49:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,316,1526367600"; d="scan'208";a="69174603" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.13.118]) by fmsmga004.fm.intel.com with ESMTP; 06 Jul 2018 05:49:05 -0700 From: "Huang\, Ying" To: Daniel Jordan Cc: Andrew Morton , , , "Kirill A. Shutemov" , Andrea Arcangeli , Michal Hocko , Johannes Weiner , "Shaohua Li" , Hugh Dickins , Minchan Kim , Rik van Riel , Dave Hansen , Naoya Horiguchi , Zi Yan Subject: Re: [PATCH -mm -v4 05/21] mm, THP, swap: Support PMD swap mapping in free_swap_and_cache()/swap_free() References: <20180622035151.6676-1-ying.huang@intel.com> <20180622035151.6676-6-ying.huang@intel.com> <20180705183318.je4gd32awgh2tnb5@ca-dmjordan1.us.oracle.com> Date: Fri, 06 Jul 2018 20:49:05 +0800 In-Reply-To: <20180705183318.je4gd32awgh2tnb5@ca-dmjordan1.us.oracle.com> (Daniel Jordan's message of "Thu, 5 Jul 2018 11:33:18 -0700") Message-ID: <877em8msvy.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel Jordan writes: > On Fri, Jun 22, 2018 at 11:51:35AM +0800, Huang, Ying wrote: >> +static unsigned char swap_free_cluster(struct swap_info_struct *si, >> + swp_entry_t entry) > ... >> + /* Cluster has been split, free each swap entries in cluster */ >> + if (!cluster_is_huge(ci)) { >> + unlock_cluster(ci); >> + for (i = 0; i < SWAPFILE_CLUSTER; i++, entry.val++) { >> + if (!__swap_entry_free(si, entry, 1)) { >> + free_entries++; >> + free_swap_slot(entry); >> + } >> + } > > Is is better on average to use __swap_entry_free_locked instead of > __swap_entry_free here? I'm not sure myself, just asking. > > As it's written, if the cluster's been split, we always take and drop the > cluster lock 512 times, but if we don't expect to call free_swap_slot that > often, then we could just drop and retake the cluster lock inside the innermost > 'if' against the possibility that free_swap_slot eventually makes us take the > cluster lock again. Yes. This is a good idea. Thanks for your suggestion! I will change this in the next version. Best Regards, Huang, Ying > ... >> + return !(free_entries == SWAPFILE_CLUSTER); > > return free_entries != SWAPFILE_CLUSTER;